Skip to content

Add detector determinism analysis#240

Open
masa10-f wants to merge 3 commits into
masterfrom
agent/detector-determinism
Open

Add detector determinism analysis#240
masa10-f wants to merge 3 commits into
masterfrom
agent/detector-determinism

Conversation

@masa10-f

@masa10-f masa10-f commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • construct a graph-state stabilizer for each closure-expanded detector group
  • report a detector as deterministic only when that stabilizer exactly equals the unsigned product of Pauli measurement axes on the detector support
  • require both Pauli axes and non-identity support to match, catching residual operators outside the detector and cancellations inside it
  • respect X/Y/Z input initialization and omit outputs without measurement bases from both sides of the comparison
  • document the new APIs in the changelog

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, and PauliFrame.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.py
  • mypy graphqomb/pauli_frame.py
  • pyright graphqomb/pauli_frame.py
  • git diff --check

@masa10-f
masa10-f marked this pull request as ready for review July 22, 2026 00:31
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.37%. Comparing base (98a4318) to head (7a56645).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread graphqomb/pauli_frame.py Outdated
Comment on lines +217 to +220
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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

1 participant