Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

✨ Allow `stepBackward` past a `measure` and `reset q[i]`

Aperta
#465 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend, devtools

Direzione di ricerca

Inizia in src/backend/dd/DDSimDebug.cpp, soprattutto in ddsimStepForward e nei percorsi di misurazione e reset di q[i]. Traccia come vengono memorizzati e ripristinati previousInstructionStack e lo stato DD, quindi esamina il comportamento esistente del debugger per il passo indietro. Il lavoro è completato quando il passo indietro attraverso entrambe le operazioni ripristina lo stato quantistico e i bit classici interessati, e il comportamento di replay in avanti è risolto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🤖 AI text below 🤖

Problem statement

Once a measure has been executed, the debugger refuses to step backward past it. ddsimStepForward in src/backend/dd/DDSimDebug.cpp clears previousInstructionStack after a measurement with the comment // after measurements, we can no longer step back.. The user loses access to the pre-measurement state, both the quantum superposition and the previous value of the target classical bit.

The reset q[i] operation (which performs a measurement internally) follows the same pattern and is also un-stepbackable.

Surfaced during the follow-up work on issue #168 (PR #456) and again during the review of PR #463.

Proposed solution

Applying the inverse of a measurement does not restore the pre-collapse superposition. The operation is genuinely irreversible in a physical sense, and the current code acknowledges this by blocking step back after a measure. Snapshot the state instead: before the measurement writes, save the quantum state together with the previous value of every classical bit it is about to touch. On step back, restore the snapshot. In the DD backend this is cheap because decision diagrams share structure through internal tables, so a snapshot is a pointer rather than a full state-vector copy.

Also drop the previousInstructionStack.clear() calls on the measure path and the reset q[i] path so the step-back path is actually reachable.

Open question

After stepping back past a measurement, the next stepForward can either re-sample the measurement (probabilistic: the operation runs again on the restored superposition and may give a different outcome) or force the previous outcome (deterministic replay: reproduces the original run bit-for-bit, at the cost of storing the outcome and/or the random-number generator state alongside the snapshot).

My preference would be probabilistic: it matches the simulator's natural semantics, requires no extra state beyond the snapshot already needed, and lines up with what a user would see on real hardware. Deterministic replay reads more like a separate feature (a "record-and-replay" mode) than an inherent part of step-back.

Final call is yours; happy to go the other way if you prefer.

Out of scope
  • Broader changes to the debugger's history model (call/return stacks, breakpoint state, etc.).
  • Persisting classical bit values across code reloads.
  • Restoring classical bits after non-measurement operations that write to them (there are currently none in the debugger's front-end).
Lingua principale
C++
Stelle
21
Fork
8
Merge medio
5h 17m
PR unite (30g)
21

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di munich-quantum-toolkit/debugger

Tutte le issue di munich-quantum-toolkit/debugger

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.