Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompleteMeasFitter incorrectly imported in measurement_error_mitigation.py #6980

Closed
omarshehab opened this issue Sep 3, 2021 · 13 comments
Closed
Labels
bug Something isn't working

Comments

@omarshehab
Copy link

Information

  • Qiskit Terra version: 0.18.0
  • Python version: 3.9.5 (default, May 18 2021, 12:31:01) [Clang 10.0.0 ]
  • Operating system: Darwin

What is the current behavior?

I am currently seeing

QiskitError: 'Unknown fitter <qiskit.ignis.mitigation.measurement.fitters.CompleteMeasFitter object at 0x7fcbcace6c40>'

error, when I pass an qiskit.ignis.mitigation.measurement.fitters.CompleteMeasFitter object as a value to the parameter measurement_error_mitigation_cls in the constructor of QuantumInstance and use the QuantumInstance object with QuantumKernel.evaluate() .

Steps to reproduce the problem

  1. Generate the calibration circuits using complete_meas_cal().
  2. Execute the calibration circuits on target hardware (for this week ibm_toronto).
  3. Calculate the calibration matrix using CompleteMeasFitter().
  4. Pass the calibration matrix calculated in step # 3 as a value for the parameter measurement_error_mitigation_clswhile creating an instance of QuantumInstance . For simplicity, I am not overriding the default values for cals_matrix_refresh_period and measurement_error_mitigation_shots.
  5. Use the QuantumInstance object in the standard QSVM pipeline.

What is the expected behavior?

It should not throw any runtime error.

Suggested solutions

CompleteMeasFitter incorrectly imported in measurement_error_mitigation.py. At line # 141 of measurement_error_mitigation.py, CompleteMeasFitter should be imported from qiskit.ignis.mitigation.measurement.fitters instead of qiskit.ignis.mitigation.measurement.

@omarshehab omarshehab added the bug Something isn't working label Sep 3, 2021
@TheGupta2012
Copy link
Contributor

May I work on this @omarshehab ?

@ShellyGarion
Copy link
Member

I think that the following PR should handle this issue: #6867
(note that qiskit-ignis is going to be deprecated)

@TheGupta2012
Copy link
Contributor

Okayy 👍

@ShellyGarion
Copy link
Member

PR #6867 is part of the next release 0.19: https://github.com/Qiskit/qiskit-terra/milestone/18

@woodsp-ibm
Copy link
Member

Can you check with the latest version of qiskit - 0.18.1 (you say you have 0.18.0). The issue you describe was fixed

See https://qiskit.org/documentation/release_notes.html#bug-fixes

Fixed an issue where the QuantumInstance class would potentially try to use the CompleteMeasFitter class before it was imported resulting in an error. Fixed #6774

@omarshehab
Copy link
Author

@woodsp-ibm , I received the same error with Qiskit Terra 0.18.1.

@jakelishman
Copy link
Member

jakelishman commented Sep 4, 2021

It sounds like you're passing an instance, but the code wants the actual class (i.e. pass CompleteMeasFitter directly). The error you reported is consistent with the import having succeeded, but the wrong value having been passed.

(by the way, for reproducibility, it can be a little easier for us if you're able to provide a minimal complete block of code to read and copy/paste, rather than trying to interpret text)

@omarshehab
Copy link
Author

@jakelishman , I have attached the MWE code here.

qsvm-readout-error-mitigation-mwe.ipynb.zip

@jakelishman
Copy link
Member

That's not exactly a MWE, but I can see you are setting measurement_error_mitigation_class to an instance of CompleteMeasFitter, but it's meant to be the class (type). You need to pass CompleteMeasFitter to construct QuantumInstance, not a constructed instance of it.

@woodsp-ibm
Copy link
Member

If an example would be helpful for how to use it see this tutorial https://qiskit.org/documentation/tutorials/algorithms/03_vqe_simulation_with_noise.html#Performance-with-noise-and-measurement-error-mitigation

@omarshehab
Copy link
Author

@woodsp-ibm , I modified the statement to create QuantumInstance as follows.

noise_model = NoiseModel.from_backend(backend)
adhoc_backend = QuantumInstance(backend, shots=1024,
                                seed_transpiler=seed, optimization_level = 3, noise_model=noise_model, measurement_error_mitigation_cls=CompleteMeasFitter)

Currently, I am getting the following error.

QiskitError: "The noise model is not supported on the selected backend ibmq_quito (<AccountProvider for IBMQ(hub='ibm-q-internal', group='deployed', project='default')>) only certain backends, such as Aer qasm simulator support noise."````

@ShellyGarion
Copy link
Member

@omarshehab - you cannot have a noise model with ibmq backend, only with Aer simulator:
backend = Aer.get_backend('aer_simulator')
the ibmq devices already have noise inside them :)
so, you should either choose an ibmq backend, or Aer simulator with a noise model
please look again at the tutorial suggested above.

@jakelishman
Copy link
Member

I'm closing this now, because I think that if there was a bug, it was fixed, and the other issues were due to problems with the usage. Please feel free to re-open this or another issue if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants