Qiskit / qiskit-ibm-runtime

IBM Client for Qiskit Runtime
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime
Apache License 2.0
140 stars 149 forks source link

`backend.num_qubits` is incorrect (or broken) for simulation backends #1484

Open richrines1 opened 4 months ago

richrines1 commented 4 months ago

Describe the bug

Steps to reproduce

service = qiskit_ibm_runtime.QiskitRuntimeService()

def test_backend(backend_name, num_qubits):
    backend = service.backend(backend_name)
    print(f"{backend_name} (backend has {backend.num_qubits} qubits):")

    circuit = qiskit.QuantumCircuit(num_qubits, 1)
    circuit.measure(0, 0)

    job = qiskit_ibm_runtime.Sampler(backend).run(circuit, shots=1)
    job.wait_for_final_state()

    print(f"{circuit.num_qubits}-qubit circuit: {job.status()}\n")

test_backend("ibmq_qasm_simulator", 31)
test_backend("ibmq_qasm_simulator", 32)

test_backend("simulator_statevector", 31)
test_backend("simulator_statevector", 32)

test_backend("simulator_mps", 63)
test_backend("simulator_mps", 64)

prints:

ibmq_qasm_simulator (backend has 32 qubits):
31-qubit circuit: JobStatus.DONE

ibmq_qasm_simulator (backend has 32 qubits):
32-qubit circuit: JobStatus.ERROR

simulator_statevector (backend has 32 qubits):
31-qubit circuit: JobStatus.DONE

simulator_statevector (backend has 32 qubits):
32-qubit circuit: JobStatus.ERROR

simulator_mps (backend has 100 qubits):
63-qubit circuit: JobStatus.DONE

simulator_mps (backend has 100 qubits):
64-qubit circuit: JobStatus.ERROR

(where for each failing job, job.error_message() returns "...Circuits do not match the target definition (non-ISA circuits)...")

meanwhile the following two lines fail immediately with a TranspilerError:

service.backend("simulator_stabilizer").num_qubits  # TranspilerError: "The number of qubits for Instruction(name='cx', num_qubits=2, num_clbits=0, params=[]) does not match the number of qubits in the properties dictionary: (0,)"
service.backend("simulator_extended_stabilizer").num_qubits  # TranspilerError: "The number of qubits for Instruction(name='cx', num_qubits=2, num_clbits=0, params=[]) does not match the number of qubits in the properties dictionary: (0,)"

Expected behavior

i would expect to be able to submit a circuit with (op to) backend.num_qubits qubits

Additional Information

alejomonbar commented 1 month ago

@richrines1 did you find a solution to this bug?

ElePT commented 1 month ago

I think it's relevant to note that cloud simulators have been retired as of May 15th, you can refer to this migration guide to see why have cloud simulators been retired as well as how to migrate to local simulators.

jyu00 commented 1 month ago

Closing this issue since as @ElePT mentioned, cloud simulators have been retired.

richrines1 commented 1 month ago

thanks @ElePT @jyu00

cloud simulators seem to still be available via the ibm cloud qiskit runtime plans, for which this bug persists - are these similarly headed for retirement?

jyu00 commented 1 month ago

You are correct that simulators are still available via the lite plan in the IBM Cloud channel.

vtomole commented 1 month ago

Hi @jyu00 ,

Will the IBM cloud simulators always be available?

vtomole commented 1 month ago

Ping @jyu00. This message might have slipped by you.

jyu00 commented 1 month ago

@vtomole I'm not in a position to make an official statement. However, given cloud simulator support was dropped from IBM Quantum Platform due to their limitations, I would not be surprised if it's also dropped from IBM Cloud channel in the near future.

vtomole commented 1 month ago

Thanks @jyu00 :)