Skip to content

Add Pauli input initialization#225

Open
masa10-f wants to merge 2 commits into
agent/stim-importerfrom
agent/pauli-input-initialization
Open

Add Pauli input initialization#225
masa10-f wants to merge 2 commits into
agent/stim-importerfrom
agent/pauli-input-initialization

Conversation

@masa10-f

@masa10-f masa10-f commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add per-input positive Pauli eigenstate initialization (X+, Y+, Z+) through GraphState, Pattern, and qompile().
  • Compile input initialization to Stim reset instructions (RX, RY, R) and mirror the same states in PatternSimulator.
  • Bump exported .ptn files to format version 2 with .input_basis, while keeping version 1 files readable with X+ input defaults.
  • Update changelog and regression coverage for graph copying/composition, .ptn roundtrip, simulator behavior, and Stim export.

Validation

  • uv sync --locked --extra dev
  • uv run --no-sync pytest -m "not pyzx"
  • uv run --no-sync ruff check ./graphqomb ./tests ./examples
  • uv run --no-sync ruff format --check --diff
  • uv run --no-sync mypy
  • uv run --no-sync pyright
  • uv sync --locked --extra dev --extra pyzx --extra doc
  • uv run --no-sync pytest -m pyzx
  • uv run --no-sync pytest --cov=graphqomb --cov-report=term-missing --cov-report=xml --cov-branch
  • uv run --no-sync sphinx-build -W docs/source docs/build
  • PRE_COMMIT_HOME=/tmp/pre-commit pre-commit run --all-files

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.12397% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.27%. Comparing base (ce9282d) to head (4fbe580).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread graphqomb/simulator.py
Comment on lines +156 to +160
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant