4
$\begingroup$

I've already generated a filter for readout error mitigation:

cal_results = cal_job.result()
meas_fitter = CompleteMeasFitter(cal_results, state_labels)  
fig, ax = plt.subplots(figsize=(10, 10))
meas_fitter.plot_calibration(ax)
meas_filter = meas_fitter.filter

enter image description here

I have a set of circuits executed using the IBM job manager, the list is called all_circuits. After transpling the list, I tried:

MExperiments = job_manager.run(all_circuits, backend=backend, shots = nshots)
results = MExperiments.results() 
**mitigated_results = meas_filter.apply(results)**

I'm hoping to use the filter to mitigate the errors for each circuit in the list, but the last line doesn't quite work. It shows me

QiskitError: 'Unrecognized type for raw_data.'

How can I fix this issue? Thanks:)

$\rule{4cm}{0.4pt}$

PS: From the tutorial, there're 4 types of raw data that match the requirement:

Form1: A counts dictionary from results.get_counts,

Form2: A list of counts of length=len(state_labels),

Form3: A list of counts of length=M*len(state_labels) where M is an integer (e.g. for use with the tomography data),

Form4: A qiskit Result.

I'm not pretty sure why the results in my code doesn't fit any one of them.

$\endgroup$
5
  • $\begingroup$ You can use type(results) to find out why results doesn't fit any of the four allowed types. This may also give you ideas about how to convert the value to whatever apply expects. $\endgroup$ Feb 7 at 21:31
  • $\begingroup$ @Adam Zalcman Thank you for the comment! I tried that command and it shows me the type is 'qiskit.providers.ibmq.managed.managedresults.ManagedResults' It looks like the parameters for apply should be a dictionary or list. I'm not pretty sure how I can convert the results $\endgroup$
    – ZR-
    Feb 7 at 21:57
  • $\begingroup$ @Adam Zalcman I just solved the issue. Thanks!! $\endgroup$
    – ZR-
    Feb 8 at 0:03
  • 1
    $\begingroup$ Cool! Consider answering your own question. It might help someone in future. $\endgroup$ Feb 8 at 0:04
  • 1
    $\begingroup$ @Adam Zalcman Sounds good! I'll do that:) $\endgroup$
    – ZR-
    Feb 8 at 0:05
3
$\begingroup$

As mentioned above, there're 4 types of data that match the requirement. The results in this case obtained from the job manager is not the same as the results shown in the tutorial since it contains a set of results from different quantum circuits. (I'm still confused why this is not considered as a qiskit result, i.e Form 4 above.)

As I tried to print the type, it shows meqiskit.providers.ibmq.managed.managedresults.ManagedResults . Then I searched more information from here. There's a method called combine_results() that allows us to combine results from all jobs into a single Result, which is the same result in the tutorial's example. So I just did:

MExperiments = job_manager.run(all_circuits, backend=backend, shots = nshots)
results = MExperiments.results() 
cresults = results.combine_results()
mitigated_results = meas_filter.apply(cresults)
$\endgroup$
5
  • 1
    $\begingroup$ Ha. I forgot about that there is a combine_result method... I have been loop through all my results and combine them manually... :) $\endgroup$
    – KAJ226
    Feb 8 at 0:51
  • $\begingroup$ @KAJ226 Haha thanks!! Yeah I didn't know that, it's really fun to explore the 'method library' :-) $\endgroup$
    – ZR-
    Feb 8 at 0:55
  • $\begingroup$ @KAJ226 Oops.. I just found we might not be able to combine the results if the circuit list gets too large. It shows me 'Results cannot be combined since some of the jobs failed.' In my job status ., however, it shows all the jobs have been successfully executed. Do you know why this happens? -:) $\endgroup$
    – ZR-
    Feb 8 at 1:08
  • $\begingroup$ No, I don't, unfortunately. :( $\endgroup$
    – KAJ226
    Feb 8 at 1:46
  • $\begingroup$ @KAJ226 Haha thanks though:) $\endgroup$
    – ZR-
    Feb 8 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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