Describe the bug
Valid OpenQASM 3 source is imported, the circuit transpiled, and sent via QiskitRuntimeService.
The job fails with Error code 3211; Job not valid. Qubit(QuantumRegister(3, 'q1'), 0)"
Steps to reproduce
$ cat test.qasm
OPENQASM 3.0;
include "stdgates.inc";
bit[1] c0;
qubit[3] q1;
cx q1[0], q1[1];
cx q1[1], q1[2];
x q1[1];
x q1[2];
c0[0] = measure q1[0];
if (!c0[0]) {
x q1[0];
x q1[2];
}
$ python
>>> from qiskit_ibm_runtime import SamplerV2
>>> from qiskit import transpile
>>> from qiskit_ibm_runtime import QiskitRuntimeService
>>> p = QiskitRuntimeService()
>>> backend = p.least_busy(operational=True, simulator=False)
>>> backend.name
'ibm_sherbrooke'
>>> from qiskit import qasm3
>>> qc = qasm3.load('test.qasm')
>>> qc_t3 = transpile(qc, backend=backend)
>>> sampler=SamplerV2(backend)
>>> job=sampler.run([qc_t3], shots=1000)
>>> print(job.status())
ERROR
>>> print(job.result())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jwoehr/work/Qiskit/qrel_env/lib/python3.10/site-packages/qiskit_ibm_runtime/runtime_job_v2.py", line 138, in result
raise RuntimeJobFailureError(f"Unable to retrieve job result. {error_message}")
qiskit_ibm_runtime.exceptions.RuntimeJobFailureError: "Unable to retrieve job result. Error code 3211; Job not valid. Qubit(QuantumRegister(3, 'q1'), 0)"
>which brings in the circuit, roundtrips it through QPY, through QASM3, then outputs it again to OQ3 and draws it, and that all passes (and on a cursory glance looks correct too), which suggests that Qiskit’s data model is doing the right thing (otherwise I’d expect us to have errored out somewhere or drawn some nonsense). It might be a similar trouble in the valid-circuits check on the backend side, but I wouldn’t know.
**Additional Information**
- **qiskit-ibm-runtime version**: 0.31.0
- **Python version**: 3.10.12
- **Operating system**: Linux PopOS Ubuntu-like
Describe the bug Valid OpenQASM 3 source is imported, the circuit transpiled, and sent via
QiskitRuntimeService
. The job fails withError code 3211; Job not valid. Qubit(QuantumRegister(3, 'q1'), 0)"
Steps to reproduce
This failing job ID was
cw8ja50ggr6g0087p13g
.Expected behavior Job runs to completion
Suggested solutions Jake Lishman posts in Qiskit Slack:
service = QiskitRuntimeService() backend = service.backend("ibm_sherbrooke")
prog = """ OPENQASM 3.0; include "stdgates.inc"; bit[1] c0; qubit[3] q1;
cx q1[0], q1[1]; cx q1[1], q1[2]; x q1[1]; x q1[2]; c0[0] = measure q1[0]; if (!c0[0]) { x q1[0]; x q1[2]; } """ qc = qasm3.loads(prog)
qc_t = transpile(qc, backend, seed_transpiler=0)
print(qasm3.dumps(qc_t))
with io.BytesIO() as fptr: qpy.dump(qc_t, fptr) fptr.seek(0) qc_qpy = qpy.load(fptr)[0] qc_qasm = qasm3.loads(qasm3.dumps(qc_t))
print(qasm3.dumps(qc_qpy)) print(qasm3.dumps(qc_qasm))
print(qc_t.draw(idle_wires=False)) print(qc_qpy.draw(idle_wires=False)) print(qc_qasm.draw(idle_wires=False))