Skip to content

Add Pauli-flow extraction from pattern corrections#539

Open
CrewRiz wants to merge 1 commit into
TeamGraphix:masterfrom
CrewRiz:codex/unitaryhack-pauli-flow-from-pattern
Open

Add Pauli-flow extraction from pattern corrections#539
CrewRiz wants to merge 1 commit into
TeamGraphix:masterfrom
CrewRiz:codex/unitaryhack-pauli-flow-from-pattern

Conversation

@CrewRiz

@CrewRiz CrewRiz commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Adds XZCorrections.to_pauli_flow() and Pattern.extract_pauli_flow() so Pauli flow can be extracted directly from pattern X/Z corrections without rerunning Pauli-flow extraction on the underlying open graph. The converter reconstructs compatible correction sets by solving the Pauli-flow parity constraints over GF(2), then validates with the existing PauliFlow.check_well_formed() checks.

Closes #432.

Tests

  • uv run --with pytest --with pytest-benchmark pytest tests/test_flow_core.py::TestFlowPatternConversion::test_corrections_to_pauli_flow tests/test_pattern.py::TestPattern::test_extract_pauli_flow
  • uv run --with pytest --with pytest-benchmark pytest tests/test_flow_core.py tests/test_pattern.py
  • uv run --with pytest --with pytest-benchmark pytest (3162 passed, 151 skipped, 2 xfailed)
  • uv run --with ruff==0.15.16 ruff check graphix/flow/core.py graphix/flow/exceptions.py graphix/pattern.py tests/test_flow_core.py tests/test_pattern.py
  • uv run --with ruff==0.15.16 ruff format --check graphix/flow/core.py graphix/flow/exceptions.py graphix/pattern.py tests/test_flow_core.py tests/test_pattern.py
  • uv run --with pyright --with pytest pyright graphix/flow/core.py graphix/pattern.py tests/test_flow_core.py tests/test_pattern.py (0 errors, 0 warnings)
  • uv run --with mypy==2.1.0 --with pytest --with pytest-benchmark --with types-networkx==3.6.1.20260518 --with types-setuptools --with scipy-stubs mypy graphix/flow/core.py graphix/flow/exceptions.py graphix/pattern.py tests/test_flow_core.py tests/test_pattern.py

Disclosure

Travis Crew (CrewRiz) used AI-assisted coding support while preparing this PR.

@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.89189% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.90%. Comparing base (a2edfbc) to head (913c74c).

Files with missing lines Patch % Lines
graphix/flow/core.py 93.33% 7 Missing ⚠️
graphix/flow/exceptions.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #539      +/-   ##
==========================================
+ Coverage   88.85%   88.90%   +0.04%     
==========================================
  Files          49       49              
  Lines        7135     7246     +111     
==========================================
+ Hits         6340     6442     +102     
- Misses        795      804       +9     

☔ View full report in Codecov by Harness.
📢 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.

@thierry-martinez

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. As you may have noticed, two other pull requests (#526 and #534) already address the same issue.

The overall approach of your PR is very similar to the others: the Pauli‑flow definition yields a system of GF(2) equations, where the anachronical corrections are the unknowns, and solving this system provides the correction sets.

Could you clarify how your contribution differs from, or improves upon, the previous works? Specifically, please explain why you consider your approach to be better.

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.

Pauli-flow extraction from pattern

2 participants