qml.qcut.expand_fragment_tape¶
- expand_fragment_tape(tape)[source]¶
Expands a fragment tape into a sequence of tapes for each configuration of the contained
MeasureNode
andPrepareNode
operations.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 fragment tape containing
MeasureNode
andPrepareNode
operations to be expanded- Returns
the tapes corresponding to each configuration and the order of preparation nodes and measurement nodes used in the expansion
- Return type
Tuple[List[QuantumTape], List[PrepareNode], List[MeasureNode]]
Example
Consider the following circuit, which contains a
MeasureNode
andPrepareNode
operation:ops = [ qml.qcut.PrepareNode(wires=0), qml.RX(0.5, wires=0), qml.qcut.MeasureNode(wires=0), ] tape = qml.tape.QuantumTape(ops)
We can expand over the measurement and preparation nodes using:
>>> tapes, prep, meas = qml.qcut.expand_fragment_tape(tape) >>> for t in tapes: ... print(qml.drawer.tape_text(t, decimals=1)) 0: ──I──RX(0.5)─┤ <I> <Z> 0: ──I──RX(0.5)─┤ <X> 0: ──I──RX(0.5)─┤ <Y> 0: ──X──RX(0.5)─┤ <I> <Z> 0: ──X──RX(0.5)─┤ <X> 0: ──X──RX(0.5)─┤ <Y> 0: ──H──RX(0.5)─┤ <I> <Z> 0: ──H──RX(0.5)─┤ <X> 0: ──H──RX(0.5)─┤ <Y> 0: ──H──S──RX(0.5)─┤ <I> <Z> 0: ──H──S──RX(0.5)─┤ <X> 0: ──H──S──RX(0.5)─┤ <Y>