-
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
Add full path transpile() support for disjoint backends #9840
Add full path transpile() support for disjoint backends #9840
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 4703893491
💛 - Coveralls |
78bdfb0
to
c3fdaca
Compare
c3fdaca
to
f4f3595
Compare
da52e9b
to
8df2130
Compare
Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes.
This commit finalizes the last piece of the full path transpile() support at all optimization levels. The primary piece to accomplish this was adding DenseLayout support for targeting a disjoint CouplingMap. With this piece added then all the default transpiler paths in the preset pass managers are able to support running with a disjoint CouplingMap. The biggest exception is the TrivialLayout pass which can result in an invalid layout being selected (where 2q connectivity crosses connected components). To handle this edge case a check is added to each routing stage to ensure the selected layout is valid for the coupling map and it is routable. This enables all the default paths at all 4 optimization levels for transpile() to be usable with disjoint connectivity. For optimization_level=0/TrivialLayout if the trivial layout is invalid the routing pass will raise an error saying as much. It's worth pointing out that NoiseAdaptiveLayout still doesn't support disjoint connectivity. However, since it's performance is poor and it's not used by default in any preset passmanager we can add this at a later date, but all other combinations of layout and routing methods should work (given the caveats with TrivialLayout) above.
Now that Qiskit#9802 supports shared classical bits correctly this commit re-enables the tests disabled in the previous commit.
8df2130
to
0041f3f
Compare
Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes.
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.
Just a few small comments.
Co-authored-by: Kevin Hartman <kevin@hart.mn>
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.
Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes.
* Filter/ignore qubits in Target without any operations Building off #9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from #9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes. * Expand testing * Make filtered qubit coupling map a Target.build_coupling_map option This commit reworks the logic to construct a filtered coupling map as an optional argument on `Target.build_coupling_map()`. This makes the filtering a function of the Target object itself, which is where the context/data about which qubits support operations or not lives. The previous versions of this PR had a weird mix of responsibilities where the target would generate a coupling map and then we'd pass the target to that coupling map to do an additional round of filtering on it. * Apply suggestions from code review Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix incorrect set construction * Expand docstring on build_coupling_map argument * Rework logic in vf2 passes for filtering * Update argument name in disjoint_utils.py * Inline second argument for require_layout_isolated_to_component Co-authored-by: Kevin Hartman <kevin@hart.mn> * Update qiskit/transpiler/passes/layout/vf2_post_layout.py Co-authored-by: Kevin Hartman <kevin@hart.mn> * Apply suggestions from code review Co-authored-by: Kevin Hartman <kevin@hart.mn> * Remove unnecessary len() * Inline second arg for dense_layout too --------- Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Kevin Hartman <kevin@hart.mn>
* Add full path transpile() support for disjoint backends This commit finalizes the last piece of the full path transpile() support at all optimization levels. The primary piece to accomplish this was adding DenseLayout support for targeting a disjoint CouplingMap. With this piece added then all the default transpiler paths in the preset pass managers are able to support running with a disjoint CouplingMap. The biggest exception is the TrivialLayout pass which can result in an invalid layout being selected (where 2q connectivity crosses connected components). To handle this edge case a check is added to each routing stage to ensure the selected layout is valid for the coupling map and it is routable. This enables all the default paths at all 4 optimization levels for transpile() to be usable with disjoint connectivity. For optimization_level=0/TrivialLayout if the trivial layout is invalid the routing pass will raise an error saying as much. It's worth pointing out that NoiseAdaptiveLayout still doesn't support disjoint connectivity. However, since it's performance is poor and it's not used by default in any preset passmanager we can add this at a later date, but all other combinations of layout and routing methods should work (given the caveats with TrivialLayout) above. * Fix test determinism * Add future facing test for shared classical bits between components * Enable shared control flow test Now that Qiskit#9802 supports shared classical bits correctly this commit re-enables the tests disabled in the previous commit. * Remove unused condition for faulty qubits backnedv1 path * Remove opt level 1 variant of test_chained_data_dependency * Use enumerate() in check_layout_isolated_to_component() Co-authored-by: Kevin Hartman <kevin@hart.mn> * Expand level 0 test coverage * Update test/python/compiler/test_transpiler.py Co-authored-by: Kevin Hartman <kevin@hart.mn> * s/check_layout_isolated_to_component/require_layout_isolated_to_component/g --------- Co-authored-by: Kevin Hartman <kevin@hart.mn>
* Add full path transpile() support for disjoint backends This commit finalizes the last piece of the full path transpile() support at all optimization levels. The primary piece to accomplish this was adding DenseLayout support for targeting a disjoint CouplingMap. With this piece added then all the default transpiler paths in the preset pass managers are able to support running with a disjoint CouplingMap. The biggest exception is the TrivialLayout pass which can result in an invalid layout being selected (where 2q connectivity crosses connected components). To handle this edge case a check is added to each routing stage to ensure the selected layout is valid for the coupling map and it is routable. This enables all the default paths at all 4 optimization levels for transpile() to be usable with disjoint connectivity. For optimization_level=0/TrivialLayout if the trivial layout is invalid the routing pass will raise an error saying as much. It's worth pointing out that NoiseAdaptiveLayout still doesn't support disjoint connectivity. However, since it's performance is poor and it's not used by default in any preset passmanager we can add this at a later date, but all other combinations of layout and routing methods should work (given the caveats with TrivialLayout) above. * Fix test determinism * Add future facing test for shared classical bits between components * Enable shared control flow test Now that Qiskit#9802 supports shared classical bits correctly this commit re-enables the tests disabled in the previous commit. * Remove unused condition for faulty qubits backnedv1 path * Remove opt level 1 variant of test_chained_data_dependency * Use enumerate() in check_layout_isolated_to_component() Co-authored-by: Kevin Hartman <kevin@hart.mn> * Expand level 0 test coverage * Update test/python/compiler/test_transpiler.py Co-authored-by: Kevin Hartman <kevin@hart.mn> * s/check_layout_isolated_to_component/require_layout_isolated_to_component/g --------- Co-authored-by: Kevin Hartman <kevin@hart.mn>
* Filter/ignore qubits in Target without any operations Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes. * Expand testing * Make filtered qubit coupling map a Target.build_coupling_map option This commit reworks the logic to construct a filtered coupling map as an optional argument on `Target.build_coupling_map()`. This makes the filtering a function of the Target object itself, which is where the context/data about which qubits support operations or not lives. The previous versions of this PR had a weird mix of responsibilities where the target would generate a coupling map and then we'd pass the target to that coupling map to do an additional round of filtering on it. * Apply suggestions from code review Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix incorrect set construction * Expand docstring on build_coupling_map argument * Rework logic in vf2 passes for filtering * Update argument name in disjoint_utils.py * Inline second argument for require_layout_isolated_to_component Co-authored-by: Kevin Hartman <kevin@hart.mn> * Update qiskit/transpiler/passes/layout/vf2_post_layout.py Co-authored-by: Kevin Hartman <kevin@hart.mn> * Apply suggestions from code review Co-authored-by: Kevin Hartman <kevin@hart.mn> * Remove unnecessary len() * Inline second arg for dense_layout too --------- Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Kevin Hartman <kevin@hart.mn>
Summary
This commit finalizes the last piece of the full path transpile()
support at all optimization levels. The primary piece to accomplish this
was adding DenseLayout support for targeting a disjoint CouplingMap.
With this piece added then all the default transpiler paths in the
preset pass managers are able to support running with a disjoint
CouplingMap. The biggest exception is the TrivialLayout pass which can
result in an invalid layout being selected (where 2q connectivity
crosses connected components). To handle this edge case a check is added
to each routing stage to ensure the selected layout is valid for the
coupling map and it is routable. This enables all the default paths at
all 4 optimization levels for transpile() to be usable with disjoint
connectivity. For optimization_level=0/TrivialLayout if the trivial
layout is invalid the routing pass will raise an error saying as much.
It's worth pointing out that NoiseAdaptiveLayout still doesn't
support disjoint connectivity. However, since it's performance is poor
and it's not used by default in any preset passmanager we can add this
at a later date, but all other combinations of layout and routing
methods should work (given the caveats with TrivialLayout) above.
Details and comments
This PR is based on top of #9802 and #9710 and is tagged as on hold until they both merge.
It will be be rebased after both of those PRs merge. To see the contents of just this PR you can
view:
mtreinish/qiskit-core@layout_and_route_disjoint_coupling_maps...mtreinish:qiskit-core:full-transpile-disjoint-support