-
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
Split scheduling pass into scheduling and padding #7709
Conversation
Now functionality of scheduling pass is split into two pieces; scheduling (analysis) and padding (transform). In between these operations, one can insert non-transform operation such as alignment (i.e. reschedule).
a2a37f2
to
ce62a52
Compare
releasenotes/notes/0.18/dynamical-decoupling-3ce6e882954f6d3b.yaml
Outdated
Show resolved
Hide resolved
Pull Request Test Coverage Report for Build 1961014800
💛 - Coveralls |
4179c04
to
b4277f4
Compare
b4277f4
to
7f3a263
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.
I agree with the direction splitting out the padding part from scheduling passes so that we can remove the overhead of creating new DAG multiple times (e.g. ASAPSchedule and AlignMeasure) in the future.
For its implementation, I think we need more discussion on what should be stored in property_set
by the new ASAP/ALAPSchedule analysis pass. Currently, "start times" are stored as a dict {node: t0 (start time)}. However, the t0 information seems essentially not used in the newly implemented BasePadding
pass. I'm thinking the minimal data to be stored may be "idle slots", i.e. (prev_node, node(next_node), duration), and t0 of the node is supplemental information that could be ignored in rescheduling passes such as AlignMeasure. What do you think?
I've left other minor comments and suggestions inline.
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
- rename timeslot - remove redundant sort
7ef508b
to
5ae1629
Compare
Thanks @itoko! It might be hard to grasp the entire picture of the refactoring only with this PR, but align measure and align pulse are the constraints on t0. The main target of I was also thinking to store (t0, t1) tuple in the property set, but I decided to store only t0 since t1 = t0 = node.duration (having both is bit redundant). |
Oh, I missed that. You're right. Alignment constraints are about t0 (not duration), so we need to store t0s even if it is not directly used in Padding passes. Also, not storing t1 (and prev_node as well) sounds reasonable to me. |
# Note that some transformation pass can override .op attribute of DAGOpNode | ||
# without breaking the reference to object. However, once operation is updated, | ||
# there is no guarantee that the duration of node is unchanged. | ||
key = node.name, node.sort_key, getattr(node, "_node_id") | ||
node_start_time[key] = t0 |
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.
Uhm, this is a tricky problem.. I'd like to hear more opinion on how to address this issue. I personally prefer to simply using DAGOpNode
instance as a key here (i.e. give up to raise an error when someone updates node.op without updating node itself) and notify that users should not update DAG before using note_start_time
property in docstrings.
Also, I'm not sure if the current key can always track the update of the node. For example, what happens if only the params are replaced in node.op?
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 understand your point. This code is indeed not robust to the future change of node data structure. I guess the mutability of node.op is due to performance of the Unroller
node, which is likely intentional and a pass manager designer must take care for the arrangement of passes. In that sense, the padding pass here can also take node as-is rather than decomposing it for the key, and let the designer carefully choose the order of passes.
- remove duration from property set - documentation update
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.
Minor comments on comments
releasenotes/notes/upgrade-convert-scheduling-passes-to-analysis-04333b6fef524d21.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
53de3ed
to
35a49bd
Compare
- replace start time dict key with node, unittest is dropped - handle edge case for delay at the very end Previously, the maximum circuit duration is generated and attached at scheduler pass. However, this duration may change in the alignment pass, the duration is dropped from the property set and re-evaluated in the padding pass. However, if user intentionally insert delay at the end of circuit, this is just ignored and circuit duration cannot be estimated properly. In this commit, new logic considers the circuit duration when the last node is delay.
Co-authored-by: Toshinari Itoko <15028342+itoko@users.noreply.github.com>
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.
Thank you for the updates, @nkanazawa1989. LGTM now.
I approve without adding automerge tag so that you could ask one more final check from other reviewers as this PR includes a big design change.
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 taking this on @nkanazawa1989 and @itoko . The approach here LGTM.
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.
small comments mostly on docstrings
releasenotes/notes/upgrade-convert-scheduling-passes-to-analysis-04333b6fef524d21.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/upgrade-convert-scheduling-passes-to-analysis-04333b6fef524d21.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
…is-04333b6fef524d21.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
…is-04333b6fef524d21.yaml Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
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
Now functionality of scheduling pass is split into two pieces; scheduling (analysis) and padding (transform). In between these operations, one can insert non-transform operation such as alignment (i.e. reschedule).
Summary
This PR splits functionality of scheduling passes into scheduling (analysis) and padding (transform). This is beneficial since one can interleave alignment passes, i.e. rescheduling, in between these operation without regenerating DAG. In addition, scheduling operation creates
time_slot
dictionary in the property set of the pass manager. This allows us to easily track instruction start time without accumulating instruction duration from the begging of the DAG wire.Details and comments
Note that this is breaking API change since now scheduling passes insert no delay. In addition, consecutive delays are now merged into a single delay, which is necessary to correctly evaluate alignment constraints (will be in follow-up PR). Because it is not easy to dynamically switch base class (analysis -> transform pass) just for backward compatibility (technically possible though), current approach is to allow this API change and to write enough information in the release note. Since scheduling pass is used only in the specific situation (e.g. noisy circuit simulation, evaluation of alignment constraints, dynamical decoupling), the impact of this change is expected to be limited.