Skip to content

Modify run_batch_async#6387

Merged
senecameeks merged 16 commits intoquantumlib:mainfrom
senecameeks:parallelize_run_batch
Dec 20, 2023
Merged

Modify run_batch_async#6387
senecameeks merged 16 commits intoquantumlib:mainfrom
senecameeks:parallelize_run_batch

Conversation

@senecameeks
Copy link
Copy Markdown
Collaborator

@senecameeks senecameeks commented Dec 18, 2023

call run batch async asynchronously

This change gives a 2x speedup when usingrun_batch

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Comment on lines -297 to -300
return [
await self.run_sweep_async(circuit, params=params, repetitions=repetitions)
for circuit, params, repetitions in zip(programs, params_list, repetitions)
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You probably want to use a variant of duet.pmap ("parallel map") to make multiple calls in parallel. In this case, the zip produces tuples of args and we want to call the underlying function like self.run_sweep_async(*args), so we need a "starmap", something like:

return await duet.pstarmap_async(self.run_sweep_async, zip(programs, params_list, repetitions))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For reference, here's the definition of duet.pstarmap_async: https://github.com/google/duet/blob/main/duet/api.py#L171

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for the code pointer!

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (be7b059) 97.80% compared to head (db41d92) 97.81%.
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6387    +/-   ##
========================================
  Coverage   97.80%   97.81%            
========================================
  Files        1111     1111            
  Lines       96877    97054   +177     
========================================
+ Hits        94754    94931   +177     
  Misses       2123     2123            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@senecameeks senecameeks marked this pull request as ready for review December 18, 2023 21:58
@senecameeks senecameeks requested review from a team, cduck and vtomole as code owners December 18, 2023 21:58
Comment thread cirq-core/cirq/work/sampler.py
Copy link
Copy Markdown
Collaborator

@wcourtney wcourtney left a comment

Choose a reason for hiding this comment

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

LGTM % some test nits. Thanks!

Comment thread cirq-core/cirq/work/sampler_test.py Outdated
Comment thread cirq-core/cirq/work/sampler_test.py Outdated
@senecameeks senecameeks enabled auto-merge (squash) December 20, 2023 15:43
@senecameeks senecameeks merged commit 7c9b713 into quantumlib:main Dec 20, 2023
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
* Created using Colaboratory

* call run_sweep_async in parallel

* call circuits asynchronously

* Revert "Created using Colaboratory"

This reverts commit eb10318.

* Revert "call run_sweep_async in parallel"

This reverts commit f4e0d88.

* revert colab

* lint

* use pmap

* add test

* lint

* lint

* nits
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.

4 participants