-
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
layout_method and routing_method selectors in transpile() #3999
Conversation
ee86ad6
to
137b3f2
Compare
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.
Looks good so far. Can you add a release note?
Right now, these don't completely override layout selection . E.g. for level2, if a user requests 'noise_adaptive', we'll still run csp_layout -> _choose_layout_condition -> noise_adaptive
. This is reasonable behavior, but might not be what the user expects, so we should point it out in the docstring.
_given_layout = SetLayout(initial_layout) | ||
|
||
def _choose_layout_condition(property_set): | ||
return not property_set['layout'] | ||
|
||
_choose_layout = TrivialLayout(coupling_map) | ||
if layout_method == 'trivial': |
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.
Can this be consolidated in e.g. _parse_layout_method
(and pass the selected class or None in the passmanagerconfig?)
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.
yeah that would be good to avoid repetition but right now the layout passes don't have the same signature, so I can't just pass the class here.
if layout_method == 'trivial':
_choose_layout = TrivialLayout(coupling_map)
elif layout_method == 'dense':
_choose_layout = DenseLayout(coupling_map, backend_properties)
elif layout_method == 'noise_adaptive':
_choose_layout = NoiseAdaptiveLayout(backend_properties)
It would be ideal to provide a unified interface though. I think in general there is too much repetition between the preset passmanagers, so a refactoring that makes them derive the same base and tweak would be great.
137b3f2
to
ebd290b
Compare
a02e9c1
to
e88c19f
Compare
In Qiskit#3999 we increased the number of trials, but the global benefit from doing this isn't clear. With the pending release weighing the increased run time for more trials against this, this commit temporarily reverts the number of trials for level 1 and level 2 back to their previous setting of 20. When we get to the bottom of Qiskit#4094 and have a fix or change for that we can increase the number of trials again. Related Qiskit#4094
In #3999 we increased the number of trials, but the global benefit from doing this isn't clear. With the pending release weighing the increased run time for more trials against this, this commit temporarily reverts the number of trials for level 1 and level 2 back to their previous setting of 20. When we get to the bottom of #4094 and have a fix or change for that we can increase the number of trials again. Related #4094
* add ability to select layout and routing method from top transpile function * set lookahead width/depth in increasing order * releasenote * review comments * lint * lint Co-authored-by: Kevin Krsulich <[email protected]>
…4099) In Qiskit#3999 we increased the number of trials, but the global benefit from doing this isn't clear. With the pending release weighing the increased run time for more trials against this, this commit temporarily reverts the number of trials for level 1 and level 2 back to their previous setting of 20. When we get to the bottom of Qiskit#4094 and have a fix or change for that we can increase the number of trials again. Related Qiskit#4094
Adding the ability to quickly select
layout_method
androuting_method
from the top-leveltranspile()
call. This configures the level 0-3 passmanagers to use the given methods for layout and routing.Something like this using
passmanager.replace()
is also doable but not as convenient due to the issue of conditions, control-flow, etc. surrounding the passes.Generally I think there are a few basic & key steps to the compilation flow, each of which have several possible methods: optimization, placement, routing, scheduling, pulse selection.
With
optimization_level
,layout_method
,routing_method
we cover the first 3. The 4th is in the form ofschedule(circuit, method)
right now.Building a passmanager gives you ultimate control over how passes get chained, repeated until convergence, etc. but high-level options are still very useful in allowing the user to quickly explore alternatives. For example right now I don't think the "lookahead swap" is used anywhere or anyone knows how to invoke it.