In Jupyter notebook, if simulation ended with runtime exception, allocated qubits are not cleared up
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
**Describe the bug**
In Jupyter notebook, if simulation ended with runtime exception, allocated qubits stay around. They show up in the next `DumpMachine` outputs, even though there's no way to access them or clear them up.
**To Reproduce**
```qsharp
open Microsoft.Quantum.Diagnostics;
operation Demo() : Unit {
use q = Qubit();
X(q);
DumpMachine();
}
Demo()
```
As you re-run this code, it throws an exception each time, and the number of allocated qubits grows by 1 each time, all of them in |1> state.
**Expected behavior**
I expect the allocated qubits to not show up in consecutive runs.
**System information**
- qsharp 1.2.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied Demo operation repeatedly in the Jupyter notebook with qsharp 1.2.0 and compare consecutive DumpMachine outputs. Trace what happens to simulator state after the runtime exception; done when qubits from a failed run no longer appear in later outputs or remain inaccessible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100