qml.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]) ops = [ qml.RX(0.4, wires=0), wire_cut_0, qml.RY(0.5, wires=0), wire_cut_1, qml.CNOT(wires=[0, 1]), multi_wire_cut, qml.RZ(0.6, wires=1), ] measurements = [qml.expval(qml.Z(0))] tape = qml.tape.QuantumTape(ops, measurements)
We can find the circuit graph and remove all the wire cut nodes using:
>>> graph = qml.qcut.tape_to_graph(tape) >>> qml.qcut.replace_wire_cut_nodes(graph)
code/api/pennylane.qcut.replace_wire_cut_nodes
Download Python script
Download Notebook
View on GitHub