qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

add controlflow handling to Layout2qDistance transpiler pass

Open ewinston opened this issue 3 years ago • 4 comments

Summary

This pr adds controlflow handling to the Layout2qDistance transpiler pass.

Details and comments

This implementation adds an init parameter weight_loops to indicate whether the number of blocks/loops should contribute to the overall 2q layout score. If True for while loops, NaN is returned.

ewinston avatar Sep 12 '22 21:09 ewinston

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

qiskit-bot avatar Sep 12 '22 21:09 qiskit-bot

Pull Request Test Coverage Report for Build 3040745492

  • 26 of 29 (89.66%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 84.309%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/passes/layout/layout_2q_distance.py 26 29 89.66%
<!-- Total: 26 29
Totals Coverage Status
Change from base Build 3039251673: 0.005%
Covered Lines: 57854
Relevant Lines: 68621

💛 - Coveralls

coveralls avatar Sep 12 '22 22:09 coveralls

I tend to agree, the 2q distance does seem like overkill for determining that a trivial layout is perfect. CheckMap is more than enough to determine if the trivial layout is enough and should be faster. I'm not sure the history on the use of Layout2qDistance for this either, I never really questioned its usage when I touched the layout path code in the past, but from my perspective making that switch in level1 makes the most sense to me. (it's not used in level 2 or 3 because vf2layout does the checking for us)

mtreinish avatar Sep 23 '22 13:09 mtreinish

On its own this pass proposes to score the quality of a layout in a reasonable way. Whether or not other passes use this analysis is a somewhat separate issue, although it doesn't seem like anything in terra currently use this information in a way that can't be replaced by CheckMap as pointed out.

In the case of level1 it seems fine to replace this pass with CheckMap, put this PR on hold, and perhaps deprecate the pass.

ewinston avatar Sep 23 '22 15:09 ewinston