Open yaelbh opened 1 month ago
It happens on real backends as well. Switching the backend to ibm_sherbrooke
threw me 'The instruction ecr on qubits (0, 1) is not supported by the target system.
Example:
from qiskit import QuantumCircuit, transpile
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
from qiskit_ibm_runtime.fake_provider import FakeCairoV2
service = QiskitRuntimeService()
backend = service.backend("ibm_sherbrooke")
sampler = SamplerV2(mode=backend)
circ = QuantumCircuit(5, 1)
circ.x(0)
circ.measure(0, 0)
with circ.if_test((0, 1)):
circ.cx(1, 2)
trans_qc = transpile(circ, backend=backend, optimization_level=1)
res = sampler.run([trans_qc]).result()
Consider replacing the entire ISA check implementation with qiskit's transpiler pass: https://github.com/Qiskit/qiskit/issues/12916#issuecomment-2275729419.
Inside the control flow operation, when the ISA check checks cx(1, 2)
, it wrongly checks cx(0, 1)
, because of a bug. Since (0, 1)
is not connected in Sherbrooke (only (1, 0)
is connected - the other direction), the ISA check fails, in spite of (1, 2)
being connected and valid.
This bug occurs also on the other way around: in Cusco, (0, 1)
is connected but (1, 2)
is not connected. Because of the bug, cx(1, 2)
wrongly passes the ISA check, and the failure is deferred must later down the stack:
from qiskit import QuantumCircuit
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
service = QiskitRuntimeService()
backend = service.backend("ibm_cusco")
sampler = SamplerV2(mode=backend)
circ = QuantumCircuit(5, 1)
circ.x(0)
circ.measure(0, 0)
with circ.if_test((0, 1)):
circ.ecr(1, 2)
job = sampler.run([circ])
print(job.job_id())
res = job.result()
print(res)
Output:
raise RuntimeJobFailureError(f"Unable to retrieve job result. {error_message}")
qiskit_ibm_runtime.exceptions.RuntimeJobFailureError: 'Unable to retrieve job result. Error code 6103; Internal OpenQASM3 compilation error'
Describe the bug
Recently, in #1784, we added ISA checks inside bodies of control flow operations. @ashsaki found an example similar to the one below, where a valid circuit is labeled as invalid by this new ISA check.
Steps to reproduce
Output is:
Expected behavior
Well, don't crash and let the circuit pass the ISA test.
Suggested solutions
Well, debug and fix :smile:.
Additional Information