-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Ignoring unsupported gates for Solovay-Kitaev transpiler pass #13690
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
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 13070354287Warning: 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
💛 - Coveralls |
I agree it should leave |
This is indeed a valid alternative. I like the analogy with the BasisTranslator pass, though (unlike BT) SK already ignores all operations on 2 or more qubits, and it feels strange that the pass should ignore, for instance, the 2-qubit The other thing is that probably we need to make the pass recursive for control-flow ops (and not just ignore these as it happens right now), what do you think? Maybe we should first decide on the typical usages of the SK pass, when and how it would be used in a typical transpiler pipeline. |
The SK algorithm only applies to decompositions of Agree that the pass should recurse over control-flow operations. If we're intending to use the SK algorithm as part of a translation stage, we might want to consider it as an entire pipeline. To use the
In an ideal world, we'd want I wouldn't necessarily make the SK pass error out if it can't translate, since it's conceivable to me that you might want to use it in other contexts - we can make the translation stage error out in that case, potentially, where it's clear that the stage is required to fail if translation can't be done. |
Thanks @jakelishman, @Cryoris! I have added recursion for control-flow operators. If we agree that the SK pass should not error out if it can't translate, is there more you suggest to do here, modulo correcting the class documentation and polishing the release notes? Let's take the discussion of the transpilation pipeline to #13695. |
releasenotes/notes/sk-ignore-unsupported-ops-8d7d5f6fca255ffb.yaml
Outdated
Show resolved
Hide resolved
…yaml Co-authored-by: Julien Gacon <gaconju@gmail.com>
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.
LGTM, thanks!
* Bug fixes in Solovay Kitaev Decomposition (#14217) * Fix _compute_rotation_axis method The method used to return [0, 0, 0] for rotation axis when theta is very close to 0 (and yet not within 1e010). This commit fixes this by noting that the rotation axis of an SO(3) matrix is simply the eigenvector of this matrix corresponding to eigenvalue 1. * Fixes related to SU(2) vs. SO(3) The implemented algorithm has a global phase uncertainty of +-1, due to approximating not the original SU(2) matrix but its projection onto SO(3). This fixes the global phase of the computed approximation. In addition, the product_su2 matrix in GateSequence was not correctly computed in many cases, leading to incorrect values when using this attribute. Since this is not needed for the actual algorithm (and spends unnecessary effort for computing it), this also completely removes this attribute. Co-authored-by: Almudena Carrera Vazquez <almudenacarreravazquez@hotmail.com> * Fix the tests. One of the tests was simply wrong because the reference circuit has the wrong global phase. The tests that check the gates in the final decomposition should not assume that SGate is included and SdgGate is not. * reno * fix to the global phase * bug fix (forgetting that gate_matrix_su2 is not SU(2) was a sequence) * adding test * Restoring the previous fast code for _compute_rotation_axis based on Rodrigues formula, while additionally handling the case of 180-degree rotation * removing old code * review comments * switching back to using _to_dag and _to_circuit I actually no longer think that these methods would ever return a circuit with unitary gates, so it does not really matter * Addressing review comments * pass over release notes combining the original and the suggested wordings * Update releasenotes/notes/fix-sk-decomposition-23da3ee4b6a10d62.yaml Co-authored-by: Julien Gacon <gaconju@gmail.com> --------- Co-authored-by: Almudena Carrera Vazquez <almudenacarreravazquez@hotmail.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> (cherry picked from commit 6892608) # Conflicts: # test/python/transpiler/test_solovay_kitaev.py * Removing tests added in PR #13690 that was not backported to 1.4 --------- Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> Co-authored-by: Julien Gacon <jules.gacon@googlemail.com> Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Summary
The Solovay-Kitaev transpiler pass (i.e. the standalone pass and not the unitary synthesis plugin) previously considered all operations over$1$ qubit and ignored all operations over $k$ qubits for $k\ne 1$ . In doing so, it raised a transpiler error for circuits with single-qubit operations that are either parameterized or don't have a
to_matrix
method (these include barriers, measures, control-flow ops and more). This PR changes the default behavior to ignore such operations instead of raising an error.