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

ResonatorSpectroscopy is incompatible with BackendV2 #1099

Closed
tenzan-araki opened this issue Mar 23, 2023 · 2 comments · Fixed by #900
Closed

ResonatorSpectroscopy is incompatible with BackendV2 #1099

tenzan-araki opened this issue Mar 23, 2023 · 2 comments · Fixed by #900
Labels
bug Something isn't working

Comments

@tenzan-araki
Copy link

Informations

  • Qiskit Experiments version: main
  • Python version: 3.10.7
  • Operating system: Mac OS

What is the current behavior?

ResonatorSpectroscopy fails to obtain center frequency of resonator for BackendV2, because BackendV2 does not have access to BackendData.meas_freqs. Specifically, BackendData(backend).meas_freqs is an empty list, and center_freq = BackendData(backend).meas_freqs[physical_qubits[0]] results in the error list index out of range.

Steps to reproduce the problem

The following code produces the error:

from qiskit_ibm_provider import IBMProvider
from qiskit_experiments.library import ResonatorSpectroscopy

provider = IBMProvider()
backend = provider.get_backend('ibm_hanoi')

qubit = 0
spec = ResonatorSpectroscopy((qubit,), backend)

The following code shows that this is caused by an incompatibility with BackendV2:

from qiskit import IBMQ
from qiskit_ibm_provider import IBMProvider
from qiskit_experiments.framework import BackendData

IBMQ.load_account()
provider1 = IBMQ.get_provider(hub='ibm-q-internal', group='deployed', project='default')
provider2 = IBMProvider(instance="ibm-q-internal/deployed/default")

backendV1 = provider1.get_backend('ibm_hanoi')
backendV2 = provider2.get_backend('ibm_hanoi')

print('BackendV1: ', BackendData(backendV1).meas_freqs)
print('BackendV2: ', BackendData(backendV2).meas_freqs)

What is the expected behavior?

The ResonatorSpectroscopy experiment should be made compatible with BackendV2.

@wshanks
Copy link
Collaborator

wshanks commented Mar 23, 2023

#900 which I had opened a while ago should fix this. I have just brought it back up to date so it can be reviewed and merged.

@wshanks
Copy link
Collaborator

wshanks commented Mar 23, 2023

You can get around the error by using absolute=False for now.

wshanks added a commit that referenced this issue Mar 27, 2023
### Summary

This change continues the work started in #843 to make
qiskit-experiments compatible with BackendV2. It updates the
spectrscopy, fine frequency and amplitude, and T1 tests to use
`BackendV2` rather than `BackendV1`. Additionally it adds support for
querying `BackendV2` for measurement frequencies.

### Details and comments

The main changes are:

* Use `backend.defaults()` to look up `measure_freq_est` for `BackendV2`
as well as `BackendV1`.
* Improve the error message when `measure_freq_est` can not be accessed
for `ResonatorSpectroscopy`
* Add T1 to `BackendData` because it is needed by `RestlessMixin`.
* Switch `MockRestlessBackend` and `MockIQBackend` to `BackendV2`. This
conversion was done by making a `FakeOpenPulse2QV2` `BackendV2` shim for
the `BackendV1` `FakeOpenPulse2Q` in terra.
* Replace modification of `basis_gates` with modification of
  `backend.target` in relevant tests.
* Remove some unnecessary code (assignments to `timing_constraints` and
  a test class with no tests).


There are a few of inelegant changes in this PR:

* Usage of `backend.defaults()` was restored for accessing the
measurement frequencies. This is an IBM specific method not in the
`BackendV1` or `BackendV2` base classes. It is only used for querying
meas_freq_est. `backend.defaults()` is what we had been using before
#843, so this is just putting things back the way we were. We might
decide to get this data a different way that does not use `defaults()`
but at the moment that is the only way to get the measurement
frequencies, so we would need to the IBM backends to provide these
values in the properties, for instance.
* `defaults()` was hacked into the fake `BackendV2` backends for the
`ResonatorSpectroscopy` tests. The fake `BackendV1` backends in terra do
provide it but not the `BackendV2` variants. One nice thing about moving
away from `defaults()` (previous point) is that we could remove this
hack.
* There is no `BackendV2` version of `FakeOpenPulse2Q`, so one was
hacked out of the `BackendV1` version. Perhaps we could get terra to
include a `BackendV2` version of `FakeOpenPulse2Q` in the future.

Closes #1099

---------

Co-authored-by: Naoki Kanazawa <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants