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

Adds a simple scheduler that just follows the moment structure. #78

Merged
merged 4 commits into from
Feb 13, 2018
Merged

Adds a simple scheduler that just follows the moment structure. #78

merged 4 commits into from
Feb 13, 2018

Conversation

dabacon
Copy link
Collaborator

@dabacon dabacon commented Feb 9, 2018

I think this will be useful at is a very simple conceptual scheduler.

Copy link
Contributor

@Strilanc Strilanc left a comment

Choose a reason for hiding this comment

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

A few minor nits. Otherwise LGTM.

device.validate_scheduled_operation(schedule, scheduled_op)
# Increment time for next moment by max of ops during this moment.
max_duration = max((device.duration_of(op) for op in moment.operations),
key=Duration.total_picos)
Copy link
Contributor

Choose a reason for hiding this comment

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

Duration implements comparison operations, so this key argument should be unnecessary.

t += max(device.duration_of(op) for op in moment.operations)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Funny I tried that and if failed but now it works. ¯_(ツ)_/¯

schedule = Schedule(device)
t = Timestamp()
for moment in circuit.moments:
if len(moment.operations) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

if not moment.operations:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

schedule = schedulers.moment_schedule(device, circuit)

zero_ns = Timestamp()
second = Timestamp(nanos=20)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call it a tick instead of a "second".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ha that is "second" as in "2nd" not the time. Changed to twenty_ns

from cirq.time import Timestamp


def moment_schedule(device: Device, circuit: Circuit):
Copy link
Contributor

Choose a reason for hiding this comment

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

Name is okay, but not great. Maybe moment_by_moment_schedule?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@dabacon dabacon merged commit 427ffd4 into quantumlib:master Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants