Add Pauli-flow extraction from pattern corrections#539
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #539 +/- ##
==========================================
+ Coverage 88.85% 89.09% +0.23%
==========================================
Files 49 49
Lines 7135 7253 +118
==========================================
+ Hits 6340 6462 +122
+ Misses 795 791 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
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. |
|
The CI broke because of a new Matplotlib release. It was fixed in #541, which has now been merged. Could you merge the current master into your branch? |
|
Addressed both outstanding items in the latest push.
On #526/#534: I agree the core method is the same GF(2) reconstruction; I am not claiming a fundamentally different algorithm. This branch's current value is that it is small, uses Graphix's existing linear-algebra machinery, and keeps the correctness evidence focused on exact X/Z corrections round trips plus the new edge cases. I am glad to adapt this branch toward whichever implementation shape maintainers prefer. Local verification:
|
Summary
Adds
XZCorrections.to_pauli_flow()andPattern.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 existingPauliFlow.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_flowuv run --with pytest --with pytest-benchmark pytest tests/test_flow_core.py tests/test_pattern.pyuv 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.pyuv 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.pyuv 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.pyDisclosure
Travis Crew (CrewRiz) used AI-assisted coding support while preparing this PR.