Add Pauli input initialization#230
Conversation
# Conflicts: # CHANGELOG.md
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #230 +/- ##
==========================================
+ Coverage 86.09% 86.19% +0.09%
==========================================
Files 29 29
Lines 4451 4577 +126
Branches 783 802 +19
==========================================
+ Hits 3832 3945 +113
- Misses 438 448 +10
- Partials 181 184 +3 🚀 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: 5989bd7c53
ℹ️ 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".
| # Note: deterministic check skipped for now | ||
| self.state = StateVector.from_num_qubits(len(self.__pattern.input_node_indices)) | ||
| input_states = [ | ||
| _INPUT_STATE_VECTORS[self.__pattern.input_initialization_axes.get(node, Axis.X)] |
There was a problem hiding this comment.
Sample Pauli-initialized non-output measurements
When simulating a pattern where an input initialized with a new non-X basis is later measured as a non-output in the same basis (for example, a one-edge input/output graph with init_axis=Axis.Z and an MZ on the input), the state is now deterministic but apply_cmd(M) still samples all non-output measurements as 50/50. Half of those runs project onto an impossible branch and normalize a zero vector, producing NaNs or wrong downstream outputs; the simulator needs to sample these measurements from the current state when the Pauli input initialization can bias them.
Useful? React with 👍 / 👎.
Summary
X+,Y+,Z+) throughGraphState,Pattern, andqompile().RX,RY,R) and mirror the same states inPatternSimulator.R,RX,RY) as the corresponding input initialization states; reject mid-circuit resets explicitly.calc_prob=False..ptnfiles to format version 2 with.input_basis, while keeping version 1 files readable withX+input defaults..ptnversion 2 format..ptnroundtrip, simulator behavior, and Stim import/export.Rebase notes
masterafter Add Stim circuit importer #229 landed, resolving the changelog overlap while preserving both entries.Validation
uv run --no-sync pytest -q -s -m "not pyzx"— 622 passed, 13 deselected.uv run --no-sync pytest -q -s -m pyzx— 13 passed, 622 deselected.uv run --no-sync ruff check .anduv run --no-sync ruff format --check .uv run --no-sync mypy graphqombanduv run --no-sync pyright graphqombuv run --no-sync sphinx-build -W --keep-going -b html docs/source <output>