Map a batch transform over multiple tapes.
Consider the following tapes:
H = qml.PauliZ(0) @ qml.PauliZ(1) - qml.PauliX(0) with qml.tape.QuantumTape() as tape1: qml.RX(0.5, wires=0) qml.RY(0.1, wires=1) qml.CNOT(wires=[0, 1]) qml.expval(H) with qml.tape.QuantumTape() as tape2: qml.Hadamard(wires=0) qml.CRX(0.5, wires=[0, 1]) qml.CNOT(wires=[0, 1]) qml.expval(H + 0.5 * qml.PauliY(0))
We can use
map_batch_transformto map a single batch transform across both of the these tapes in such a way that allows us to submit a single job for execution:
>>> tapes, fn = map_batch_transform(qml.transforms.hamiltonian_expand, [tape1, tape2]) >>> dev = qml.device("default.qubit", wires=2) >>> fn(qml.execute(tapes, dev, qml.gradients.param_shift)) [0.9950041652780257, 0.8150893013179248]
- What is PennyLane?
- Quantum circuits
- Gradients and training
- Quantum operators
- Inspecting circuits
- Compiling circuits
- Quantum Chemistry
- Decorators and utility functions
- Transforms for error mitigation