-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Do not run VF2PostLayout in level 3 if layout args are set #14869
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
base: main
Are you sure you want to change the base?
Conversation
One or more of the following people are relevant to this code:
|
This commit fixes a bug in the construction of the preset pass manager for optimization level 3. In Qiskit 2.1.0 we started running the VF2PostLayout pass in strict mode at the end of the optimization stage. However when that was added it neglected to have a check that the user didn't specify an explicit layout with the `initial_layout` argument or a specific layout method be used with the `layout_method` argument. This meant even though the user requested a specific layout or layout technique the preset pass managers would ignore that setting and VF2PostLayout would potentially pick a different layout. This commit fixes this by only running the VF2PostLayout pass if these settings are not used. Fixes Qiskit#14867
def test_level3_does_not_run_vf2post_layout_when_layout_method_set(self): | ||
"""Test that level 3 does not run VF2PostLayout when layout_method is set.""" | ||
target = GenericBackendV2( | ||
num_qubits=7, | ||
basis_gates=["cx", "id", "rz", "sx", "x"], | ||
coupling_map=LAGOS_CMAP, | ||
seed=42, | ||
) | ||
_target = target.target | ||
target._target.add_instruction(ForLoopOp, name="for_loop") | ||
qc = QuantumCircuit(4) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.cx(0, 2) | ||
qc.cx(0, 3) | ||
with qc.for_loop((1,)): | ||
qc.cx(0, 1) | ||
qc.measure_all() | ||
_ = transpile( | ||
qc, target, optimization_level=1, callback=self.callback, layout_method="dense" | ||
) | ||
self.assertIn("SetLayout", self.passes) | ||
self.assertNotIn("VF2Layout", self.passes) | ||
self.assertNotIn("SabreLayout", self.passes) | ||
self.assertNotIn("VF2PostLayout", self.passes) | ||
self.assertIn("DenseLayout", self.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.
This one is slightly more questionable to me. I guess it's consistent with what we already have, though gating the layout-improvement logic in the optimisation stage as being dependent on the layout stage being default
feels weird.
I think we should leave it as written, it just makes me question our current configuration methods a bit.
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.
This is the logic that the pass manager exhibits today. The idea is more if you request an explicit layout method the transpiler should run that method and nothing else. For example, if you said sabre the idea is that it only runs sabre and never vf2 layout. I guess it's more questionable for vf2 post layout case because it runs after the layout stage and the layout_method
argument is nominally for which plugin to use. But I think this behavior predates the staged pass manager and the plugin interface.
releasenotes/notes/vf2post-no-opt-if-layout-opt-set-b9998e4ba8c5280f.yaml
Show resolved
Hide resolved
Pull Request Test Coverage Report for Build 16910437198Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
…l 3 (Qiskit#14120)" This temporarily reverts commit a8d2366 due to multiple bugs found around the implementation see Qiskit#14867 and Qiskit#14869. Sincefixing the bugs will have a large impact on the transpilation results it is better to just disable it and save the runtime overhead which has been reported in a few places (see Qiskit#14855 and the end of the discussion in Qiskit#14653). This functionality will be fixed in 2.2.0 and re-enabled there, but for the rest of the 2.1.x release series we should just leave it disabled.
…l 3 (#14120)" (#14905) * Revert "Added VF2PostLayout at the end of optimization stage for level 3 (#14120)" This temporarily reverts commit a8d2366 due to multiple bugs found around the implementation see #14867 and #14869. Sincefixing the bugs will have a large impact on the transpilation results it is better to just disable it and save the runtime overhead which has been reported in a few places (see #14855 and the end of the discussion in #14653). This functionality will be fixed in 2.2.0 and re-enabled there, but for the rest of the 2.1.x release series we should just leave it disabled. * Apply suggestions from code review Co-authored-by: Jake Lishman <jake@binhbar.com> --------- Co-authored-by: Jake Lishman <jake@binhbar.com>
Summary
This commit fixes a bug in the construction of the preset pass manager for optimization level 3. In Qiskit 2.1.0 we started running the VF2PostLayout pass in strict mode at the end of the optimization stage. However when that was added it neglected to have a check that the user didn't specify an explicit layout with the
initial_layout
argument or a specific layout method be used with thelayout_method
argument. This meant even though the user requested a specific layout or layout technique the preset pass managers would ignore that setting and VF2PostLayout would potentially pick a different layout. This commit fixes this by only running the VF2PostLayout pass if these settings are not used.Details and comments
Fixes #14867