-
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
[WIP] Fixing symbolic pulse equating for non-unique representations #9257
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 3670658549
💛 - 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.
Thanks @TsafrirA updated logic looks good to me. Do you want to remove draft now?
if self.parameters != other.parameters: | ||
return False | ||
if not self._equate_parameters(other): |
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 is nitpicky, but the logic seems to me bit inefficient. It first fully evaluates the dict equality and then compares the canonicals and rest of dict items. Maybe just return self._equate_paramters(other)
without if clause enough? Probably my suggestion is wrong because evaluation of builtin dict equality might be faster.
Summary
Qiskit-Terra PR #9002, converted the library symbolic pulses from a complex
amp
representation to a real (float)amp
,angle
representation. To overcome the non-unique nature of the new representation (particularly, when negative amp is allowed), this PR adds two optional attributescanonical_params
andexcluded_params
- the first is used for extra parameters which remove the degeneracy, and the second to indicate which parameters don't necessarily have to be equa.PR #9247 presented a different option for this - using SymbolicExpressions - and was closed.
PR #9314 presented a different approach altogether - not a general solution for every non unique representation, but rather a focused solution for pulses with
amp,angle
representation via a new subclass - leading to this PR being closed.Details and comments
Qiskit-Terra PR #9002, converted the library symbolic pulses from a complex
amp
representation to a real (float)amp
,angle
representation. To better support several experiments in Qiskit-Experiments, theamp
parameter is allowed to take both positive and negative values. This decision creates a non-unique representation for the pulses, where a pi shift ofangle
and a sign flip ofamp
have the same effect (the issue obviously also exists for 2*pi shift ofangle
). For example, the following two pulsesare not the same when equated (because their parameters are different):
but they represent the same waveform:
This PR sets to correct this situation, by introducing two new attributes to the
SymbolicPulse
class -canonical_params
andexcluded_params
. 'canonical_params' is a list of values orParametricExpression
s which are equated when two pulses are equated.excluded_params
, on the other hand, is a tuple of strings matching keys ofparameters
which should be ignored in the equating process of the two pulses. For library pulses, the new parameters are assigned the following values:canonical_params=[amp * np.exp(1j * angle)]
andexcluded_params=("amp","angle")
.By adjusting the parameter assignment procedure for symbolic pulses, this method works for
ParameterExpression
s arguments forcanonical_params
.Returning to the example above, the new PR yields: