qml.transforms.qcut.replace_wire_cut_nodes¶
-
replace_wire_cut_nodes
(graph)[source]¶ Replace each
WireCut
node in the graph with aMeasureNode
andPrepareNode
.Note
This function is designed for use as part of the circuit cutting workflow. Check out the
qml.cut_circuit()
transform for more details.- Parameters
graph (nx.MultiDiGraph) – The graph containing the
WireCut
nodes to be replaced
Example
Consider the following circuit with manually-placed wire cuts:
wire_cut_0 = qml.WireCut(wires=0) wire_cut_1 = qml.WireCut(wires=1) multi_wire_cut = qml.WireCut(wires=[0, 1]) with qml.tape.QuantumTape() as tape: qml.RX(0.4, wires=0) qml.apply(wire_cut_0) qml.RY(0.5, wires=0) qml.apply(wire_cut_1) qml.CNOT(wires=[0, 1]) qml.apply(multi_wire_cut) qml.RZ(0.6, wires=1) qml.expval(qml.PauliZ(0))
We can find the circuit graph and remove all the wire cut nodes using:
>>> graph = qml.transforms.qcut.tape_to_graph(tape) >>> qml.transforms.qcut.replace_wire_cut_nodes(graph)
code/api/pennylane.transforms.qcut.replace_wire_cut_nodes
Download Python script
Download Notebook
View on GitHub