# qml.transforms.make_tape¶

make_tape(fn)[source]

Returns a function that generates the tape from a quantum function without any operation queuing taking place.

This is useful when you would like to manipulate or transform the tape created by a quantum function without evaluating it.

Parameters

fn (function) – the quantum function to generate the tape from

Returns

The returned function takes the same arguments as the quantum function. When called, it returns the generated quantum tape without any queueing occuring.

Return type

function

Example

Consider the following quantum function:

def qfunc(x):
qml.CNOT(wires=[0, 1])
qml.RX(x, wires=0)


We can use make_tape to extract the tape generated by this quantum function, without any of the operations being queued by any existing queuing contexts:

>>> with qml.tape.QuantumTape() as active_tape:
...     qml.RY(1.0, wires=0)
...     tape = make_tape(qfunc)(0.5)
>>> tape.operations

>>> active_tape.operations