Add CCZ and CCX gate support#150
Open
glasses666 wants to merge 1 commit into
Open
Conversation
Issue QuEraComputing#113 asks for native CCZ and CCX/Toffoli support without taking on visualization. The implementation keeps the simulator path simple by expanding both shorthand and append API usage into the existing Clifford+T instruction set, using the collaborator-approved 7-T CCZ decomposition and deriving CCX by H-conjugating the target. Constraint: Stim does not parse CCZ or CCX instructions directly Constraint: Visualization support is explicitly out of scope for the bounty issue Rejected: Add direct Stim/GATE_TABLE native instructions | stim.Circuit would still reject source program text before tsim parsing Confidence: high Scope-risk: narrow Directive: Keep CCZ and CCX behavior aligned across program text parsing and Circuit.append Tested: PYTHONPATH=src uv run pytest -q (1087 passed) Tested: PYTHONPATH=src uv run ruff check src/tsim/utils/program_text.py src/tsim/circuit.py test/unit/test_circuit.py Tested: PYTHONPATH=src uv run black --check src/tsim/utils/program_text.py src/tsim/circuit.py test/unit/test_circuit.py Tested: PYTHONPATH=src uv run pyright src/tsim/circuit.py src/tsim/utils/program_text.py test/unit/test_circuit.py Not-tested: SVG/timeline visualization for CCZ/CCX, per issue scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #113.
Summary
CCZandCCX/Toffoli support by expanding both program-text shorthand andCircuit.append()calls into the existing Clifford+T instruction set.CCZdecomposition discussed in the issue, withCCXderived by H-conjugating the target.CCZandCCX, plus shorthand-vs-append coverage.Scope note
Visualization support is left out intentionally, matching the issue discussion that SVG visualization can be deferred.
Validation
PYTHONPATH=src uv run pytest -q->1087 passed in 46.24sPYTHONPATH=src uv run pytest test/unit/test_circuit.py -q->192 passed in 1.22sPYTHONPATH=src uv run pytest test/integration/test_gate_unitaries.py -q->117 passed in 2.27sPYTHONPATH=src uv run ruff check src/tsim/utils/program_text.py src/tsim/circuit.py test/unit/test_circuit.py->All checks passed!PYTHONPATH=src uv run black --check src/tsim/utils/program_text.py src/tsim/circuit.py test/unit/test_circuit.py->3 files would be left unchangedPYTHONPATH=src uv run pyright src/tsim/circuit.py src/tsim/utils/program_text.py test/unit/test_circuit.py->0 errors, 0 warnings, 0 informationsNote: in my local checkout, bare
uv run pytestdid not putsrc/onsys.path, so I usedPYTHONPATH=srcfor the validation commands above.