qml.transforms.qcut.remap_tape_wires

remap_tape_wires(tape: pennylane.tape.tape.QuantumTape, wires: Sequence)pennylane.tape.tape.QuantumTape[source]

Map the wires of a tape to a new set of wires.

Given an \(n\)-wire tape, this function returns a new QuantumTape with operations and measurements acting on the first \(n\) wires provided in the wires argument. The input tape is left unmodified.

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
  • tape (QuantumTape) – the quantum tape whose wires should be remapped

  • wires (Sequence) – the new set of wires to map to

Returns

A remapped copy of the input tape

Return type

QuantumTape

Raises

ValueError – if the number of wires in tape exceeds len(wires)

Example

Consider the following circuit that operates on wires [2, 3]:

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 [2, 3] to [0, 1] using:

>>> 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⟩