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

Modify run_batch_async #6387

Merged
merged 16 commits into from
Dec 20, 2023
Merged

Conversation

senecameeks
Copy link
Collaborator

@senecameeks senecameeks commented Dec 18, 2023

call run batch async asynchronously

This change gives a 2x speedup when usingrun_batch

Copy link

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
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
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
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!

Copy link

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 vtomole, cduck and a team as code owners December 18, 2023 21:58
Copy link
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!

@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