QuTech-Delft / quantuminspire

Quantum Inspire SDK
Apache License 2.0
64 stars 27 forks source link

Execution of quantum circuits fails with 1 shot #155

Closed eendebakpt closed 1 year ago

eendebakpt commented 1 year ago

Describe the bug

When running a circuit with a single shot an error is generated. Update: fix typo in circuit

To Reproduce A minimal example:

from quantuminspire.api import QuantumInspireAPI
from quantuminspire.credentials import get_token_authentication, load_account
from quantuminspire.qiskit import QI
from qiskit import QuantumCircuit

authentication = get_token_authentication(load_account())

backend_name= "QX single-node simulator"
QI.set_authentication(authentication)
backend = QI.get_backend(backend_name)
number_of_shots = 4 * 2048
backend.options.shots = number_of_shots  

qc=QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0,0)

backend.run(qc, shots=1).result()

Error generated: CircuitError: 'Index 0 out of range for size 0.'

QFer commented 1 year ago

This is not a bug in SDK but a Circuit Error as the error message is saying.

The QuantumCircuit that is defined with QuantumCircuit(1) has 1 qubit registers and no classical bit registers. This means that the measurement is generating the error because there is no classical register for the result.

To fix the error in this example, QuantumCircuit should be defined as: QuantumCircuit(1, 1).

eendebakpt commented 1 year ago

This is not a bug in SDK but a Circuit Error as the error message is saying.

The QuantumCircuit that is defined with QuantumCircuit(1) has 1 qubit registers and no classical bit registers. This means that the measurement is generating the error because there is no classical register for the result.

To fix the error in this example, QuantumCircuit should be defined as: QuantumCircuit(1, 1).

Sorry, that was a typo in the script. Also with QuantumCircuit(1, 1) I get an error

eendebakpt commented 1 year ago

Resolved by upgrading the quantuminspire package to the latest version on pypi.