Skip to content

fix(stim-parser)!: follow Stim's tag model#186

Open
rafaelha wants to merge 1 commit into
mainfrom
rafael/stim-raw-tag-atoms
Open

fix(stim-parser)!: follow Stim's tag model#186
rafaelha wants to merge 1 commit into
mainfrom
rafael/stim-raw-tag-atoms

Conversation

@rafaelha

@rafaelha rafaelha commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stim tags are a single opaque string, not a comma-separated list of structured values. This PR updates stim-parser to follow that model and moves PPVM-specific modifier parsing into the extended lowering stage.

  • Parse one decoded tag string per instruction, including spaces, commas, parentheses, punctuation, [, and Unicode.
  • Support Stim's \n, \r, \B, and \C escapes; reject unknown escapes and raw line breaks.
  • Preserve tags on gates, noise, measurements, annotations, MPP, MPAD, and REPEAT blocks.
  • Canonically re-encode decoded tags when printing.
  • Remove the public Tag / TagParam representation in favor of tag: String (breaking Rust AST change).

Simulation semantics

Tag interpretation is limited to PPVM's reserved carrier instructions:

Instruction Behavior
S / S_DAG Exact decoded tag T promotes to T / T-dagger; every other tag is ignored for simulation.
I Every non-empty tag must parse as a valid R_X, R_Y, R_Z, or U3 modifier; malformed, unknown, or comment-like tags are errors.
I_ERROR Only exact loss and correlated_loss tags are accepted.
Direct T / T_DAG Tags are ignored for simulation.
All other instructions Tags are metadata and do not affect simulation.

This keeps ordinary Stim metadata readable and compatible while preventing misspelled PPVM modifiers on I or I_ERROR from silently becoming comments.

Testing

  • cargo test --workspace -q
  • cargo clippy -p stim-parser -p ppvm-stim --all-targets -- -D warnings
  • Parser tests cover opaque content, every Stim escape, invalid escapes and raw line breaks, empty tags, annotations, REPEAT blocks, and parse/print/reparse behavior across every instruction family.
  • Lowering tests cover exact S[T], ignored metadata, strict I modifiers, strict I_ERROR modifiers, and direct T / T_DAG tags.

Copilot AI review requested due to automatic review settings July 17, 2026 14:17

This comment was marked as outdated.

@rafaelha
rafaelha marked this pull request as draft July 17, 2026 14:24
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://QuEraComputing.github.io/ppvm/pr-preview/pr-186/

Built to branch gh-pages at 2026-07-17 17:50 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@rafaelha
rafaelha force-pushed the rafael/stim-raw-tag-atoms branch from c17ada6 to f83d8e0 Compare July 17, 2026 17:47
@rafaelha rafaelha changed the title feat(stim-parser): accept raw Stim tag atoms alongside structured tags fix(stim-parser)!: follow Stim's opaque tag model Jul 17, 2026
@rafaelha
rafaelha requested a review from Copilot July 17, 2026 17:49
@rafaelha
rafaelha marked this pull request as ready for review July 17, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

@rafaelha rafaelha changed the title fix(stim-parser)!: follow Stim's opaque tag model fix(stim-parser)!: follow Stim's tag model Jul 17, 2026
@rafaelha
rafaelha requested a review from david-pl July 17, 2026 21:10
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.

2 participants