Support Stim tags and export Stim non-Clifford gates#688
Open
ChenZhao44 wants to merge 17 commits intomainfrom
Open
Support Stim tags and export Stim non-Clifford gates#688ChenZhao44 wants to merge 17 commits intomainfrom
ChenZhao44 wants to merge 17 commits intomainfrom
Conversation
Add tests for tag attribute on collapse dialect statements: - test_measurement_with_tag (MZ) - test_reset_with_tag (RZ) - test_ppmeasurement_with_tag (MPP) These tests will fail until StimStatement base class is implemented. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create StimStatement base class with tag attribute - Update Measurement, Reset, PPMeasurement to inherit from StimStatement - Update emit methods to include tag in output - Fix test expectations for float formatting Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for tag attribute on noise dialect statements: - test_depolarize_with_tag (Depolarize1) - test_pauli_channel_with_tag (PauliChannel1) These tests will fail until noise statements inherit from StimStatement. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update all noise statements (Depolarize1, Depolarize2, PauliChannel1, PauliChannel2, XError, YError, ZError, TrivialError, QubitLoss, etc.) to inherit from StimStatement base class, which provides the tag attribute. Update emit methods to format instructions with optional tag annotations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for TICK, DETECTOR, OBSERVABLE_INCLUDE, and QUBIT_COORDS instructions with tag annotations. Tests fail because the tag attribute doesn't exist on these statements yet. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update Tick, Detector, ObservableInclude, and QubitCoordinates statements to inherit from StimStatement base class, which provides the tag attribute. Update emit methods to format instructions with optional tag annotations. Fix test API usage for detector, observable_include, and qubit_coordinates. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update all wrapper functions to expose the tag parameter for: - Gate dialect (x, y, z, h, s, t, cx, cy, cz, swap, spp, etc.) - Collapse dialect (mz, my, mx, mzz, myy, mxx, mpp, rz, ry, rx) - Noise dialect (depolarize1, depolarize2, pauli_channel1, etc.) - Auxiliary dialect (tick, detector, observable_include, qubit_coords) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactor Gate and SPP to inherit from StimStatement instead of ir.Statement, removing duplicate tag attribute definitions. This centralizes the tag functionality in the StimStatement base class. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Sort imports alphabetically in src/bloqade/stim/__init__.py - Fix import order in collapse/stmts/pp_measure.py - Format long line in test_stim_tag.py per black requirements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
This PR includes changes to support stim tags for Stim circuit analysis. It also exports the non-Clifford gates explicitly in the dialect, allowing users to run potential simulations with Tsim.
To support the Stim tag, I introduced a base class for all Stim native statements, including gate, noise, collapse, and annotation. Those instructions are inherent from the
StimStatementbase class that includes the tag.One thing I would like to mention is that the tag now is typed as
tag: str = info.attribute(types.String, default=None)instead ofstr | None. I couldn't figure out how to make thetypes.UnionTypework for attributes. Probably it is a bug of theUnionType. Therefore, the current type will result in an error when the user explicitly setstag=None. For example,will not pass the compilation.