-
Notifications
You must be signed in to change notification settings - Fork 61
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
Move gates.Gate.decompose
to transpiler.decompositions
#1188
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1188 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 69 69
Lines 10107 10124 +17
=========================================
+ Hits 10107 10124 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Thank you for moving the Gate.decompose to the transpiler decompositions. This is a good start for the next step of having a general decomposer. I plan on starting it next week.
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 @renatomello, I believe this is a step in the right direction since it is reducing code duplication (or at least puts all decompositions in a single place). I have some questions:
- Do we still the
Gate.decompose
interface? If this is not used anywhere I would consider dropping completely. This way we avoid the ugly pylint exceptions and we don't have to maintain two interfaces for the same thing - we also force the users to use the transpiler interface directly. Personally I am not aware of any applications ofGate.decompose
. - Is there something special about the
standard_decomposition
? What makes it more "standard" than the other decompositions?
Not necessarily for this PR, but in my mind it would be useful have a map or function in which we pass the available native gates and we get back a GateDecomposition
that decomposes everything to these gates, for example
get_decomposition(NativeGates.GPI2 | NativeGates.CZ) -> cz_dec
etc. Then there is a trickier part of whether multiple decompositions can be combined to reach the desired gates, but that we could even leave for a later step.
I would say yes. I, for one, sometimes want to get a decomposition of one specific gate without being in the context of transpiling an entire circuit. It'd be annoying to have to create a circuit, add the gate, and then transpile the circuit just to get the decomposition of one gate.
No. Just like with any "standard", it is, by definition, arbitrary. In this case it just means the ones that were already hard-coded in the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1188 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 68 68
Lines 10203 10215 +12
=========================================
+ Hits 10203 10215 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
You can already do that using just from qibo.transpiler.decompositions import standard_decompositions
dec_gate = standard_decompositions(gate) without having to create any circuits. This is also more flexible because you can use any decomposition in the same fashion, not only the "standard" one. If the main issue is the names and import, we could propose better names and arrange the modules so that you can simply do from qibo.transpiler import mydecomposition or from qibo.decompositions import mydecomposition |
I think that the best way is either to use only the "transpiler method" or to allow in the decompose method to decide the basis gates. However as a first implementation only to store the decompositions in a single place this should be enough. Why don't we discuss the structure of the general unroller in person at the beginning of next week? |
I agree with this. Is it ok for you @stavros11? |
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.
I still don't see how Gate.decompose
itself can be useful but okay.
Closes #1040
Checklist: