[Panic] Ctl operation that calls an element of an operation-array parameter panics
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with the reported invariant failure in qsc_fir_transforms/src/invariants.rs:1926, then inspect the defunctionalization evaluation and index order changes from #3893. Use the Q# example and Python reproduction in the issue to compare indexed calls under Ctl and Adj controls. Done means the reproductions compile without panicking across the listed profiles while the control cases continue to compile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
operation W(q : Qubit, ops : (Qubit => Unit is Ctl)[]) : Unit is Ctl {
ops[0](q);
}
operation Main() : Result {
use q = Qubit();
W(q, [S]);
MResetZ(q)
}
- Failure: every profile, including Base, panics in
qsc_fir_transforms/src/invariants.rs:1926:
PostArgPromote/PostAll call invariant violation: Expr 67 passes Expr 66 with type Tuple([Array(Prim(Qubit)), Prim(Qubit)]) to callee Expr 65 expecting input type Prim(Qubit). The program never usesControlled, so the
panic probably comes from the generated controlled specialization ofW, which passes(ctls, q)to an array
element. - What triggers it:
is Ctloris Adj + Ctl, together with indexing (ops[i](q)). It compiles withis Adj
alone, withfor op in ops { op(q); }, or with a single operation parameter instead of an array. - Regression: a bisect over the commits between merge base
7c6a2b51and main gives6adfda105(#3891)
compiles it, and84d1ec2e4"Defunctionalization: evaluation and index order (#3893)" panics. Branches without
#3893 (f05438eb,ca2fe553) compile it correctly. - Related: #3966 (open) reports the same invariant violation when
Controlledis applied to a callable-array closure through the Python callable API. This is a much simpler
trigger in plain Q#, with no closure, noControlledcall, and no Python, so it's likely the same root cause. - Impact: this accounts for half of all panics in the run, including all 8 Base panics, and stops every program
with aWgate-array operation from compiling.
"""Panic: an `is Ctl` operation that calls an element of an operation-array parameter.
Every profile, including Base, panics in qsc_fir_transforms (invariants.rs) with
"PostArgPromote/PostAll call invariant violation ... passes ... Tuple([Array(Prim(Qubit)), Prim(Qubit)]) to callee
... expecting input type Prim(Qubit)". The program never uses `Controlled`, so the panic probably comes from the
generated controlled specialization of `W`. It's a regression: a bisect over upstream/main gives 6adfda105 (#3891) good,
84d1ec2e4 "Defunctionalization: evaluation and index order (#3893)" bad. Related: #3966 (the same invariant through the
Python callable API with a callable-array closure).
The controls show what the trigger needs: `is Ctl` (or `is Adj + Ctl`) and indexing into the array. They compile.
Requires only the `qdk` package. Exits 0 while the panic reproduces.
"""
import sys
from qdk import Context, TargetProfile
PROFILES = ("Base", "Adaptive_RI", "Adaptive_RIF", "Adaptive")
MAIN = """
operation Main() : Result {
use q = Qubit();
W(q, [S]);
MResetZ(q)
}
"""
def w(functors: str, body: str) -> str:
return f"operation W(q : Qubit, ops : (Qubit => Unit is {functors})[]) : Unit is {functors} {{ {body} }}"
PROGRAMS = {
"Ctl, indexed (bug)": w("Ctl", "ops[0](q);"),
"Adj + Ctl, indexed (bug)": w("Adj + Ctl", "ops[0](q);"),
"Adj only, indexed (control)": w("Adj", "ops[0](q);"),
"Ctl, for loop (control)": w("Ctl", "for op in ops { op(q); }"),
}
def compile_status(source: str, profile: str) -> str:
ctx = Context(target_profile=getattr(TargetProfile, profile))
try:
ctx.eval(source)
ctx.compile("Main()")
return "ok"
except BaseException as e: # pyo3's PanicException derives from BaseException
kind = "PANIC" if type(e).__name__ == "PanicException" else "error"
return f"{kind}: {' '.join(str(e).split())[:110]}"
reproduced = False
for label, w in PROGRAMS.items():
print(label)
for profile in PROFILES:
status = compile_status(w + MAIN, profile)
print(f" {profile:13s} {status}")
if "(bug)" in label and "PostArgPromote" in status:
reproduced = True
print("REPRODUCED" if reproduced else "NOT REPRODUCED")
sys.exit(0 if reproduced else 1)
- Lingua principale
- Rust
- Stelle
- 1k
- Fork
- 219
- Merge medio
- 3g 19h
- PR unite (30g)
- 93
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/qdk
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[Samples] Investigate redundant CheckForse di nuovo libera @theARCania l’ha presa 43 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement good first issue low-priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoft/qdk#1933 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Fuzz: "" (ubuntu-latest)Forse già presa @swernli l’ha presa 1 giorno fa. Apertabug
microsoft/qdk#4019 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug needs triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
RCA: `set () = { … }` drops its value's dynamic kind; code is lostForse già presa @domorale l’ha presa 2 giorni fa. Apertabug needs triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/qdk
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
farion1231/cc-switch#8829 ·
I maintainer di solito rispondono entro 1 giorno
-
bug ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
longbridge/gpui-kit#3677 ·
I maintainer di solito rispondono entro 1 giorno
-
E-pr-welcome
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
seanmonstar/reqwest#3121 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
ilya-zlobintsev/LACT#1235 ·
I maintainer di solito rispondono entro 1 giorno