Basic circuit execution¶
This notebooks illustrates how you can run your qiskit code on the Quantum Inspire platform.
This notebook makes the following assumptions:¶
QI tool installed
account exists in the Quantum Inspire platform
Pennylane plugin installed in the same environment as this notebook
# Be sure to have logged in to the Quantum Inspire platform via the QI tool. If you have installed it in the same
# environment as this notebook, you may run this cell.
!qi login
The necessary imports¶
import pennylane as qml
from qiskit_quantuminspire.qi_provider import QIProvider
from pennylane_quantuminspire.qi_device import QIDevice
What QI Backends are available?¶
# Show all current supported backends:
provider = QIProvider()
print(provider.backends())
Choose your backend¶
We will choose the QX emulator
# Get Quantum Inspire's simulator backend:
backend = provider.get_backend("QX emulator")
# Instantiate a Pennylane device based on chosen backend
demo_device = QIDevice(backend)
Create your Circuit¶
Let’s create a bell state circuit.
@qml.qnode(demo_device)
def bell_state():
qml.Hadamard(wires=0)
qml.CNOT(wires=[0, 1])
return [qml.expval(qml.Z(x)) for x in range(2)]
Run the job and get results¶
Let’s run the circuit! Be aware that if your circuit contains gates that are not supported by the target, compilation errors may arise.
# Execute the circuit
result = bell_state()
print(result)