More Schedule-ScheduleBlock integration #6444
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Currently the data representation of
Schedule
andScheduleBlock
are quite different and most of transform functions support onlySchedule
. Thus we always need to convert block to schedule before using these transforms. This conversion is irreversible and we lost alignment context due to this conversion.This PR attempts to introduce
ScheduleNode
that hasdata, time, location
as variable. With this we can redefine block (schedule) as a sequence of node with unassigned (assigned) node time. Note that we are still able to assign time to the nodes of the blocks (if all node durations are fixed), and we can schedule the block while keeping the alignment context. Thus we can use most of transformation function without converting it into schedule.Note that we can update node time and node data (i.e. node is mutable object) without breaking the structure of schedule. Since each node is managed by unique
location
(uuid4) id.This also unifies representation of schedule and block. Thus we can add
schedule_to_block
conversion with a special context ofFrozen
(this doesn't perform alignment but returns node sequence as-is since it's already scheduled).Now the builder can return time-assigned nodes if possible.
Details and comments
This is an example of what can be done with this PR.
Since all
sched
instructions have fixed duration, we can assign node time when the builder returns the root block. We can filter returnedsched
by time interval without converting it into a schedule.Comments:
Still this PR has lots of bugs and there is no unittest for transform of schedule block. Before going into detailed design and bug fixes, I'd like to hear feedback about this approach. If this doesn't make sense I'll just close this PR. It seems like we can completely integrate schedule and block at some point.
Since this is large PR it might be efficient to start from
qiskit/pulse/schedule.py
to grasp rough framework of this PR.