qiskit-ibm-runtime icon indicating copy to clipboard operation
qiskit-ibm-runtime copied to clipboard

resilience_level = 2 gives VALUEERROR: INVALID LITERAL FOR INT() WITH BASE 2: '0 0'

Open kevinsung opened this issue 2 years ago • 2 comments

Describe the bug

Steps to reproduce

from qiskit import QuantumCircuit, QuantumRegister, transpile
from qiskit.providers.fake_provider import FakeLagos
from qiskit.quantum_info import SparsePauliOp
from qiskit_ibm_runtime import Estimator, Options, Session, QiskitRuntimeService
from qiskit_aer.noise import NoiseModel, ReadoutError

hub = "ibm-q-internal"
group = "deployed"
project = "default"
service = QiskitRuntimeService(instance=f"{hub}/{group}/{project}")

backend = service.get_backend("simulator_statevector")
fake_backend = FakeLagos()

options = Options()
options.simulator = {
    "noise_model": NoiseModel.from_backend(fake_backend),
    "basis_gates": fake_backend.configuration().basis_gates,
    "coupling_map": fake_backend.configuration().coupling_map,
}

hamiltonian = SparsePauliOp("X")
qubits = QuantumRegister(1)
circuit = QuantumCircuit(qubits)
circuit.measure_all()

options.resilience_level = 2
with Session(service=service, backend=backend):
    estimator = Estimator(options=options)
    job = estimator.run(circuit, hamiltonian, shots=10000)

result = job.result()
result
---------------------------------------------------------------------------
RuntimeJobFailureError                    Traceback (most recent call last)
Cell In[3], line 32
     29     estimator = Estimator(options=options)
     30     job = estimator.run(circuit, hamiltonian, shots=10000)
---> 32 result = job.result()
     33 result

File /usr/local/venvs/qiskit-terra-D4GIWOF4/lib/python3.10/site-packages/qiskit_ibm_runtime/runtime_job.py:227, in RuntimeJob.result(self, timeout, decoder)
    225     if self._reason == "RAN TOO LONG":
    226         raise RuntimeJobMaxTimeoutError(error_message)
--> 227     raise RuntimeJobFailureError(
    228         f"Unable to retrieve job result. " f"{error_message}"
    229     )
    231 result_raw = self._download_external_result(
    232     self._api_client.job_results(job_id=self.job_id())
    233 )
    235 self._results = _decoder.decode(result_raw) if result_raw else None

RuntimeJobFailureError: "Unable to retrieve job result. VALUEERROR: INVALID LITERAL FOR INT() WITH BASE 2: '0 0'"

Expected behavior should work

Suggested solutions

Additional Information

  • qiskit-ibm-runtime version: 0.10.0
  • Python version: 3.10.11
  • Operating system: Arch Linux

kevinsung avatar May 22 '23 20:05 kevinsung

You need to remove the measurements

nonhermitian avatar May 22 '23 21:05 nonhermitian

Thanks, that worked. I still think this is an issue though, because the code I gave works with resilience_level set to 0 or 1. Apparently, in those cases the measurements are ignored. The behavior should be consistent.

kevinsung avatar May 22 '23 21:05 kevinsung

I think we raise an error if there is measurement in an estimator job now, but someone should verify.

jyu00 avatar May 22 '24 17:05 jyu00

Confirmed this is no longer an issue

kt474 avatar May 22 '24 18:05 kt474