UnitaryHack 2026 - issue #142#152
Open
Mostafa-Atallah2020 wants to merge 14 commits into
Open
Conversation
added 11 commits
June 3, 2026 15:35
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba4b1fa393
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
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.
Fixes #142
Adds the parametric Pauli-rotation gates
R_XX,R_YY,R_ZZ, and the generalR_PAULI, matching the clifft two-qubit Pauli rotations reference.R_PAULI(theta) P0*P1*...appliesexp(-i * theta * pi/2 * P0 P1 ...)for an arbitrary Pauli product, andR_XX/R_YY/R_ZZare surface shorthands for the two-qubit same-axis case.Following the issue's suggested approach, the gates are encoded on top of stim's existing
SPP/tag pipeline rather than as a new instruction kind. The angle is carried in the tag the same wayR_X/R_Y/R_Zcarrytheta=...*piviaI[R_X(theta=...*pi)], andR_XX/R_YY/R_ZZlower toSPP[R_PAULI(theta=α*pi)] P0*P1. The lowering lives inCircuit.append, the new simulation primitivecore/instructions.r_pauligeneralisesSPP(θ=1/2) andTPP(θ=1/4) to arbitrary angles via the existing_pauli_product_phasemechanism, andcore/parse.parse_stim_circuitdispatches taggedSPP/SPP_DAGinstructions to it after a new validator rejects duplicate qubits within a single Pauli product and caps targets at 64 per instruction, both checked on the raw un-reduced target list.Clifford-angle rotations stay first-class.
is_half_pi_multiplenow recognisesSPP[R_PAULI(theta=k/2*pi)], and a new_expand_clifford_spphelper rewrites such instructions (includingSPP_DAG) into the equivalent tag-freeSPP/SPP+SPP/SPP_DAGsequence so simplification keeps producing pure-Clifford output. The shorthand layer is symmetric.shorthand_to_stimrewritesR_XX(α) 0 1,R_YY(α) 0 1,R_ZZ(α) 0 1, andR_PAULI(α) X0*Y1into the tagged-SPPform, andstim_to_shorthandruns the inverse with the same-axis collapse applied before the general one in both directions so theR_XX/R_YY/R_ZZsurface form survives round-trips. Daggered forms work for free because the negated angle threads throughr_pauli's existingdaggerparameter.Tests cover Stim-parity at Clifford angles, arbitrary-angle unitaries against the analytic
cos(α π/2)·I − i sin(α π/2)·PPform (Kronecker-expanded for generalR_PAULI), inverse round-trips via the existing inverse-of-inverse identity coverage, and the parser's duplicate-qubit and 64-qubit-cap validation paths.test/helpers/gate_matrices.pygains closed-form unitaries for the four new gates. The existing suite is untouched anduv run just coveragereports 95% on the committed tree (1e1b74f). Docs are updated inCHANGELOG.md(Unreleased entry) and in the Stim-API parity note inREADME.md/docs/index.md.