Add detector determinism analysis#240
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #240 +/- ##
==========================================
+ Coverage 86.36% 86.37% +0.01%
==========================================
Files 31 31
Lines 5112 5153 +41
Branches 908 916 +8
==========================================
+ Hits 4415 4451 +36
- Misses 491 494 +3
- Partials 206 208 +2 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25892e284c
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| all( | ||
| (node in output_nodes and node not in meas_bases) | ||
| or (node in meas_bases and determine_pauli_axis(meas_bases[node]) == pauli_axis) | ||
| for node, pauli_axis in stabilizer.items() |
There was a problem hiding this comment.
Require detector records to cover stabilizer support
When the stabilizer has measured non-output support outside the closure-expanded detector group, this reports the detector as deterministic even though the emitted parity omits required records. For example, on a two-node edge with parity_check_group=[{0}], node 0 measured X and node 1 measured Z, the stabilizer is X0 Z1 so this all(...) returns true, but detector_groups()/Stim export still emits only rec[0]; the deterministic relation is rec[0] xor rec[1], while rec[0] alone is random. Please either require the stabilizer support to be included in the detector records or include the extra measured support before marking it deterministic.
Useful? React with 👍 / 👎.
Summary
Why
Detector parity is deterministic when the measured Pauli product itself is a stabilizer. Comparing axes only on the stabilizer support could incorrectly accept extra measured operators outside the detector support or miss detector operators that cancel to identity.
Impact
PauliFrame.detector_stabilizers()exposes the non-identity Pauli support for each detector, andPauliFrame.detector_determinism()returns aligned exact-product determinism flags without changing Stim compilation behavior. Measurement signs are intentionally ignored.Validation
pytest -s -q(809 passed, 1 skipped)ruff check graphqomb/pauli_frame.py tests/test_pauli_frame.pymypy graphqomb/pauli_frame.pypyright graphqomb/pauli_frame.pygit diff --check