Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
There was a problem hiding this comment.
Pull request overview
Implements support for Stim’s SPP / SPP_DAG instructions in tsim by translating them into an auxiliary-qubit gadget, plus associated parsing, documentation, and tests.
Changes:
- Added
sppcore instruction (and extracted_apply_pauli_controlsshared withmpp). - Extended the Stim circuit parser to recognize and expand
SPP/SPP_DAG(including!-inverted targets and multi-product instructions). - Added unit/integration tests and updated the overview demo notebook with the new instructions.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/tsim/core/instructions.py |
Adds spp gadget implementation and extracts shared _apply_pauli_controls. |
src/tsim/core/parse.py |
Parses SPP / SPP_DAG targets into Pauli products and dispatches to spp. |
test/unit/core/test_parse.py |
Adds basic parsing tests ensuring SPP/SPP_DAG don’t create measurement records. |
test/integration/test_sampler_circuits.py |
Adds probability-based equivalence tests for SPP/SPP_DAG vs known gates. |
docs/demos/overview.ipynb |
Documents SPP / SPP_DAG semantics and shows a diagram example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class TestParseSPP: | ||
| """Tests for parsing SPP and SPP_DAG instructions.""" | ||
|
|
||
| def test_spp_single_pauli(self): | ||
| """SPP Z0 should parse without adding measurement records.""" | ||
| circuit = stim.Circuit("SPP Z0") | ||
| b = parse_stim_circuit(circuit) | ||
| assert len(b.rec) == 0 | ||
|
|
||
| def test_spp_product(self): | ||
| """SPP X0*Z1 should parse without adding measurement records.""" | ||
| circuit = stim.Circuit("SPP X0*Z1") | ||
| b = parse_stim_circuit(circuit) | ||
| assert len(b.rec) == 0 | ||
|
|
||
| def test_spp_dag_single_pauli(self): | ||
| """SPP_DAG Z0 should parse without adding measurement records.""" | ||
| circuit = stim.Circuit("SPP_DAG Z0") | ||
| b = parse_stim_circuit(circuit) | ||
| assert len(b.rec) == 0 | ||
|
|
||
| def test_spp_multiple_products(self): | ||
| """SPP with multiple products should parse correctly.""" | ||
| circuit = stim.Circuit("SPP X0 Y1*Z2") | ||
| b = parse_stim_circuit(circuit) | ||
| assert len(b.rec) == 0 |
There was a problem hiding this comment.
These new parsing tests assume the installed stim supports SPP/SPP_DAG. The project metadata currently allows stim>=1.0.0, which may permit versions that can't parse these instructions, causing test/runtime failures in downstream environments. Consider bumping the minimum supported stim version (or conditionally skipping these tests when the gate is unavailable).
… single and two-qubit SPP equivalences.
…per function `_iter_pauli_products` to streamline the extraction of Pauli products and their inversion status from circuit instructions.
…e a few new-ish Stim instructions that are not yet supported.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
_apply_pauli_controlshelper from MPP!) which toggle between SPP and SPP_DAG behaviorSPP X0*Y1*Z2) and multiple products per instructionCloses #74
Test plan
SPP Z0=S,SPP_DAG Z0=S_DAGSPP X0=SQRT_X,SPP !X0=SQRT_X_DAGSPP X0*X1=SQRT_XX,SPP Y0*Y1=SQRT_YY,SPP Z0*Z1=SQRT_ZZ🤖 Generated with Claude Code