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.
fn (function) – the quantum function to generate the tape from
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
Consider the following quantum function:
def qfunc(x): qml.Hadamard(wires=0) qml.CNOT(wires=[0, 1]) qml.RX(x, wires=0)
We can use
make_tapeto 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 [Hadamard(wires=), CNOT(wires=[0, 1]), RX(0.5, wires=)]
Note that the currently recording tape did not queue any of these quantum operations:
>>> active_tape.operations [RY(1.0, wires=)]
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry
- Decorators and utility functions