[Stim] Accept lowercase and mixed-case instruction names

Open Beginner friendly
#4,313 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, rust
Domain
compilers

Research direction

The failure is the Qdk.Stim.Semantic.UnknownInstruction error raised by qdk.stim.compile on lowercase or mixed-case gate names. Start by finding where instruction names are looked up and make that lookup case-insensitive, including the cnot and zcx aliases. Done when the reproduction script in the issue prints NOT REPRODUCED.

Written by the indexing model from the issue text.

Description

enhancement needs triage

Is your feature request related to a problem? Please describe.

Stim treats gate names as case-insensitive: h 0, cx 0 1 and Mpp Z0 are all valid Stim. qdk.stim rejects them with Qdk.Stim.Semantic.UnknownInstruction, so some valid Stim files can't be compiled.

import sys
import qdk.stim

failed = []
for src in ["R 0\nh 0\nm 0", "R 0\nH 0\nMpp Z0", "R 0 1\ncx 0 1\nM 0 1"]:
    try:
        qdk.stim.compile(src)
    except Exception:
        failed.append(src)
if failed:
    print("Rejected:", failed)
    print("REPRODUCED")
    sys.exit(1)
print("NOT REPRODUCED")

Describe the solution you'd like

Match instruction names case-insensitively (including aliases such as cnot and zcx), as Stim does.

Additional context

Found by differential fuzzing against Stim 1.16.0.

Dominant language
Rust
Stars
1k
Forks
226
Avg merge
2d 9h
Merged PRs (30d)
72

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/qdk

All issues in microsoft/qdk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.