Replace AlignMeasures with ConstrainedReschedule for pulse alignment#7762
Conversation
New pass considers both pulse and acquire alignment constraints, thus it is a drop-in-replacement of the AlignMeasures. Note that ordering of passes in the preset pass managers is updated because new pass is implemented as analysis pass, that only updates `node_start_time` in the property set, thus it should be executed before the padding passes.
ajavadia
left a comment
There was a problem hiding this comment.
looks good. needs some tests
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
4b6af59 to
c0dcd43
Compare
ajavadia
left a comment
There was a problem hiding this comment.
the PR looks good to me now. but it contains no new tests. is everything here covered by previous tests?
…verlap in rescheduler.
…989/qiskit-terra into upgrade/alignment-to-analysis
…y them to circuit attributes. Schedulign passes are combined in a single ``scheduling`` folder.
Pull Request Test Coverage Report for Build 2024560948
💛 - Coveralls |
|
Now unittests are updated and the PR is ready for final review. I noticed reschedule pass also needs classical I/O latency information to compute correct node start/end time of instructions acting on classical registers. These are already covered by existing test case in This makes me think adding latencies in the property set is better approach, rather than setting values in the constructor of every pass. Constructor values tend to have poor documentation (because developer just copies value without doc, or sometimes forget to update all docs synchronously, etc...) and to make pass API unstable since we didn't decide spec for these values. Instead, I introduced |
4d99832 to
40900b1
Compare
40900b1 to
6d8dc28
Compare
ajavadia
left a comment
There was a problem hiding this comment.
looks good to go basically, just a small question about how SetIOLatency gets called.
| pm0.append( | ||
| InstructionDurationCheck( | ||
| acquire_alignment=timing_constraints.acquire_alignment, | ||
| pulse_alignment=timing_constraints.pulse_alignment, | ||
| ) | ||
| ) | ||
| pm0.append( | ||
| ConstrainedReschedule( | ||
| acquire_alignment=timing_constraints.acquire_alignment, | ||
| pulse_alignment=timing_constraints.pulse_alignment, | ||
| ), | ||
| condition=_require_alignment, | ||
| ) | ||
| pm0.append( | ||
| ValidatePulseGates( | ||
| granularity=timing_constraints.granularity, | ||
| min_length=timing_constraints.min_length, | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Shouldn't SetIOLatency be part of preset passmanagers at levels 0-3?
There was a problem hiding this comment.
It should be but currently the backend data fields are both empty. We don't have any spec for values, i.e. they might be qubit dependent, or a single-value per system, or something else. We can come back to this once we define the format. We can minimize the impact of this unstable API since everything is internal code now.
| [ | ||
| SetIOLatency(clbit_write_latency=1000), | ||
| ASAPSchedule(durations), | ||
| PadDelay(), | ||
| ] |
There was a problem hiding this comment.
Alternatively you could add SetIOLatency to the self.requires of ASAPSchedule and ALAPSchedule which guarantees that the i/o information is available to them.
There was a problem hiding this comment.
That sounds like a good plan. I'll keep this in mind.
ajavadia
left a comment
There was a problem hiding this comment.
ok this looks good to me. there is a merge conflict right now but i'm good to merge after that is fixed.
5a4a4b6 to
6d8dc28
Compare
|
Sorry seems like I messed up CLA. I think I've fixed the wrong commit. The last commit is to move paddings to own module as what I've done for other two modules, since we have merged #7760 . |
…asses In Qiskit#7762 the scheduling passes in the transpiler were completely rewritten to operate in a model where scheduling and alignment happen as metadata on the circuit until a single padding pass is called to adapt the circuit to fit the scheduling metadata. As part of that rework a new pass ConstrainedReschedule was added to perform the alignment for measurement as well as all instructions via this new mechanism. However the way the migration was done was a breaking change and should have been additive so that we can deprecate the old path in 0.21 and allow users time to migrate to the new approach. Additionally as part of Qiskit#7762 the AlignMeasures pass was deprecated and its implementation was replaced with just returning an equivalent ConstraintedReschedule pass. This was problematic for two reasons though, first the two passes were not equivalent and this a breaking change and second it violates the deprecation policy. For the breaking change the AlignMeasures and ConstrainedReschedule while performing the same function do it in a different manner. I assume the deprecation was done this way because AlignMeasures is incompatible with the While the scheduling pass changes were also breaking to do the migration gracefully would require duplicating their functionality and deprecating the old This is also violating the deprecation policy which is defined here: https://qiskit.org/documentation/contributing_to_qiskit.html#deprecation-policy as the alternative wasn't available for a release prior to the start of the deprecation (see 2a in the above link). This commit adds back the breaking classes and renames the new scheduling classes ALAPScheduleAnalysis and ASAPScheduleAnalysis to differentiate them from the previous implementations. This also reverts the deprecation and changes to the AlignMeasures pass until we can do it correctly at the appropriate time. The class is restored to its previous state but instead a PendingDeprecationWarning is now emitted to warn users of the pending deprecation and removal of the class. Additionally, a warning in the release notes will be added as part of Qiskit#7828 to document the incompatibility with the new behavior of the scheduling and alignment passes.
…asses (#7835) * Revert deprecation and breaking changes of scheduling and alignment passes In #7762 the scheduling passes in the transpiler were completely rewritten to operate in a model where scheduling and alignment happen as metadata on the circuit until a single padding pass is called to adapt the circuit to fit the scheduling metadata. As part of that rework a new pass ConstrainedReschedule was added to perform the alignment for measurement as well as all instructions via this new mechanism. However the way the migration was done was a breaking change and should have been additive so that we can deprecate the old path in 0.21 and allow users time to migrate to the new approach. Additionally as part of #7762 the AlignMeasures pass was deprecated and its implementation was replaced with just returning an equivalent ConstraintedReschedule pass. This was problematic for two reasons though, first the two passes were not equivalent and this a breaking change and second it violates the deprecation policy. For the breaking change the AlignMeasures and ConstrainedReschedule while performing the same function do it in a different manner. I assume the deprecation was done this way because AlignMeasures is incompatible with the While the scheduling pass changes were also breaking to do the migration gracefully would require duplicating their functionality and deprecating the old This is also violating the deprecation policy which is defined here: https://qiskit.org/documentation/contributing_to_qiskit.html#deprecation-policy as the alternative wasn't available for a release prior to the start of the deprecation (see 2a in the above link). This commit adds back the breaking classes and renames the new scheduling classes ALAPScheduleAnalysis and ASAPScheduleAnalysis to differentiate them from the previous implementations. This also reverts the deprecation and changes to the AlignMeasures pass until we can do it correctly at the appropriate time. The class is restored to its previous state but instead a PendingDeprecationWarning is now emitted to warn users of the pending deprecation and removal of the class. Additionally, a warning in the release notes will be added as part of #7828 to document the incompatibility with the new behavior of the scheduling and alignment passes. * More release note fixes * Fix lint * Fix docs * Fix doc whitespace * Update dynamical decoupling release note * Copy docstrings from pre-refactor to fix docs build * Add back test coverage for legacy scheduling and alignment passes * Update releasenotes/notes/update-instruction-alignment-passes-ef0f20d4f89f95f3.yaml Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com> * Fix release notes * Rename base scheduler class in legacy path This commit renames the BaseScheduler class in the legacy scheduling path to BaseSchedulerTransform to differentiate it from the new path scheduling paths. It also documents the pending deprecation in all the legacy scheduling passes to point people to the new scheduling workflow. * Rename DynamicalDecouplingPadding to PadDynamicalDecoupling Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This PR introduces new pass
ConstrainedReschedule(name should be discussed) which is a drop-in-replacement ofAlignMeasurespass. New pass takes both pulse and acquire alignment constraints thus it guarantees your circuit is executable on recent IBM Quantum backend with non-"1" pulse alignment constraint.Details and comments
ConstrainedRescheduleis implemented asAnalysisPass, which updatesnode_start_timedictionary in the property set. This is follow-up of #7709 and necessary for #7760 . Note that this pass doesn't regenerate DAG instance, thus performance of scheduling chain will be improved. The pass ordering of preset pass managers has been also updated.old, at #7709:
scheduling (analysis) -> padding (transform) -> alignment (transform)new:
scheduling (analysis) -> alignment (analysis) -> padding (transform)TODO