-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix custom constraints in transpile
with BackendV2
#12042
Conversation
…anspile and BackendV2.
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 8418045790Warning: 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 |
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 LGTM, just one small question inline.
I have updated the PR to:
After these changes the table looks like this:
To test the custom |
82e9706
to
45129a6
Compare
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 LGTM now, thanks for fixing this. Before I hit automerge though do you think we should put your table in the docstring? It might be a good idea to make the priority ranking of different combinations of arguments more explicit since it seems to confuse everyone frequently.
transpile
with BackendV2
transpile
with BackendV2
Added an explanation + table in 856efc4 |
Co-authored-by: Matthew Treinish <[email protected]>
I ended up adding one more sentence in 05a8240 explaining the table, because the formatting wasn't on my side (I wanted the left column to be in bold font but it looks like I cannot choose how the table is formatted, or I don't know how to). |
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.
LGTM, thanks for updating the docs. This will be a good test of our stability policy in 1.1.0 as we've described this as a bugfix because the code behavior was different from the documented API. The backend
argument docs said:
If any other option is explicitly set (e.g.,
coupling_map
), it
will override the backend's.
But let's see if any users complain about an API change, because the exact behavior if you call transpile(qc, backend_v2, dt=5.2)
differs between 1.0.x and 1.1.x. I think in this case we're fine because we've documented the API stability policy as applying to our documented API surface and this was really a consistency issue between the handling of BackendV1
and BackendV2
.
Summary
This PR proposes a fix for the issue raised in #11994, where custom scheduling constraints would be ignored when a
BackendV2
backend was provided totranspile
. This happened because the underlying passes prioritize the information encoded in the target over user-provided information, which would set a clear order of priorities withBackendV1
:custom target constraints>custom input constraints>backend constraints
, but a not so clear one withBackendV2
, wherecustom target constraints
andbackend target constraints
would be treated both as "target constraints", leading to the backend constraints always overriding the custom input ones.The proposed solution is to extend the approach already used for custom
coupling_map
s andbasis_gates
: setting the_skip_target
flag toTrue
in these cases. This way, the priority order already established forBackendV1
inputs will be maintained for target-based backends:custom target > custom individual constraints > backend.target
Details and comments
transpile
are the same for v1 and v2 backends are intest_transpiler.py
, which I believe makes sense, because this PR is at the intersection of the scheduling passes and thetranspiler
interface.transpile
to change when transitioning to v2, but let me know if you disagree.transpile()
to convertBackendV1
inputs toBackendV2
withBackendV2Converter
#11996