[STIM] Support Generalized Pauli Product Gates - #3556
[STIM] Support Generalized Pauli Product Gates#3556João Boechat (joao-boechat) wants to merge 14 commits into
Conversation
Dima Fedoriaka (fedimser)
left a comment
There was a problem hiding this comment.
In general, I would suggest adding a comment for each function explaining what it's doing (when it's not obvious from the name), which would make it easier to review. For example, decompose_pauli_product doesn't literally decompose Pauli product, but decomposes an instruction whose target is Pauli product.
| } | ||
|
|
||
| #[test] | ||
| fn pauli_product_negated_second_factor() { |
There was a problem hiding this comment.
Something about this seems off to me. The negation is on the Y1 target, and if this was a naked Pauli the negative sign would be inside the Pauli string, not in front of it: Pauli(-Y 1).
There was a problem hiding this comment.
Shouldn't the PauliProduct be displayed in a way that reflects this hierarchy?
i.e. PauliProduct(Pauli(X 0)*Pauli(-Y 1))
There was a problem hiding this comment.
Processing the negations during the parsing (i.e. cancelling out even negations) seems like we are doing evaluation at the wrong step of the process.
|
|
||
| #[test] | ||
| fn mpp_product_folding_to_identity_yields_error() { | ||
| // this is temporary |
There was a problem hiding this comment.
Is this comment left over from something?
There was a problem hiding this comment.
No, this is a temporary behavior that will disappear in a PR that's coming soon. I just left the comment there to remind myself of removing this test case.
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.