-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix ignored errors/durations in generate_preset_pass_manager
if dt
is set
#14065
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
Conversation
One or more of the following people are relevant to this code:
|
…er target to reset internal instruction_durations value so that new dt can be taken into account
qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py
Outdated
Show resolved
Hide resolved
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.
Thanks for diving into the details on this and fixing it, I just have a few inline comments.
qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py
Outdated
Show resolved
Hide resolved
tqc = transpile( | ||
qc, backend=backend, seed_transpiler=4242, callback=callback, dt=backend.dt * 2 | ||
) | ||
self.assertTrue(vf2_post_layout_called) | ||
self.assertEqual([2, 1, 0], _get_index_layout(tqc, qubits)) |
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.
I think to test this we either should run transpile twice once with a custom dt once with out and assert the layouts are the same providing indication that we've got the same error rates for both runs.
Or alternatively we could probably test this more directly by building a preset pass manager and poking the internals of one of the passes to assert the target has the expected error rates.
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Pull Request Test Coverage Report for Build 13995670918Warning: 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 |
qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py
Outdated
Show resolved
Hide resolved
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.
Thanks for the update. I'm mildly concerned that the test will be fragile longer term because we're indirectly testing the root cause of the bug here. But at the end of the day I don't think it's likely to cause an issue and the test would catch the regression even if it's indirect.
…` is set (#14065) * Fix dt oversight in generate_preset_pass_manager * Update warning to mention explicitly the invalidation of custom durations and error rates. * Do not overwrite original backend values inside transpile, iterate over target to reset internal instruction_durations value so that new dt can be taken into account * One iteration is enough to reset the value of self._instruction_durations * Estimate duration instead of hardcoding it * Apply suggestion from Matt's code review Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Fix example * Move cache invalidation to target dt setter. * Add reno --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> (cherry picked from commit 6ce7788)
…` is set (#14065) (#14098) * Fix dt oversight in generate_preset_pass_manager * Update warning to mention explicitly the invalidation of custom durations and error rates. * Do not overwrite original backend values inside transpile, iterate over target to reset internal instruction_durations value so that new dt can be taken into account * One iteration is enough to reset the value of self._instruction_durations * Estimate duration instead of hardcoding it * Apply suggestion from Matt's code review Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Fix example * Move cache invalidation to target dt setter. * Add reno --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> (cherry picked from commit 6ce7788) Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Summary
#14056 (comment) reported an unexpected behavior of
generate_preset_pass_manager
where setting a customdt
would invalidate the backend's gate durations and error rates. This was due to an oversight in #9256 , where a custom target would be built from scratch usingTarget.from_configuration
whenever any loose constraint was set, and any information regarding instruction properties would be lost. This was intentional forcoupling_map
andbasis_gates
, as they modify the target gate map, but not necessary fordt
, where the target could be kept and simply updated.This PR fixes this use case, adds a test with vf2 + dt, and modifies the user warning to explicitly communicate what will happen with gate durations and errors if
coupling_map
orbasis_gates
are set with abackend
.Details and comments
The changelog is None as #9256 has not been released yet.