-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add support for BackendV2 #317
Conversation
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
9b9db11
to
541e49f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything lgtm - best to wait for @daka1510 to have another pair of eyes review
Pull Request Test Coverage Report for Build 2106543868Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Let's not merge this until we get an all pass on integration tests in my fork. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good, just added 2 questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…mprovements when lazy loading backends for a provider
… if need be now that we have a sub class Also convert us to s for t1 and t2 and ghz to hz for frequency and anharmonicity
qubit_props = {} | ||
for qubit, _ in enumerate(properties.qubits): | ||
t_1 = properties.t1(qubit) * 1e-6 # microseconds to seconds | ||
t_2 = properties.t2(qubit) * 1e-6 # microseconds to seconds | ||
frequency = properties.frequency(qubit) * 1e9 # GHz to Hz | ||
try: | ||
anharmonicity = ( | ||
properties.qubit_property(qubit, "anharmonicity")[0] * 1e9 | ||
) # GHz to Hz | ||
except Exception: # pylint: disable=broad-except | ||
anharmonicity = None | ||
qubit_props[qubit] = IBMQubitProperties( # type: ignore[no-untyped-call] | ||
t1=t_1, | ||
t2=t_2, | ||
frequency=frequency, | ||
anharmonicity=anharmonicity, | ||
) | ||
return qubit_props |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to a list return instead of a dict with int keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry didn't notice these comments, sure will open a new PR with these changes.
"reset": Reset(), | ||
} | ||
custom_gates = {} | ||
target = Target(num_qubits=configuration.n_qubits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should call qubit_props_dict_from_props
once it returns a list and set qubit_properties=qubit_properties
here from that list return.
def qubit_properties( | ||
self, qubit: Union[int, List[int]] | ||
) -> Union[IBMQubitProperties, List[IBMQubitProperties]]: | ||
"""Return IBMQubitProperties for a given qubit. | ||
|
||
Args: | ||
qubit: The qubit to get the | ||
:class:`~qiskit_ibm_provider.IBMQubitProperties` object for. This can | ||
be a single integer for 1 qubit or a list of qubits and a list | ||
of :class:`~qiskit_ibm_provider.IBMQubitProperties` objects will be | ||
returned in the same order | ||
|
||
Returns: | ||
IBMQubitProperties or a list of IBMQubitProperties | ||
""" | ||
self._get_properties() | ||
if not self._qubit_properties: | ||
self._qubit_properties = qubit_props_dict_from_props(self._properties) | ||
if isinstance(qubit, int): # type: ignore[unreachable] | ||
return self._qubit_properties.get(qubit) | ||
if isinstance(qubit, List): | ||
return [self._qubit_properties.get(q) for q in qubit] | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we set this in the target this can be deleted.
Summary
Add support for BackendV2
Details and comments
Copied from Qiskit/qiskit-ibmq-provider#1108
Fixes #238