You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jobs run on the IonQ "ideal" simulator provide deterministic results, so for these jobs, the IonQ API returns results as histogram probabilities instead of measurement counts. However, currently, there is no way to pass just raw probability data to GateModelResultData (#785). To patch this, we've added an arbitrary default shots value to IonQ.submit:
For sequential job submission and results retrieval this works fine:
fromqbraid.runtimeimportIonQJob, IonQProviderprovider=IonQProvider(api_key="...")
device=provider.get_device("simulator")
program="""OPENQASM 2.0;qreg q[2];h q[0];cx q[0],q[1];cx q[1],q[0];"""job=device.run(program)
# Getting the result directly from the job object created from device.run# works fine because we carry over arbitrary placeholder value for shotsprint(job._cache_metadata.get("shots")) # 100result=job.result()
However, this arbitrary shots value is not used by the IonQ "ideal" simulator, and therefore is not stored anywhere other than locally within that initial IonQJob instance. So if you then create a new job instance from the job ID, the result() method fails with a ValueError because there is no stored value for "shots."
job=IonQJob(job.id, session=provider.session)
print(job._cache_metadata.get("shots")) # Noneresult=job.result()
# File ~/.../qBraid/qbraid/runtime/ionq/job.py:86, in IonQJob._get_counts(result)# 84 probs_dec_str: Optional[dict[str, float]] = result.get("probabilities")# 85 if shots is None or probs_dec_str is None:# ---> 86 raise ValueError("Missing shots or probabilities in result data.")# 87 probs_dec = {int(key): value for key, value in probs_dec_str.items()}# 88 probs_normal = normalize_counts(probs_dec)# ValueError: Missing shots or probabilities in result data.
Remove placeholder (default) shots value from IonQDevice.submit()
Revise IonQJob.result() to pass probability data directly to GateModelResultData, and only construct measurement counts data from probabilities if shots > 0.
The text was updated successfully, but these errors were encountered:
Jobs run on the IonQ "ideal" simulator provide deterministic results, so for these jobs, the IonQ API returns results as histogram probabilities instead of measurement counts. However, currently, there is no way to pass just raw probability data to
GateModelResultData
(#785). To patch this, we've added an arbitrary default shots value toIonQ.submit
:qBraid/qbraid/runtime/ionq/device.py
Line 75 in 03aa38b
so that the
IonQJob.result()
method can construct measurement counts data based on the returned probabilities together with that shots value:qBraid/qbraid/runtime/ionq/job.py
Lines 102 to 108 in 03aa38b
For sequential job submission and results retrieval this works fine:
However, this arbitrary shots value is not used by the IonQ "ideal" simulator, and therefore is not stored anywhere other than locally within that initial
IonQJob
instance. So if you then create a new job instance from the job ID, theresult()
method fails with aValueError
because there is no stored value for "shots."TODO
GateModelResultData
to support direct probability data #785IonQDevice.submit()
IonQJob.result()
to pass probability data directly toGateModelResultData
, and only construct measurement counts data from probabilities if shots > 0.The text was updated successfully, but these errors were encountered: