Add Pauli input initialization#225
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## agent/stim-importer #225 +/- ##
=======================================================
+ Coverage 79.85% 85.27% +5.42%
=======================================================
Files 28 28
Lines 4219 4312 +93
Branches 731 742 +11
=======================================================
+ Hits 3369 3677 +308
+ Misses 698 451 -247
- Partials 152 184 +32 🚀 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: d41dd5ff32
ℹ️ 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".
| input_states = [ | ||
| _INPUT_STATE_VECTORS[self.__pattern.input_initialization_axes.get(node, Axis.X)] | ||
| for node in self.node_indices | ||
| ] | ||
| self.state = StateVector.from_product_states(input_states) |
There was a problem hiding this comment.
Sample initialized inputs from the state
With these new per-axis initial states, PatternSimulator must respect the measurement probabilities for measured input nodes. For example, a pattern that initializes an input with Axis.Z and then measures that non-output node in Z should always return the + result (Stim export now emits R then MZ), but the existing M handler still samples every non-output measurement as rng.uniform() < 1 / 2 and then projects the state; half the time it chooses a zero-probability branch, yielding an impossible outcome or zero-norm state. Please sample these measurements from self.state instead of relying on the old 50/50 shortcut.
Useful? React with 👍 / 👎.
Summary
X+,Y+,Z+) throughGraphState,Pattern, andqompile().RX,RY,R) and mirror the same states inPatternSimulator..ptnfiles to format version 2 with.input_basis, while keeping version 1 files readable withX+input defaults..ptnroundtrip, simulator behavior, and Stim export.Validation
uv sync --locked --extra devuv run --no-sync pytest -m "not pyzx"uv run --no-sync ruff check ./graphqomb ./tests ./examplesuv run --no-sync ruff format --check --diffuv run --no-sync mypyuv run --no-sync pyrightuv sync --locked --extra dev --extra pyzx --extra docuv run --no-sync pytest -m pyzxuv run --no-sync pytest --cov=graphqomb --cov-report=term-missing --cov-report=xml --cov-branchuv run --no-sync sphinx-build -W docs/source docs/buildPRE_COMMIT_HOME=/tmp/pre-commit pre-commit run --all-files