Skip to content

Commit

Permalink
Fix issue where qubits are retained with draw / tracer (#1457)
Browse files Browse the repository at this point in the history
* Fix issue where qubits are retained with draw / tracer

---------

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
  • Loading branch information
amccaskey committed Apr 1, 2024
1 parent d355064 commit f6840d0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
30 changes: 30 additions & 0 deletions python/tests/kernel/test_kernel_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,33 @@ def kernel(argument: float):

with pytest.raises(RuntimeError) as error:
print(cudaq.draw(kernel))


def test_draw_bug_1400():

@cudaq.kernel
def bell_pair():
q = cudaq.qvector(2)
h(q[0])
cx(q[0], q[1])
mz(q)


@cudaq.kernel
def kernel(angle:float):
q = cudaq.qubit()
h(q)
ry(angle, q)


print(cudaq.draw(kernel, 0.59))
print(cudaq.draw(kernel, 0.59))
circuit = cudaq.draw(bell_pair)
print(circuit)
expected_str = ''' ╭───╮
q0 : ┤ h ├──●──
╰───╯╭─┴─╮
q1 : ─────┤ x ├
╰───╯
'''
assert circuit == expected_str
8 changes: 0 additions & 8 deletions runtime/cudaq/qis/managers/BasicExecutionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@ class BasicExecutionManager : public cudaq::ExecutionManager {
if (!executionContext)
return;

if (isInTracerMode()) {
for (auto &q : contextQuditIdsForDeletion)
returnIndex(q.id);

contextQuditIdsForDeletion.clear();
return;
}

// Do any final post-processing before
// we deallocate the qudits
handleExecutionContextEnded();
Expand Down

0 comments on commit f6840d0

Please sign in to comment.