Skip to content

Restore correct max_trials behaviour for VF2Layout pass #14667

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

Merged
merged 3 commits into from
Jul 7, 2025

Conversation

mtreinish
Copy link
Member

Summary

The VF2Layout pass is documented as setting a trial limit equivalent to the being based on the number of edges of the interaction or connectivity graph. Additionally it supports being a negative value to run unbounded. However, when vf2 layout was ported to rust in #14056 this behavior was not preserved. It was not able to handle negative values and also a value of None was treated as unbounded. This commit corrects these oversights so the argument to the pass is handled correctly as documented.

Details and comments

The VF2Layout pass is documented as setting a trial limit equivalent to
the being based on the number of edges of the interaction or connectivity
graph. Additionally it supports being a negative value to run unbounded.
However, when vf2 layout was ported to rust in Qiskit#14056 this behavior was
not preserved. It was not able to handle negative values and also a
value of None was treated as unbounded. This commit corrects these
oversights so the argument to the pass is handled correctly as
documented.
@mtreinish mtreinish added this to the 2.1.1 milestone Jun 26, 2025
@mtreinish mtreinish requested a review from a team as a code owner June 26, 2025 00:20
@mtreinish mtreinish added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: transpiler Issues and PRs related to Transpiler labels Jun 26, 2025
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Jun 26, 2025

Pull Request Test Coverage Report for Build 15950055131

Details

  • 24 of 25 (96.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.08%) to 87.76%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/transpiler/src/passes/vf2/vf2_layout.rs 24 25 96.0%
Files with Coverage Reduction New Missed Lines %
crates/circuit/src/symbol_expr.rs 1 73.69%
crates/transpiler/src/passes/vf2/vf2_layout.rs 1 91.35%
crates/qasm2/src/lex.rs 2 92.01%
Totals Coverage Status
Change from base Build 15925725626: 0.08%
Covered Lines: 81082
Relevant Lines: 92391

💛 - Coveralls

The previous version of the tests in this module didn't set the seed
correctly, so the rust component was not run. Similarly, the tests
didn't cover the strict direction path. This commit corrects both
oversights so the tests added in this PR cover the fix.
@1ucian0 1ucian0 added this pull request to the merge queue Jul 7, 2025
Merged via the queue into Qiskit:main with commit 6e4d83c Jul 7, 2025
26 checks passed
mergify bot pushed a commit that referenced this pull request Jul 7, 2025
* Restore correct max_trials behaviour for VF2Layout pass

The VF2Layout pass is documented as setting a trial limit equivalent to
the being based on the number of edges of the interaction or connectivity
graph. Additionally it supports being a negative value to run unbounded.
However, when vf2 layout was ported to rust in #14056 this behavior was
not preserved. It was not able to handle negative values and also a
value of None was treated as unbounded. This commit corrects these
oversights so the argument to the pass is handled correctly as
documented.

* Improve tests

The previous version of the tests in this module didn't set the seed
correctly, so the rust component was not run. Similarly, the tests
didn't cover the strict direction path. This commit corrects both
oversights so the tests added in this PR cover the fix.

(cherry picked from commit 6e4d83c)
github-merge-queue bot pushed a commit that referenced this pull request Jul 7, 2025
)

* Restore correct max_trials behaviour for VF2Layout pass

The VF2Layout pass is documented as setting a trial limit equivalent to
the being based on the number of edges of the interaction or connectivity
graph. Additionally it supports being a negative value to run unbounded.
However, when vf2 layout was ported to rust in #14056 this behavior was
not preserved. It was not able to handle negative values and also a
value of None was treated as unbounded. This commit corrects these
oversights so the argument to the pass is handled correctly as
documented.

* Improve tests

The previous version of the tests in this module didn't set the seed
correctly, so the rust component was not run. Similarly, the tests
didn't cover the strict direction path. This commit corrects both
oversights so the tests added in this PR cover the fix.

(cherry picked from commit 6e4d83c)

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@mtreinish mtreinish deleted the fix-max-trials-vf2 branch August 7, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: transpiler Issues and PRs related to Transpiler stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants