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

Fixes for 0.31 release #835

Merged
merged 8 commits into from
Jun 23, 2023
Merged
Changes from 1 commit
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
31 changes: 16 additions & 15 deletions demonstrations/tutorial_quantum_circuit_cutting.py
mudit2812 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -658,28 +658,29 @@ def make_kraus_ops(num_wires: int):
# In code, this looks like:
#

with QuantumTape(do_queue=False) as tape0, QuantumTape(do_queue=False) as tape1:
# Record on new "fragment" tapes
with qml.queuing.QueuingManager.stop_recording():
mudit2812 marked this conversation as resolved.
Show resolved Hide resolved
with QuantumTape() as tape0, QuantumTape() as tape1:
# Record on new "fragment" tapes

for op in tape:
for op in tape:

if isinstance(op, qml.WireCut): # If the operation is a wire cut, replace it
if isinstance(op, qml.WireCut): # If the operation is a wire cut, replace it

k = len(op.wires)
d = 2**k
k = len(op.wires)
d = 2**k

K0, K1 = make_kraus_ops(k) # Generate Kraus operators on the fly
probs = (d + 1) / (2 * d + 1), d / (2 * d + 1) # Probabilities of the two channels
K0, K1 = make_kraus_ops(k) # Generate Kraus operators on the fly
probs = (d + 1) / (2 * d + 1), d / (2 * d + 1) # Probabilities of the two channels

psi_0 = qml.QubitChannel(K0, wires=op.wires, do_queue=False)
psi_1 = qml.QubitChannel(K1, wires=op.wires, do_queue=False)
psi_0 = qml.QubitChannel(K0, wires=op.wires)
psi_1 = qml.QubitChannel(K1, wires=op.wires)

qml.apply(psi_0, context=tape0)
qml.apply(psi_1, context=tape1)
qml.apply(psi_0, context=tape0)
qml.apply(psi_1, context=tape1)

else: # Otherwise, just apply the existing gate
qml.apply(op, context=tape0)
qml.apply(op, context=tape1)
else: # Otherwise, just apply the existing gate
qml.apply(op, context=tape0)
qml.apply(op, context=tape1)


######################################################################
Expand Down