Skip to content

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

Open
@guenp

Description

@guenp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    azure-quantumbugSomething isn't workinghelp wantedExtra attention is neededpythonPull requests that update Python codeqiskitA Qiskit issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions