Skip to content
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

Remove hard time limit from vf2 passes in preset passmanagers #8021

Merged
merged 3 commits into from
May 4, 2022

Conversation

mtreinish
Copy link
Member

Summary

This commit removes the hard time limit from the preset passmanager. We
were previously setting two limits on the pass a call_limit parameter,
which is used to set the limit of internal state visits the vf2
implementation in retworkx will attempt before giving up, and a time
limit which sets a hard wall time limit that is checked after each
mapping to ensure we don't spend more than a specific amount of time on
trying to find an optimal mapping. As subgraph isomorphism is
NP-complete we could spend a very large amount of time trying to find
the next isomorphic mapping and both these limits were set to avoid a
situation where we spend hours in optimization level 1 trying to find a
better layout. However, as we've seen in #8017 setting a hard time limit
limits the level of reproducibility on the output of the transpiler. It
means that setting a fixed seed is no longer sufficient to exactly
reproduce the output as it's also partially a function of the
performance of the local system we're running on. If the local
environment is slower we might get different results because we've hit
the hard time limit.

To address this, this commit removes the hard time limit so that we only
rely on the call limit parameter on the preset pass manager. While this
parameter is a bit more opaque in how it should be used because it
requires an understanding of how the VF2 algorithm works (and is
implemented in retworkx) it should be sufficient to avoid the runaway
execution problem but also means the limits are deterministically
applied. This should improve the reproducibility of the transpiler because
the pass will always try exactly up until a given point regardless of
how fast the local environment is.

For people manually instantiating the pass they can still rely on the
hard time limit parameter if they want it, but for the preset pass
managers and the transpile() function we no longer set this.

Details and comments

Fixes #8017

This commit removes the hard time limit from the preset passmanager. We
were previously setting two limits on the pass a call_limit parameter,
which is used to set the limit of internal state visits the vf2
implementation in retworkx will attempt before giving up, and a time
limit which sets a hard wall time limit that is checked after each
mapping to ensure we don't spend more than a specific amount of time on
trying to find an optimal mapping. As subgraph isomorphism is
NP-complete we could spend a very large amount of time trying to find
the next isomorphic mapping and both these limits were set to avoid a
situation where we spend hours in optimization level 1 trying to find a
better layout. However, as we've seen in Qiskit#8017 setting a hard time limit
limits the level of reproducibility on the output of the transpiler. It
means that setting a fixed seed is no longer sufficient to exactly
reproduce the output as it's also partially a function of the
performance of the local system we're running on. If the local
environment is slower we might get different results because we've hit
the hard time limit.

To address this, this commit removes the hard time limit so that we only
rely on the call limit parameter on the preset pass manager. While this
parameter is a bit more opaque in how it should be used because it
requires an understanding of how the VF2 algorithm works (and is
implemented in retworkx) it should be sufficient to avoid the runaway
execution problem but also means the limits are determinitisically
applied. This should improve the reproducability of the transpiler because
the pass will always try exactly up until a given point regardless of
how fast the local environment is.

For people manually instatiating the pass they can still rely on the
hard time limit parameter if they want it, but for the preset pass
managers and the transpile() function we no longer set this.

Fixes Qiskit#8017
@mtreinish mtreinish requested a review from a team as a code owner May 4, 2022 14:40
@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

@coveralls
Copy link

coveralls commented May 4, 2022

Pull Request Test Coverage Report for Build 2270937180

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.008%) to 84.349%

Files with Coverage Reduction New Missed Lines %
qiskit/transpiler/passes/layout/vf2_post_layout.py 2 96.28%
qiskit/pulse/library/waveform.py 3 89.36%
Totals Coverage Status
Change from base Build 2270133073: -0.008%
Covered Lines: 54476
Relevant Lines: 64584

💛 - Coveralls

@mtreinish mtreinish added Changelog: API Change Include in the "Changed" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog labels May 4, 2022
@mtreinish mtreinish added this to the 0.21 milestone May 4, 2022
@mergify mergify bot merged commit f1f078b into Qiskit:main May 4, 2022
@mtreinish mtreinish deleted the drop-hard-time-limit branch May 4, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-deterministic test failures in CI test_layout_tokyo
4 participants