-
Notifications
You must be signed in to change notification settings - Fork 2.6k
two-qubit unitary synthesis adapted to errors and over-complete gatesets #9175
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
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:
|
ca7cf23
to
f40ffda
Compare
@ewinston @mtreinish I think this is ready, can you have another look please |
Pull Request Test Coverage Report for Build 4093415744
💛 - Coveralls |
This looks good, although I didn't carefully check the performance, but I suppose that will show up in the automated benchmarks. |
…ets (Qiskit#9175) * make Optimize1qGatesDecomposition target aware * choose decomopsition based on fidelity * tests for the target path * choosing XXDecomposition * add known embodiments as a library * choosing between controlled and supercontrolled decomposers * add known embodiments. add basis_fidelity to init of XXDecomposer * set basis_fidelity at init of all decomposers, not per call * choose euler_basis based on 1q error rates * make backup_optimizer in XXDecomposer pulse_efficient * revert changes to one_qubit_euler_decomposer.py * use Optimize1qGatesDecomposition when UnitarySynthesis hits a 1-qubit unitary * build all the decomposers, then choose after running them * add a function for computing circuit error from target * run all available decomposers, fix synth direction if needed, choose min cost * xx embodiment for itself * add ECR embodiment and fix some tests * add ECR embodiment and fix some tests * fix preferred_direction * no decomposition if no basis * release notes * remove unnecessary GateDirection from level 3. Add a test for targeting a single fractional gate, no full entangler * change gate_lengths and gate_errors format, and update _preferred_direction and _error * remove accidental test duplicates * small lint fixes * approximation degree * rebase * add approximate=True/False arg to TwoQubitBasisDecomposer * black * review comments * approximation_degree should default to 1, not None * type hints * fix a test that was wrong in test_optimize_1q_commutation * one qubit unitary corner case is decomposed with UnitarySynthesis but not with Optimize1qGatesDecomposition * one more test for approx * lint * release note format
could it be this introduced a regression #9592 ? |
This commit fixes an issue introduced into the UnitarySynthesis pass as part of Qiskit#9175. In Qiskit#9715 the UnitarySynthesis pass was updated to consider multiple different target bases and select the best performing synthesis output found. When UnitarySynthesis is provided a Target object this involves querying the target for the error rates and duration of the instructions used. However, currently this lookup doesn't handle a couple of edge cases in the target data model resulting from variable width operations and ideal gates (i.e. from a simulator that don't have error or durations). In those cases some fields in the internal dictionaries used to store data can be None or the gate object stored in the target can be a class not an instance of a class. If a target with either of these properties were used as an input to UnitarySynthesis the pass would error. Fixes Qiskit#9592
* Fix target error and duration lookup in UnitarySynthesis This commit fixes an issue introduced into the UnitarySynthesis pass as part of #9175. In #9715 the UnitarySynthesis pass was updated to consider multiple different target bases and select the best performing synthesis output found. When UnitarySynthesis is provided a Target object this involves querying the target for the error rates and duration of the instructions used. However, currently this lookup doesn't handle a couple of edge cases in the target data model resulting from variable width operations and ideal gates (i.e. from a simulator that don't have error or durations). In those cases some fields in the internal dictionaries used to store data can be None or the gate object stored in the target can be a class not an instance of a class. If a target with either of these properties were used as an input to UnitarySynthesis the pass would error. Fixes #9592 * Remove superfluous pylint suppression --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Fix target error and duration lookup in UnitarySynthesis This commit fixes an issue introduced into the UnitarySynthesis pass as part of Qiskit#9175. In Qiskit#9715 the UnitarySynthesis pass was updated to consider multiple different target bases and select the best performing synthesis output found. When UnitarySynthesis is provided a Target object this involves querying the target for the error rates and duration of the instructions used. However, currently this lookup doesn't handle a couple of edge cases in the target data model resulting from variable width operations and ideal gates (i.e. from a simulator that don't have error or durations). In those cases some fields in the internal dictionaries used to store data can be None or the gate object stored in the target can be a class not an instance of a class. If a target with either of these properties were used as an input to UnitarySynthesis the pass would error. Fixes Qiskit#9592 * Remove superfluous pylint suppression --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Since Qiskit#9175 merged the UnitarySynthesis pass has been updated to consider multiple different potential target bases and select the best performing synthesis output found. When UnitarySynthesis is provided a Target object this involves querying the target for the error rates and duration of the instructions used and determining which bases are valid. As part of this lookup the Operator for the 2q gates in the target is needed to determine the characteristics of the 2q gates. However, the code for doing this wasn't considering that some operations in the target might not have sufficient information to build a unitary representation of the operation. This could come up with the use of custom opaque gates in the target that don't have a definition defined or a matrix defined. This commit fixes this oversight and handles the case where building an Operator for the gate fails. Related to #9675 (the underlying issue is in the qiskit-ibm-runtime package for not mapping the "ecr" string to the "ECRGate" object, so this won't close that issue).
* Fix UnitarySynthesis with target that contains custom gates Since #9175 merged the UnitarySynthesis pass has been updated to consider multiple different potential target bases and select the best performing synthesis output found. When UnitarySynthesis is provided a Target object this involves querying the target for the error rates and duration of the instructions used and determining which bases are valid. As part of this lookup the Operator for the 2q gates in the target is needed to determine the characteristics of the 2q gates. However, the code for doing this wasn't considering that some operations in the target might not have sufficient information to build a unitary representation of the operation. This could come up with the use of custom opaque gates in the target that don't have a definition defined or a matrix defined. This commit fixes this oversight and handles the case where building an Operator for the gate fails. Related to #9675 (the underlying issue is in the qiskit-ibm-runtime package for not mapping the "ecr" string to the "ECRGate" object, so this won't close that issue). * Fix lint * Only run Operator construction under try block The error we're trying to catch and handle is if a gate object doesn't have sufficient information to get it's matrix. This commit updates the try block to only run on the Operator construction so we don't potentially mas errors in the TwoQubitWeylDecomposition construction. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit reverts an unecessary breaking API change that was introduced in Qiskit#9175. In that PR the data type for two arguments, gate_lengths and gate_errors, that was potentially passed to plugins was changed. This change was well intentioned as it was used by the default plugin as part of the changes to the default plugin made in that PR. But this neglected the downstream effects for any existing plugin interface users relying on the input to those fields. Making this change to existing fields would break any plugins that were using the old data format and is a violation of the Qiskit stability and deprecation policy. This commit reverts that change so that gate_lengths and gate_errors contain the same data format as in previous releases. Instead to facilitate the new workflow a new fields, gate_lengths_by_qubit and gate_errors_by_qubit, were added that leverage the new format introduced by Qiskit#9175. By adding this as new optional fields existing users can continue to work as before, but the default plugin which requires the different data format can use the new data type.
* Undo breaking API change in unitary synthesis plugin interface This commit reverts an unecessary breaking API change that was introduced in #9175. In that PR the data type for two arguments, gate_lengths and gate_errors, that was potentially passed to plugins was changed. This change was well intentioned as it was used by the default plugin as part of the changes to the default plugin made in that PR. But this neglected the downstream effects for any existing plugin interface users relying on the input to those fields. Making this change to existing fields would break any plugins that were using the old data format and is a violation of the Qiskit stability and deprecation policy. This commit reverts that change so that gate_lengths and gate_errors contain the same data format as in previous releases. Instead to facilitate the new workflow a new fields, gate_lengths_by_qubit and gate_errors_by_qubit, were added that leverage the new format introduced by #9175. By adding this as new optional fields existing users can continue to work as before, but the default plugin which requires the different data format can use the new data type. * Update docstring * Fix copy paste error
* Undo breaking API change in unitary synthesis plugin interface This commit reverts an unecessary breaking API change that was introduced in #9175. In that PR the data type for two arguments, gate_lengths and gate_errors, that was potentially passed to plugins was changed. This change was well intentioned as it was used by the default plugin as part of the changes to the default plugin made in that PR. But this neglected the downstream effects for any existing plugin interface users relying on the input to those fields. Making this change to existing fields would break any plugins that were using the old data format and is a violation of the Qiskit stability and deprecation policy. This commit reverts that change so that gate_lengths and gate_errors contain the same data format as in previous releases. Instead to facilitate the new workflow a new fields, gate_lengths_by_qubit and gate_errors_by_qubit, were added that leverage the new format introduced by #9175. By adding this as new optional fields existing users can continue to work as before, but the default plugin which requires the different data format can use the new data type. * Update docstring * Fix copy paste error (cherry picked from commit 72e7481)
… (#10075) * Undo breaking API change in unitary synthesis plugin interface This commit reverts an unecessary breaking API change that was introduced in #9175. In that PR the data type for two arguments, gate_lengths and gate_errors, that was potentially passed to plugins was changed. This change was well intentioned as it was used by the default plugin as part of the changes to the default plugin made in that PR. But this neglected the downstream effects for any existing plugin interface users relying on the input to those fields. Making this change to existing fields would break any plugins that were using the old data format and is a violation of the Qiskit stability and deprecation policy. This commit reverts that change so that gate_lengths and gate_errors contain the same data format as in previous releases. Instead to facilitate the new workflow a new fields, gate_lengths_by_qubit and gate_errors_by_qubit, were added that leverage the new format introduced by #9175. By adding this as new optional fields existing users can continue to work as before, but the default plugin which requires the different data format can use the new data type. * Update docstring * Fix copy paste error (cherry picked from commit 72e7481) Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
) * Fix UnitarySynthesis with target that contains custom gates Since Qiskit#9175 merged the UnitarySynthesis pass has been updated to consider multiple different potential target bases and select the best performing synthesis output found. When UnitarySynthesis is provided a Target object this involves querying the target for the error rates and duration of the instructions used and determining which bases are valid. As part of this lookup the Operator for the 2q gates in the target is needed to determine the characteristics of the 2q gates. However, the code for doing this wasn't considering that some operations in the target might not have sufficient information to build a unitary representation of the operation. This could come up with the use of custom opaque gates in the target that don't have a definition defined or a matrix defined. This commit fixes this oversight and handles the case where building an Operator for the gate fails. Related to #9675 (the underlying issue is in the qiskit-ibm-runtime package for not mapping the "ecr" string to the "ECRGate" object, so this won't close that issue). * Fix lint * Only run Operator construction under try block The error we're trying to catch and handle is if a gate object doesn't have sufficient information to get it's matrix. This commit updates the try block to only run on the Operator construction so we don't potentially mas errors in the TwoQubitWeylDecomposition construction. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…t#10066) * Undo breaking API change in unitary synthesis plugin interface This commit reverts an unecessary breaking API change that was introduced in Qiskit#9175. In that PR the data type for two arguments, gate_lengths and gate_errors, that was potentially passed to plugins was changed. This change was well intentioned as it was used by the default plugin as part of the changes to the default plugin made in that PR. But this neglected the downstream effects for any existing plugin interface users relying on the input to those fields. Making this change to existing fields would break any plugins that were using the old data format and is a violation of the Qiskit stability and deprecation policy. This commit reverts that change so that gate_lengths and gate_errors contain the same data format as in previous releases. Instead to facilitate the new workflow a new fields, gate_lengths_by_qubit and gate_errors_by_qubit, were added that leverage the new format introduced by Qiskit#9175. By adding this as new optional fields existing users can continue to work as before, but the default plugin which requires the different data format can use the new data type. * Update docstring * Fix copy paste error
Summary
This commit updates the
DefaultUnitarySynthesis
transpiler pass for the case of 2-qubit unitaries. Now it can target a richer gateset, and picks the lowest-error synthesis option if multiple synthesis exist.Details and comments
The basis supported here is a single controlled gate of the canonical form (a, 0, 0) or a set of supercontrolled gates of the canonical form (pi/4, b, 0), or both. Other basis decomposers can be added in the future. Each two-qubit basis is paired with every possible one-qubit basis to yield the set of all possible basis to consider.
Example
original

target 1

target 2

target 3
