[Bug] Interpreter stabilizer: `IsResourceEstimating()` is an unknown intrinsic

Open Beginner friendly
#4,174 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
rust

Research direction

Start by locating CliffordSim::custom_intrinsic in the stabilizer simulator and compare its handling with SparseSim, which the issue says already supports this intrinsic. Run the Python reproduction with the Adaptive_RIF profile and stabilizer backend. Done means the program returns [Zero, Zero] instead of an unknown intrinsic error.

Written by the indexing model from the issue text.

Description

bug bulk-filed needs triage
  • Symptom: Rejected
  • Release 5a7b2ee32: Non-regression
  • Where: interpreter · qsharp.run(type='stabilizer')

Summary. Any program calling IsResourceEstimating() (including library code such as AddLookup) fails on the stabilizer simulator with 'unknown intrinsic'.

Q# repro (Main.qs)

// Interpreter stabilizer backend: Std.ResourceEstimation.IsResourceEstimating() is an unknown intrinsic.
// Expected: false -> program returns Zero.   Observed (qsharp.run(type="stabilizer")): "unknown intrinsic `IsResourceEstimating`".
// (Sparse and the QIR simulators return Zero.)  Needs a profile that allows classical-if (Adaptive_RIF / Unrestricted).
namespace Repro {
    @EntryPoint()
    operation Main() : Result {
        use q = Qubit();
        if Std.ResourceEstimation.IsResourceEstimating() { X(q); }
        MResetZ(q)
    }
}

Python repro

# F8: CliffordSim::custom_intrinsic has no "IsResourceEstimating" arm.
from qdk import qsharp, Result

SRC = """
namespace Repro {
    operation Main() : Result {
        use q = Qubit();
        if Std.ResourceEstimation.IsResourceEstimating() { X(q); }
        MResetZ(q)
    }
}
"""
qsharp.init(target_profile=qsharp.TargetProfile.Adaptive_RIF)
qsharp.eval(SRC)
print("sparse    :", qsharp.run("Repro.Main()", shots=2, seed=1, type="sparse"), "(expected [Zero, Zero])")
try:
    got = qsharp.run("Repro.Main()", shots=2, seed=1, type="stabilizer")
except qsharp.QSharpError as e:
    msg = str(e).strip().splitlines()[0]
    print("stabilizer: ERROR", msg)
    if "unknown intrinsic" in msg and "IsResourceEstimating" in msg:
        print(f"VERDICT: REPRODUCED - {msg}")
        raise SystemExit(1)
    print(f"VERDICT: INCONCLUSIVE - different error: {msg}")
    raise SystemExit(2)
print("stabilizer:", got)
if got == [Result.Zero] * 2:
    print("VERDICT: NOT REPRODUCED - stabilizer returns Zero")
    raise SystemExit(0)
print(f"VERDICT: REPRODUCED - stabilizer returned {got}")
raise SystemExit(1)
Build Result Evidence
release 5a7b2ee32 bug present Error: unknown intrinsic IsResourceEstimating
main 42c843a20 bug present Error: unknown intrinsic IsResourceEstimating

Observed: stabilizer: Error: unknown intrinsic IsResourceEstimating (sparse returns [Zero, Zero])

Expected: [Zero, Zero]

Probable cause. CliffordSim::custom_intrinsic has no IsResourceEstimating arm (SparseSim handles it).

Originally reported as A127

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.