3

I'm running a circuit on ionq device using qiskit_braket_provider. I want to extract per shot measurement results. While running on IBMQ backends, it can be accessed by setting memory=True in execute function and then running job.result().get_memory(qc). I'm trying to similar thing for ionq device, but getting the following error.

Code:

job = ionq.run(tqc,shots=1024,memory=True)
job.status()
job.wait_for_final_state()
result = job.result()
m = job.result().get_memory(tqc)
print(m)

Error:

---------------------------------------------------------------------------
QiskitError                               Traceback (most recent call last)
Input In [70], in <cell line: 1>()
----> 1 m = job.result().get_memory(tqc)
      2 m

File ~/anaconda3/envs/qlab/lib/python3.10/site-packages/qiskit/result/result.py:217, in Result.get_memory(self, experiment) 191 def get_memory(self, experiment=None): 192 """Get the sequence of memory states (readouts) for each shot 193 The data from the experiment is a list of format 194 ['00000', '01000', '10100', '10100', '11101', '11100', '00101', ..., '01010'] (...) 215 QiskitError: if there is no memory data for the circuit. 216 """ --> 217 exp_result = self._get_experiment(experiment) 218 try: 219 try: # header is not available

File ~/anaconda3/envs/qlab/lib/python3.10/site-packages/qiskit/result/result.py:380, in Result._get_experiment(self, key) 373 exp = [ 374 result 375 for result in self.results 376 if getattr(getattr(result, "header", None), "name", "") == key 377 ] 379 if len(exp) == 0: --> 380 raise QiskitError('Data for experiment "%s" could not be found.' % key) 381 if len(exp) == 1: 382 exp = exp[0]

QiskitError: 'Data for experiment "circuit-7034" could not be found.'

One more thing, how to extract execution time for job on ionq device? In IBMQ simply job.result().time_taken returns it.

Cody Wang
  • 1,303
  • 8
  • 13
Devesh
  • 63
  • 6

1 Answers1

2

From what I can tell, this information isn't available from the provider because the header parameter isn't supplied to the ExperimentResult constructor. This might be worth submitting an issue or PR for!

In the meantime, you can get per-shot results by getting the Amazon Braket task result directly:

from braket.aws import AwsQuantumTask
task = AwsQuantumTask(job.job_id())
measurements = task.result().measurements
Cody Wang
  • 1,303
  • 8
  • 13