qml.from_qasm¶
-
from_qasm
(quantum_circuit)[source]¶ Loads quantum circuits from a QASM string using the converter in the PennyLane-Qiskit plugin.
Example:
>>> hadamard_qasm = 'OPENQASM 2.0;' \ ... 'include "qelib1.inc";' \ ... 'qreg q[1];' \ ... 'h q[0];' >>> my_circuit = qml.from_qasm(hadamard_qasm)
The
my_circuit
template can now be used within QNodes, as a two-wire quantum template.>>> @qml.qnode(dev) >>> def circuit(x): >>> qml.RX(x, wires=1) >>> my_circuit(wires=(1, 0)) >>> return qml.expval(qml.PauliZ(0))
- Parameters
quantum_circuit (str) – a QASM string containing a valid quantum circuit
- Returns
the PennyLane template created based on the QASM string
- Return type
function
code/api/pennylane.from_qasm
Download Python script
Download Notebook
View on GitHub