IBM Q Experience

PennyLane-Qiskit supports running PennyLane on IBM Q hardware via the qistkit.ibmq device. You can choose between different backends - either simulators tailor-made to emulate the real hardware, or the real hardware itself.

Accounts and Tokens

By default, the qiskit.ibmq device will attempt to use an already active or stored IBM Q account. If the device finds no account it will raise an error:

'No active IBM Q account, and no IBM Q token provided.

You can use the qiskit_ibm_provider.IBMProvider.save_account("<my_token>") function to permanently store an account, and the account will be automatically used from then onward. Alternatively, you can specify the token with PennyLane via the PennyLane configuration file by adding the section

[qiskit.global]

  [qiskit.ibmq]
  ibmqx_token = "XXX"

You may also directly pass your IBM Q API token to the device:

dev = qml.device('qiskit.ibmq', wires=2, backend='ibmq_qasm_simulator', ibmqx_token="XXX")

You may also save your token as an environment variable by running the following in a terminal:

export IBMQX_TOKEN=<my_token>

Warning

Never publish code containing your token online.

Backends

By default, the qiskit.ibmq device uses the simulator backend ibmq_qasm_simulator, but this may be changed to any of the real backends as returned by

dev.capabilities()['backend']

Most of the backends of the qiskit.ibmq device, such as ibmq_london or ibmq_16_melbourne, are hardware backends. Running PennyLane with these backends means to send the circuit as a job to the actual quantum computer and retrieve the results via the cloud.

Specifying providers

Custom providers can be passed as arguments when a qiskit.ibmq device is created:

from qiskit_ibm_provider import IBMProvider
provider = IBMProvider("XYZ")

import pennylane as qml
dev = qml.device('qiskit.ibmq', wires=2, backend='ibmq_qasm_simulator', provider=provider)

If no provider is passed explicitly, then the official provider options are used, hub='ibm-q', group='open' and project='main'.

Custom provider options can also be passed as keyword arguments when creating a device:

import pennylane as qml
dev = qml.device('qiskit.ibmq', wires=2, backend='ibmq_qasm_simulator',
                 ibmqx_token='XXX', hub='MYHUB', group='MYGROUP', project='MYPROJECT')

More details on Qiskit providers can be found in the IBMQ provider documentation.