Skip to content

Conversation

@joeycarter
Copy link
Contributor

@joeycarter joeycarter commented Dec 5, 2025

Context: In #2188, we added a new PauliFrame dialect to Catalyst to represent programs using Pauli frame tracking protocols. This PR adds a new compilation pass, to-pauli-frame, which applies these Pauli frame tracking protocols to a Clifford+T program.

Description of the Change: Applying the to-pauli-frame pass applies the following transformations:

  1. Initialize the Pauli record of the qubits in a register by inserting a pauli_frame.init_qreg op immediately after quantum.alloc ops, taking the !quantum.reg as its input operand. A similar pattern that inserts a pauli_frame.init op immediately after a single-qubit allocation op quantum.alloc_qb is also applied.
  2. Converts Pauli gates to their equivalent pauli_frame.update ops, e.g. it replaces a Pauli X gate with a pauli_frame.update [1, 0] op, where the attributes in the square brackets are the [x, z] parity bits.
  3. Inserts pauli_frame.update_with_clifford ops immediately before Clifford ops (H, S, and CNOT).
  4. Flushes the Pauli record immediately before non-Clifford ops (T). Flushing applies the pauli_frame.flush op, which returns the x- and z-parity bits for the given qubit, and applies the X and Z gates to that qubit, conditional on the returned parity bits.
  5. Corrects single-qubit mid-circuit measurements by inserting pauli_frame.correct_measurement ops immediately after quantum.measure ops.
  6. Flushes the Pauli records of all relevant qubits immediately before applying terminal measurement processes.

Benefits: This is a proof-of-concept prototype that allows us to express quantum programs in Catalyst IR using Pauli frame tracking protocols.

Possible Drawbacks: This prototype is by no means production grade and the final version of this compilation pass used for utility-scale workloads will need updating for both functional purposes (e.g. to communicate with a remote process running the Pauli frame tracking process) and scalability purposes (e.g. flushing the Pauli frame for each qubit before performing terminal measurement processes is not optimal, as it requires many calls into the Pauli frame process to retrieve the Pauli records, and as it currently inlines all of these operations into the main region that performs the quantum execution). The scalability issues might be avoided by carefully defining a new operation that corrects the measurement results in an array of samples in one go.

Another detail that we have not considered in this prototype is handling the Pauli byproduct corrections in a program's MBQC representation. This is a more challenging task because of the state-teleportation that occurs in MBQC, and it will need to be addressed in a future PR.


[sc-103533]

@joeycarter joeycarter changed the title Add passes that apply Clifford+T -> Pauli frame protocols Add pass that applies Clifford+T -> Pauli frame protocols Dec 5, 2025
@joeycarter joeycarter marked this pull request as ready for review December 10, 2025 17:13
@joeycarter
Copy link
Contributor Author

joeycarter commented Dec 10, 2025

Can't reproduce the failing lit test locally—will need to investigate.

Update: Fixed with a code refactor.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.99%. Comparing base (433b7e4) to head (53fc824).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2269      +/-   ##
==========================================
- Coverage   97.21%   96.99%   -0.23%     
==========================================
  Files          93       93              
  Lines       11243    11243              
  Branches     1075     1075              
==========================================
- Hits        10930    10905      -25     
- Misses        246      266      +20     
- Partials       67       72       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants