I'd like to retrieve from IonQ QPU provided by Azure the per-shot measurements. Azure recommends the results are retrieved via Qiskit. The standard Qiskit command for that is: shots_mem_list=job.result().get_memory(0) which will deliver a list of bit-strings: ['101011', '101111', '000100', '111100',...]

But to make it work the job needs to be submitted to the backend with 2 additional flags: meas_level=2 and memory=True.

 backend.run(circ, count=100, meas_level=2, memory=True) 

However, Azure is ignoring meas_level flag:

meas_level is not a known attribute of class <class 'azure.quantum._client.models._models_py3.JobDetails'> and will be ignored

As a consequence Qiskit result.get_memory(0) command produces an error:

qiskit.exceptions.QiskitError: 'No memory for experiment "0". Please verify that you either ran a measurement level 2 job with the memory flag set, eg., "memory=True", or a measurement level 0/1 job.'

Is it possible to invoke azure.quantum.backend with meas_level=2 argument to be passed to the backend?


1 Answer 1


No, Azure Quantum doesn't support setting memory=True on a backend yet. See: https://github.com/microsoft/qdk-python/issues/225

The only workaround is to simulate the individual results by populating the memory on the client using the same probability distribution as the results from the job, something like:

result = backend.run(circuit, count=100).result()
memory = random.choices(list(result.keys()), weights=result.values(), k=100)

the values will be statiscally equivalent, but they are of course not the actual measurements that you got from the device.

  • $\begingroup$ I'm measuring on the real device and it is costly. The reason I want to activate this option is I want to re-analyze the measurements instead of submitting new jobs with smaller number of shots. Since 1+1/2+1/4+...=2 - it would save me 1/2 of the total cost. Would be great (for users) if Azure were to support memory=True. $\endgroup$ Dec 3, 2022 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.