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

More Schedule-ScheduleBlock integration #6444

Conversation

nkanazawa1989
Copy link
Contributor

@nkanazawa1989 nkanazawa1989 commented May 19, 2021

Summary

Currently the data representation of Schedule and ScheduleBlock are quite different and most of transform functions support only Schedule. 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 has data, 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 of Frozen (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.

with pulse.build() as sched:
    pulse.shift_phase(1.57, pulse.DriveChannel(0))
    pulse.play(pulse.Gaussian(160, 0.1, 40), pulse.DriveChannel(0))
    with pulse.align_right():
        pulse.play(pulse.Gaussian(80, 0.1, 20), pulse.DriveChannel(1))
        pulse.play(pulse.Gaussian(160, 0.3, 40), pulse.DriveChannel(0))
    pulse.shift_phase(1.57, pulse.DriveChannel(1))
    with pulse.align_sequential():
        pulse.play(pulse.Gaussian(80, 0.1, 20), pulse.DriveChannel(2))
        pulse.shift_phase(1.57, pulse.DriveChannel(0))
        pulse.play(pulse.Gaussian(160, 0.1, 40), pulse.DriveChannel(1))
    pulse.shift_phase(1.57, pulse.DriveChannel(0))

filt_sched = filters.filter_instructions(sched, filters.with_intervals([[0, 300]]))

type(filt_sched)  # qiskit.pulse.schedule.ScheduleBlock

Since all sched instructions have fixed duration, we can assign node time when the builder returns the root block. We can filter returned sched 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.

- add schedule node class to unify representation
- update builder logic
- add schedule_to_block with new alignment Frozen
- update pulse transofms to accept blocks
- update alignment logic not to depend on timeslots
@nkanazawa1989 nkanazawa1989 marked this pull request as draft May 19, 2021 19:44
@nkanazawa1989 nkanazawa1989 added the mod: pulse Related to the Pulse module label May 19, 2021
@nkanazawa1989
Copy link
Contributor Author

Closed because this is not right direction.

@nkanazawa1989 nkanazawa1989 deleted the dev/block-schedule-integration branch November 25, 2022 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: pulse Related to the Pulse module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant