Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#465 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp
Área
backend, devtools

Línea de trabajo

Empieza en src/backend/dd/DDSimDebug.cpp, especialmente en ddsimStepForward y en las rutas de medición y reset de q[i]. Sigue cómo se almacenan y restauran previousInstructionStack y el estado DD, y después inspecciona el comportamiento existente de retroceso paso a paso del depurador. Se considera terminado cuando retroceder a través de ambas operaciones restaura el estado cuántico y los bits clásicos afectados, y el comportamiento de reproducción hacia delante queda resuelto.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

🤖 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).
Lenguaje dominante
C++
Estrellas
21
Forks
8
Merge medio
5 h 17 min
PR fusionados (30 d)
21

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de munich-quantum-toolkit/debugger

Todos los issues de munich-quantum-toolkit/debugger

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.