Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where qubits are retained with draw / tracer #1457

Merged
merged 3 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading