-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Solve strange behavior with qubit_properties
in Target
.
#13400
Conversation
The previous implementation of the Target would always make sure to receive a real value for `num_qubits` or it would default to zero. Mistakenly because of the behavior of `Target::from_configuration` it was assumed that `num_qubits` could be `None` unless otherwise specified. However, the default behavior should be to make `num_qubits` zero unless specified otherwise. The following commits fix this behavior by fixing the signature of the rust `Target` to have default values and adding an extra check when comparing against `qubit_properties`. A test casde based on @wshanks findings in Qiskit#13393 was also included in these additions.
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 11692746207Details
💛 - Coveralls |
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.
Hmmm I am a bit weary of the change in the default value of num_qubits
because I remember playing around with it with the refactoring of BasicSimulator
and concluding that the default should stay None
. However, it's true that the BasicSimulator
target is instantiated explicitly with num_qubits=None
, so maybe I remember a different issue. In any case, wouldn't this have to be documented as an interface change? I don't think it should be something users heavily rely on but I think this is part of the user-facing API, right?
I think the switch to |
Aha, then maybe I remembered the issue the other way round, the default was |
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.
Ok, double checking the historical target version @mtreinish linked, I think it makes sense to align the default values of the constructor with the python ones, both for num_qubits
and the pulse-related args. LGTM!
Summary
Fixes #13393.
The following commits address some strange behavior when deciding the
num_qubits
attribute of a Target when onlyqubit_properties
is provided.Details and comments
The previous implementation of the Target would always make sure to receive a real value for
num_qubits
or it would default to zero. Mistakenly because of the behavior ofTarget::from_configuration
it was assumed thatnum_qubits
could beNone
unless otherwise specified. However, the default behavior should be to makenum_qubits
zero unless specified otherwise.The following commits fix this behavior by fixing the signature of the rust
Target
to have default values and adding an extra check when comparing againstqubit_properties
.A test case based on @wshanks findings in #13393 was also included in these additions.