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