qsharp icon indicating copy to clipboard operation
qsharp copied to clipboard

In Jupyter notebook, if simulation ended with runtime exception, allocated qubits are not cleared up

Open tcNickolas opened this issue 4 months ago • 6 comments

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

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

tcNickolas avatar Mar 15 '24 05:03 tcNickolas