Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError when getting results via IonQ Backend if not measuring all qubits #227

Open
guenp opened this issue Jan 30, 2022 · 0 comments
Labels
azure-quantum bug Something isn't working help wanted Extra attention is needed python Pull requests that update Python code qiskit A Qiskit issue

Comments

@guenp
Copy link
Contributor

guenp commented Jan 30, 2022

Sharing on behalf of @amirebrahimi:

I'm getting an error when calling job.result() from ionq.simulator. Details in thread.

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
/tmp/ipykernel_15433/1564545644.py in <module>
      1 # print(result)
----> 2 print(job.result())

/usr/local/lib/python3.7/site-packages/azure/quantum/qiskit/job.py in result(self, timeout)
     75 
     76         success = self._azure_job.details.status == "Succeeded"
---> 77         results = self._format_results()
     78 
     79         return Result.from_dict(

/usr/local/lib/python3.7/site-packages/azure/quantum/qiskit/job.py in _format_results(self)
    118 
    119             elif (self._azure_job.details.output_data_format == IONQ_OUTPUT_DATA_FORMAT):
--> 120                 job_result["data"] = self._format_ionq_results()
    121                 job_result["header"] = self._azure_job.details.metadata
    122 

/usr/local/lib/python3.7/site-packages/azure/quantum/qiskit/job.py in _format_ionq_results(self)
    140         if "meas_map" not in self._azure_job.details.metadata or "num_qubits" not in self._azure_job.details.metadata:
    141             raise ValueError(f"Job with ID {self.id()} does not have the required metadata to format IonQ results.")
--> 142         meas_map = json.loads(self._azure_job.details.metadata.get("meas_map"))
    143         num_qubits = self._azure_job.details.metadata.get("num_qubits")
    144 

/usr/local/lib/python3.7/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    346             parse_int is None and parse_float is None and
    347             parse_constant is None and object_pairs_hook is None and not kw):
--> 348         return _default_decoder.decode(s)
    349     if cls is None:
    350         cls = JSONDecoder

/usr/local/lib/python3.7/json/decoder.py in decode(self, s, _w)
    335 
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()
    339         if end != len(s):

/usr/local/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 14 (char 13)

A temporary fix: measure all your qubits
The problem is that meas_map may have None for any qubits you don't measure. which is breaking the parsing

@guenp guenp added bug Something isn't working help wanted Extra attention is needed azure-quantum qiskit A Qiskit issue python Pull requests that update Python code labels Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-quantum bug Something isn't working help wanted Extra attention is needed python Pull requests that update Python code qiskit A Qiskit issue
Projects
None yet
Development

No branches or pull requests

3 participants