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

Rework handling of instruction durations in preset pass managers #12183

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

ElePT
Copy link
Contributor

@ElePT ElePT commented Apr 15, 2024

Summary

This PR fixes #10449 by removing the "hack" in transpile that handled the priority order of different sources of InstructionDurations in scheduling passes. The passes now analyze the dag calibrations and set the relevant value themselves, which allows for a much easier use of the standalone passes.

I believe that the change in line 412 (where num_processes wasn't used) was a bug that also got fixed in this PR, unless I am missing something.

Details and comments

Connected to #9256.

@ElePT ElePT requested a review from a team as a code owner April 15, 2024 14:14
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@@ -51,6 +51,7 @@ def __init__(self, inst_durations: InstructionDurations = None, target: Target =
self.inst_durations = inst_durations or InstructionDurations()
if target is not None:
self.inst_durations = target.durations()
self._durations_provided = inst_durations is not None or target is not None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this extra variable because unlike the other passes, this instantiates an empty InstructionDurations.

@coveralls
Copy link

coveralls commented Apr 15, 2024

Pull Request Test Coverage Report for Build 8875014693

Warning: 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

  • 43 of 48 (89.58%) changed or added relevant lines in 4 files are covered.
  • 899 unchanged lines in 76 files lost coverage.
  • Overall coverage increased (+0.08%) to 89.441%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/transpiler/passes/scheduling/dynamical_decoupling.py 9 14 64.29%
Files with Coverage Reduction New Missed Lines %
qiskit/circuit/library/standard_gates/r.py 1 97.62%
qiskit/transpiler/target.py 1 93.74%
crates/qasm2/src/expr.rs 1 94.03%
qiskit/primitives/backend_sampler_v2.py 1 99.21%
qiskit/circuit/library/generalized_gates/permutation.py 1 93.1%
qiskit/primitives/containers/data_bin.py 1 97.92%
qiskit/circuit/library/standard_gates/rxx.py 1 97.44%
qiskit/circuit/library/standard_gates/u2.py 1 96.67%
qiskit/circuit/library/standard_gates/rzx.py 1 97.44%
qiskit/quantum_info/operators/operator.py 1 94.94%
Totals Coverage Status
Change from base Build 8689749566: 0.08%
Covered Lines: 60944
Relevant Lines: 68139

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this LGTM, it's a pretty straightforward fix just inlining the logic from transpile() in the passes that actually need it. I just had some questions about release notes.

@@ -0,0 +1,11 @@
---
features_transpiler:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this more of a fix than a feature? At a high level this change doesn't feel like a user facing feature to document on the release. Or are you thinking that for using the individual passes in isolation this is a new feature that you can have the pass handle the durations in the circuit on their own?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that, I found the change somewhere in between a feature and a bugfix, it does change the behavior of the individual passes but probably to the behavior that would have been expected anyways, so I'm fine changing it to a fix.

@@ -453,7 +409,7 @@ def callback_func(**kwargs):
optimization_method=optimization_method,
_skip_target=_skip_target,
)
out_circuits = pm.run(circuits, callback=callback)
out_circuits = pm.run(circuits, callback=callback, num_processes=num_processes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should have a fix release note for this? This argument totally wouldn't ever work before, we were setting the flag in the single process path and we weren't setting the argument when the call could be multiprocess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 250ff77

@ElePT ElePT added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Apr 29, 2024
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick updates.

@mtreinish mtreinish added this pull request to the merge queue Apr 29, 2024
Merged via the queue into Qiskit:main with commit 393524f Apr 29, 2024
13 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rework handling of instruction durations in preset pass managers
5 participants