Basic circuit execution

This notebooks illustrates how you can run your qiskit code on the Quantum Inspire 2 platform.

This notebook makes the following assumptions:

  • quantuminspire2 sdk installed

  • account exists in the QI2 platform

  • Pennylane plugin installed in the same environment as this notebook

# Be sure to have logged in to the QI2 platform via the SDK. If you have installed it in the same environment as
# this notebook, you may run this cell.

!qi login "https://staging.qi2.quantum-inspire.com"

The necessary imports

import pennylane as qml

from pennylane_quantuminspire2.qi_device import QI2Device

What QI Backends are available?

# Show all current supported backends:
print(QI2Device.backends())

Choose your backend

We will choose the QX emulator

# Get Quantum Inspire's simulator backend:
emulator_backend = QI2Device.get_backend("QX emulator")

# Instantiate a Pennylane device based on chosen backend
demo_device = QI2Device(emulator_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)