Open rtvuser1 opened 5 months ago
@rtvuser1 Thank you for reporting the issue! We should respect pythonic scoping (i.e. a variable can be declared inside a scope and used after), but we could definitely release the cubits if they are not used outside the scope, as in your case. Will work on that.
Required prerequisites
Describe the bug
In Python version, qubits allocated within a conditional do not appear to be localized to the kernel. The qubits for each new kernel appear to be added to the end of the prior kernels qubits. WORKAROUND: If no conditional is used to control the allocation, then the qubits do appear to be local to the kernel.
Steps to reproduce the bug
Expected behavior
The number and organization of qubits allocated within a kernel may need to be controlled by kernel parameters. However, if the qubits themselves are allocated within a block of code executed within a conditional, the qubits appear to be added to a previously created qvector. Instead a new qvector should be created inside each kernel instance. This can be seen by looking at the circuit diagram that is drawn in the above example after each kernel is created. The second one adds its qubits to the end of the vector instead of creating a new vector.
Simply uncomment the WORKAROUND block above and comment the offending code above it to see what the program should do.
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
Suggestions
This behavior is highly unexpected and may not even be noticed by a user until after the program grows and crashes with out of memory. And then, tracing the source to the allocation inside a conditional can take a bit of time and cause frustration. For these reasons, the issue should probably be addressed.