remap_tape_wires(tape: pennylane.tape.tape.QuantumTape, wires: Sequence) → pennylane.tape.tape.QuantumTape¶
Map the wires of a tape to a new set of wires.
Given an \(n\)-wire
tape, this function returns a new
QuantumTapewith operations and measurements acting on the first \(n\) wires provided in the
wiresargument. The input
tapeis left unmodified.
This function is designed for use as part of the circuit cutting workflow. Check out the
qml.cut_circuit()transform for more details.
tape (QuantumTape) – the quantum tape whose wires should be remapped
wires (Sequence) – the new set of wires to map to
A remapped copy of the input tape
- Return type
ValueError – if the number of wires in
Consider the following circuit that operates on wires
with qml.tape.QuantumTape() as tape: qml.RX(0.5, wires=2) qml.RY(0.6, wires=3) qml.CNOT(wires=[2, 3]) qml.expval(qml.PauliZ(2) @ qml.PauliZ(3))
We can map from wires
>>> new_wires = [0, 1] >>> new_tape = qml.transforms.qcut.remap_tape_wires(tape, new_wires) >>> print(qml.drawer.tape_text(new_tape)) 0: ──RX(0.5)──╭●──╭┤ ⟨Z ⊗ Z⟩ 1: ──RY(0.6)──╰X──╰┤ ⟨Z ⊗ Z⟩
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry