Returns a function that generates a qscript from a quantum function without any operation queuing taking place.
This is useful when you would like to manipulate or transform the qscript created by a quantum function without evaluating it.
fn (function) – the quantum function to generate the qscript from
The returned function takes the same arguments as the quantum function. When called, it returns the generated quantum script 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_qscriptto extract the qscript generated by this quantum function, without any of the operations being queued by any existing queuing contexts:
>>> with qml.queuing.AnnotatedQueue() as active_queue: ... _ = qml.RY(1.0, wires=0) ... qs = make_qscript(qfunc)(0.5) >>> qs.operations [Hadamard(wires=), CNOT(wires=[0, 1]), RX(0.5, wires=)]
Note that the currently recording queue did not queue any of these quantum operations:
>>> active_queue.queue [RY(1.0, wires=)]
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry
- Quantum Datasets
- QNode returns