Skip to content

Add Stim circuit importer#224

Open
masa10-f wants to merge 3 commits into
feat/qec-helperfrom
agent/stim-importer
Open

Add Stim circuit importer#224
masa10-f wants to merge 3 commits into
feat/qec-helperfrom
agent/stim-importer

Conversation

@masa10-f

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

Copy link
Copy Markdown
Collaborator

Summary

  • Add a Stim importer that converts supported noiseless Clifford gate blocks and tick-separated MPP blocks into GraphQOMB patterns.
  • Preserve sparse Stim qubit mappings and QUBIT_COORDS metadata in the import result.
  • Add an opt-in QEC graph builder mode that exposes data layers as graph inputs/outputs for fragment composition.

Validation

  • uv run --extra stim pytest tests/test_stim_importer.py tests/test_stim_mpp.py tests/test_qec.py -q
  • uv run --extra stim pytest tests/test_stim_compiler.py tests/test_ptn_format.py::test_roundtrip_preserves_logical_observables_for_stim tests/test_ptn_format.py::test_roundtrip_preserves_detectors_for_stim -q
  • uv run --no-sync pyright graphqomb/stim_importer.py
  • uv run --no-sync ruff check

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.28814% with 148 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat/qec-helper@be48e39). Learn more about missing BASE report.

❌ Your patch check has failed because the patch coverage (37.28%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                Coverage Diff                 @@
##             feat/qec-helper     #224   +/-   ##
==================================================
  Coverage                   ?   79.85%           
==================================================
  Files                      ?       28           
  Lines                      ?     4219           
  Branches                   ?      731           
==================================================
  Hits                       ?     3369           
  Misses                     ?      698           
  Partials                   ?      152           
🚀 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: 740221185c

ℹ️ 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".

*,
context: _ImportContext,
) -> _Fragment:
circuit = Circuit(len(context.stim_to_qubit))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid creating identity wires for every tick block

When a tick-separated unitary block touches only some of the global Stim qubits, such as H 10 before a later MPP X10*Z12, this full-width Circuit creates an idle wire whose single graph node is both an input and an output. On the next compose for that same qindex, the matched output node is excluded and then remapped again as a graph1 input, leaving no node_map1 entry and causing the importer to raise KeyError instead of producing a pattern. Build each fragment only over the qubits present in that block, or handle these input/output identity nodes during composition.

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