[STIM] Support Generalized Pauli Product Gates - #3556
Open
João Boechat (joao-boechat) wants to merge 10 commits into
Open
[STIM] Support Generalized Pauli Product Gates#3556João Boechat (joao-boechat) wants to merge 10 commits into
João Boechat (joao-boechat) wants to merge 10 commits into
Conversation
João Boechat (joao-boechat)
marked this pull request as ready for review
August 7, 2026 20:30
João Boechat (joao-boechat)
requested review from
Andrew Casey (amcasey),
Ian Davis (idavis) and
Stefan J. Wernli (swernli)
as code owners
August 7, 2026 20:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds QIR compiler support for Stim's generalized Pauli-product gates:
MPP,SPP, andSPP_DAG. For more info on how they work, I recommend the official stim docs.High-level changes
X1,Y1,Z1) and loss targets (e.g.L1) as separate tokens, rather than the general "instruction_name".*-connected Pauli targets into a singlePauliProductAST node. It combines factor negations with XOR and represents each term as aPauliFactor.Canonicalization
Before emission, the compiler canonicalizes each product by sorting factors by qubit, multiplying repeated same-qubit Paulis, and tracking the resulting phase
i^k. Odd phases are rejected because they produce an anti-Hermitian product. A-1phase negates the canonical product, while factors reducing to identity are removed.Decomposition
To emit the product, the compiler:
MPP: measure the focus qubit.SPP: applyS.SPP_DAG: applyS_DAG.Inversion logic
For
MPP, negation flips the measurement result. For phase gates, negation reverses the phase direction:Identity products
An
MPPtarget whose factors all cancel measures the identity, which is deterministic but still has to append a result to the measurement record. We don't have an instruction that appends to the measurement record without acting on a qubit, so these targets are rejected for now. Once that instruction exists,MPPwill be able to support them.SPPandSPP_DAGdon't have this limitation: phasing the identity is a global phase, so those targets are emitted as no-ops.