The Simulator device¶
You can instantiate the qulacs device in PennyLane as follows:
import pennylane as qml
dev = qml.device('qulacs.simulator', wires=2)
This device can then be used just like other devices for the definition and evaluation of QNodes within PennyLane. A simple quantum function that returns the expectation value of a measurement and depends on three classical input parameters would look like:
@qml.qnode(dev)
def circuit(x, y, z):
qml.RZ(z, wires=[0])
qml.RY(y, wires=[0])
qml.RX(x, wires=[0])
qml.CNOT(wires=[0, 1])
return qml.expval(qml.PauliZ(wires=1))
You can then execute the circuit like any other function to get the quantum mechanical expectation value.
circuit(0.2, 0.1, 0.3)
Device options¶
To run the qulacs device simulations on a GPU, set the custom qpu
argument to True
when creating the device.
dev = qml.device('qulacs.simulator', wires=2, gpu=True)
Note
For GPU support, you need to have the qulacs-gpu
version installed, including its dependencies. Check the
Qulacs documentation for details.
If you create the device with gpu=True
but you do not have qulacs-gpu
installed you will get an error
GPU not supported with installed version of Qulacs.
.
Supported operations¶
The qulacs.simulator
device supports all PennyLane
operations and observables: