Skip to content

Conversation

mtreinish
Copy link
Member

Summary

This commit fixes an issue in the SabreLayout pass when run on backends with a disjoint connectivity graph. The SabreLayout pass internally runs routing as part of its operation and as a performance efficiency we use that routing output by default. However, in the case of a disjoint coupling map we are splitting the circuit up into different subcircuits to map that to the connected components on the backend. Doing final routing as part of that split context is no sound because depsite the quantum operations being isolated to each component, other operations could have a dependency between the components. This was previously discovered during the development of #9802 to be the case with classical data/bits, but since merging that it also has come up with barriers. To prevent any issues in the future this commit changes the SabreLayout pass to never use the routing output during the layout search when there is >1 connected component because we need to rerun routing on the full circuit after applying the layout.

Details and comments

Fixes #9995

This commit fixes an issue in the `SabreLayout` pass when run on
backends with a disjoint connectivity graph. The `SabreLayout`
pass internally runs routing as part of its operation and as a
performance efficiency we use that routing output by default. However,
in the case of a disjoint coupling map we are splitting the circuit up
into different subcircuits to map that to the connected components on
the backend. Doing final routing as part of that split context is no
sound because depsite the quantum operations being isolated to each
component, other operations could have a dependency between the
components. This was previously discovered during the development
of Qiskit#9802 to be the case with classical data/bits, but since merging
that it also has come up with barriers. To prevent any issues in the
future this commit changes the SabreLayout pass to never use the routing
output during the layout search when there is >1 connected component
because we *need* to rerun routing on the full circuit after applying
the layout.

Fixes Qiskit#9995
@mtreinish mtreinish requested a review from a team as a code owner April 20, 2023 14:33
@qiskit-bot
Copy link
Collaborator

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:

  • @Qiskit/terra-core

@mtreinish mtreinish added the Changelog: None Do not include in changelog label Apr 20, 2023
@mtreinish mtreinish added this to the 0.24.0 milestone Apr 20, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 4756578146

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 6 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.04%) to 85.941%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 2 91.14%
crates/accelerate/src/sabre_swap/layer.rs 4 97.32%
Totals Coverage Status
Change from base Build 4755986374: 0.04%
Covered Lines: 71096
Relevant Lines: 82727

💛 - Coveralls

@mtreinish mtreinish requested a review from kevinhartman April 20, 2023 17:20
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mtreinish mtreinish added this pull request to the merge queue Apr 20, 2023
Comment on lines +248 to +251
# We also skip routing here if there is more than one connected
# component we ran layout on. We can only reliably route the full dag
# in this case if there is any dependency between the components
# (typically shared classical data or barriers).
Copy link
Contributor

@jlapeyre jlapeyre Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unclear to me. What does this mean ?

there is more than one connected component we ran layout on

There are more than one connected components. Did we run layout on some of them?
Can we reliably route if there is a dependency or if there is no dependency?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the layout problem gets split up is a function of both the circuit and the coupling map. If the coupling map is disjoint and the circuit isn't we only run layout over a single connected component from the coupling map. The only case when we're not safe to execute routing as part of this pass is when we have more than one circuit component and coupling map component so that we run the inner layout function >1 time. In those cases there is a potential data dependency across the output from the split layout runs' connected components (which is the combination of the connected components from the circuit applied to connected components on the device) in the non-quantum component of the circuit.

Merged via the queue into Qiskit:main with commit b0db53c Apr 20, 2023
@mtreinish mtreinish deleted the handle-faulty-scheduling branch April 20, 2023 18:57
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
* Don't run routing in SabreLayout with split components

This commit fixes an issue in the `SabreLayout` pass when run on
backends with a disjoint connectivity graph. The `SabreLayout`
pass internally runs routing as part of its operation and as a
performance efficiency we use that routing output by default. However,
in the case of a disjoint coupling map we are splitting the circuit up
into different subcircuits to map that to the connected components on
the backend. Doing final routing as part of that split context is no
sound because depsite the quantum operations being isolated to each
component, other operations could have a dependency between the
components. This was previously discovered during the development
of Qiskit#9802 to be the case with classical data/bits, but since merging
that it also has come up with barriers. To prevent any issues in the
future this commit changes the SabreLayout pass to never use the routing
output during the layout search when there is >1 connected component
because we *need* to rerun routing on the full circuit after applying
the layout.

Fixes Qiskit#9995

* Remove unused shared_clbits logic

* Remove swap and routing assertions from disjoint sabre layout tests

* Fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Barrier replacement introduces cycle with disjoint coupling map
5 participants