Skip to content

stim parser should merge gates across lines #291

Open

Description

@david-pl

Stim's Circuit parser merges consecutive lines into one instruction when gate name, arguments, and tag all match. stim_parser::parse keeps one instruction per source line.

Source Stim stim-parser
H 0 / H 1 H 0 1 2 instructions
CX 0 1 / CX 2 3 CX 0 1 2 3 2 instructions
M 0 / M 1 M 0 1 2 instructions
X_ERROR(0.1) 0 / X_ERROR(0.1) 1 X_ERROR(0.1) 0 1 2 instructions
H[tag] 0 / H[tag] 1 H[tag] 0 1 2 instructions
H 0 / H 0 H 0 0 2 instructions

Stim does not fuse when:

  • args differ (X_ERROR(0.1) 0 / X_ERROR(0.2) 1)
  • tags differ (H[a] 0 / H[b] 1)
  • any other instruction sits between the lines, including TICK

It also does not deduplicate targets (H 0 0 above).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions