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

Add async methods to AbstractEngine and AbstractJob #5555

Merged
merged 15 commits into from Jul 12, 2022

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Jun 17, 2022

This adds abstract async run_* methods to AbstractEngine, AbstractProcessor, and AbstractJob, with duet.sync wrappers to preserve the current sync API. This requires a new version of duet to support duet.sync on abstract methods.

Also modified the underlying cirq.Sampler base class to support either implementing run_sweep in terms of run_sweep_async or the other way around, depending on whether the underlying sampler supports asynchrony with futures, e.g. if it makes calls to a remote service.

@CirqBot CirqBot added the size: L 250< lines changed <1000 label Jun 17, 2022
@maffoo maffoo added area/async and removed size: L 250< lines changed <1000 labels Jun 17, 2022
@CirqBot CirqBot added the size: L 250< lines changed <1000 label Jun 17, 2022
@maffoo maffoo force-pushed the u/maffoo/abstract-engine-async branch 2 times, most recently from 8d70ffc to 2a36c26 Compare June 22, 2022 21:42
@maffoo maffoo force-pushed the u/maffoo/abstract-engine-async branch from 2a36c26 to d12b0ca Compare June 22, 2022 21:43
@maffoo maffoo marked this pull request as ready for review June 22, 2022 21:47
@maffoo maffoo requested review from wcourtney, a team, vtomole, cduck and verult as code owners June 22, 2022 21:47
Copy link
Collaborator

@95-martin-orion 95-martin-orion 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 formatting nits and docstring requests, but the overall change seems reasonable.

) -> Sequence[Sequence['cirq.Result']]:
"""Runs the supplied circuits.

This is an asynchronous version of `run_batch`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Document args / return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My idea here was just to refer to run_batch rather than repeat the same docs here. I've added a note to make this more explicit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems OK since these are on the same page in the docs site. Would be nice if we could link, but I'm not 100% certain whether cirq.Sampler.run_batch would auto-link properly with the tfdocs tools.

cirq-google/cirq_google/engine/engine.py Show resolved Hide resolved
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

LGTM. Up to you if you want to try linking with cirq.Sampler.run_batch.

@maffoo
Copy link
Contributor Author

maffoo commented Jul 12, 2022

Gonna go ahead and merge. I'll follow up with doc fixes if I can figure out how to get code references to render as links.

@maffoo maffoo merged commit faf6454 into master Jul 12, 2022
@maffoo maffoo deleted the u/maffoo/abstract-engine-async branch July 12, 2022 19:02
CirqBot pushed a commit that referenced this pull request Jul 12, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/async size: L 250< lines changed <1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants