[Stim] Accept ! and * in CORRELATED_ERROR / ELSE_CORRELATED_ERROR targets

Open Beginner friendly
#4,316 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
66/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python, rust
Domain
compilers

Research direction

The two diagnostics named in the issue, Qdk.Stim.Semantic.UnsupportedTarget and Qdk.Stim.Semantic.NegatedTarget, are the entry points: search for where they are raised and find the code that validates E, CORRELATED_ERROR and ELSE_CORRELATED_ERROR targets. Run the reproduction script from the issue to confirm the failures. Done when the * and ! forms compile to the same channel as the plain form and the script 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.

Low priority. qdk.stim rejects two Stim spellings of CORRELATED_ERROR/E and ELSE_CORRELATED_ERROR targets that Stim accepts:

Input Stim qdk.stim
E(0.1) X0 Z1 OK OK
E(0.1) X0*Z1, E(0.1) X0 * Z1 OK, same channel as X0 Z1 Qdk.Stim.Semantic.UnsupportedTarget
E(0.1) !X0 Z1 OK, same channel as X0 Z1 Qdk.Stim.Semantic.NegatedTarget

In both cases the meaning is unchanged. A correlated error's targets already form one Pauli product, so * is redundant. A ! only changes the global phase of the applied Pauli. Stim samples identical results for each pair (checked with Stim 1.16.0). (MPP X0 * Z1 is already accepted by qdk.stim.)

import sys
import qdk.stim

failed = []
for src in ["E(0.1) X0*Z1", "E(0.1) X0 * Z1", "E(0.1) !X0 Z1",
            "E(0.1) X0\nELSE_CORRELATED_ERROR(0.2) X0*!Z1"]:
    try:
        qdk.stim.compile(src)
    except Exception as e:
        failed.append(src)
        print(repr(src), "->", str(e).splitlines()[0])
if failed:
    print("REPRODUCED")
    sys.exit(1)
print("NOT REPRODUCED")

Describe the solution you'd like

For E/CORRELATED_ERROR/ELSE_CORRELATED_ERROR, treat * combiners like whitespace, with or without spaces around them. Accept ! on Pauli targets and ignore it.

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.