Add Stim circuit importer#229
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #229 +/- ##
==========================================
+ Coverage 85.55% 86.09% +0.54%
==========================================
Files 27 29 +2
Lines 4035 4451 +416
Branches 703 783 +80
==========================================
+ Hits 3452 3832 +380
- Misses 413 438 +25
- Partials 170 181 +11 🚀 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: 6db8527614
ℹ️ 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".
| context: _ImportContext, | ||
| ) -> _Fragment: | ||
| text = _stim_text_with_coords(block, coordinate_by_stim_id=context.coordinate_by_stim_id) | ||
| extraction = stabilizer_code_from_stim_text(text, mpp_layer=None, coord_dims=context.coord_dims) |
There was a problem hiding this comment.
Split sequential MPP layers instead of merging them
When one tick block contains multiple MPP layers separated by annotations, such as MPP X0; DETECTOR rec[-1]; MPP Z0, this selects all products into one StabilizerCode and builds a single graph fragment. Stim executes those as sequential measurements, and non-commuting layers collapse the state between records; merging them into one stabilizer-code fragment makes both checks share the same data input/output chain, so the imported pattern can represent the wrong post-measurement state. Split these layers into composed MPP fragments, or reject non-commuting multi-layer blocks.
Useful? React with 👍 / 👎.
|
With this branch, I don't fully do integrated tests since a couple of upcoming PRs would touch the same files |
Summary
masterafter Add Stim MPP stabilizer import #217 was squash-merged.Correctness fixes
TICKboundaries do not change circuit semantics.Replaces #224, which GitHub cannot reopen after its deleted base branch was squash-merged and the head history was rebuilt.
Validation
uv run --no-sync pytest -s -m "not pyzx" -q— 531 passed, 1 skipped.uv run --no-sync pytest -s -m pyzx -q— 13 passed.uv run --no-sync pytest -s --cov=graphqomb --cov-report=term-missing --cov-report=xml --cov-branch -q— 544 passed, 87.98% total coverage.uv run --no-sync ruff check ./graphqomb ./tests ./examplesuv run --no-sync ruff format --check --diffuv run --no-sync mypyuv run --no-sync pyrightuv run --no-sync sphinx-build -W -E docs/source docs/build