[WIP] Fixing symbolic pulse equating for non-unique representations#9257
[WIP] Fixing symbolic pulse equating for non-unique representations#9257TsafrirA wants to merge 5 commits into
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 |
nkanazawa1989
left a comment
There was a problem hiding this comment.
Thanks @TsafrirA updated logic looks good to me. Do you want to remove draft now?
| # no parameters) | ||
| if self.parameters != other.parameters: | ||
| return False | ||
| if not self._equate_parameters(other): |
There was a problem hiding this comment.
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
amprepresentation to a real (float)amp,anglerepresentation. To overcome the non-unique nature of the new representation (particularly, when negative amp is allowed), this PR adds two optional attributescanonical_paramsandexcluded_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,anglerepresentation 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
amprepresentation to a real (float)amp,anglerepresentation. To better support several experiments in Qiskit-Experiments, theampparameter is allowed to take both positive and negative values. This decision creates a non-unique representation for the pulses, where a pi shift ofangleand a sign flip ofamphave 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
SymbolicPulseclass -canonical_paramsandexcluded_params. 'canonical_params' is a list of values orParametricExpressions which are equated when two pulses are equated.excluded_params, on the other hand, is a tuple of strings matching keys ofparameterswhich 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
ParameterExpressions arguments forcanonical_params.Returning to the example above, the new PR yields: