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

Add support for BackendV2 #317

Merged
merged 21 commits into from
Apr 21, 2022
Merged

Conversation

rathishcholarajan
Copy link
Member

@rathishcholarajan rathishcholarajan commented Apr 6, 2022

Summary

Add support for BackendV2

Details and comments

Copied from Qiskit/qiskit-ibmq-provider#1108
Fixes #238

@rathishcholarajan rathishcholarajan added the Changelog: API Change Include in the Changed section of the changelog label Apr 6, 2022
@rathishcholarajan rathishcholarajan self-assigned this Apr 6, 2022
Copy link
Member

@kt474 kt474 left a 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

@coveralls
Copy link

coveralls commented Apr 6, 2022

Pull Request Test Coverage Report for Build 2106543868

Warning: 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

  • 57 of 192 (29.69%) changed or added relevant lines in 17 files are covered.
  • 95 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.3%) to 35.82%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit_ibm_provider/job/ibm_circuit_job.py 2 3 66.67%
qiskit_ibm_provider/jupyter/init.py 0 1 0.0%
qiskit_ibm_provider/jupyter/backend_info.py 0 1 0.0%
qiskit_ibm_provider/jupyter/config_widget.py 0 1 0.0%
qiskit_ibm_provider/jupyter/dashboard/backend_widget.py 0 1 0.0%
qiskit_ibm_provider/jupyter/gates_widget.py 0 1 0.0%
qiskit_ibm_provider/jupyter/qubits_widget.py 0 1 0.0%
qiskit_ibm_provider/jupyter/utils.py 0 1 0.0%
qiskit_ibm_provider/visualization/interactive/error_map.py 0 1 0.0%
qiskit_ibm_provider/jupyter/jobs_widget.py 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit_ibm_provider/ibm_backend.py 95 48.83%
Totals Coverage Status
Change from base Build 2106533842: -0.3%
Covered Lines: 1844
Relevant Lines: 5148

💛 - Coveralls

@rathishcholarajan
Copy link
Member Author

Let's not merge this until we get an all pass on integration tests in my fork.

@rathishcholarajan rathishcholarajan added the on hold Cannot fix yet label Apr 7, 2022
Copy link
Collaborator

@daka1510 daka1510 left a 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.

qiskit_ibm_provider/ibm_backend.py Show resolved Hide resolved
Copy link
Collaborator

@daka1510 daka1510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

… 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
Comment on lines +138 to +155
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
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

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.

Comment on lines +348 to +370
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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the Changed section of the changelog on hold Cannot fix yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for BackendV2 in qiskit-ibm-provider
6 participants