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

feature: Implement run_batch for MultiSimulator #1000

Closed
wants to merge 3 commits into from

Conversation

rmshaffer
Copy link
Contributor

Issue #, if available:

Description of changes:
Braket SDK changes to support run_batch for the new MultiSimulator class in amazon-braket/amazon-braket-default-simulator-python#260

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

codecov bot commented Jun 11, 2024

Codecov Report

Attention: Patch coverage is 42.64706% with 39 lines in your changes missing coverage. Please review.

Project coverage is 99.56%. Comparing base (0ad486f) to head (9cafa74).
Report is 46 commits behind head on main.

Files with missing lines Patch % Lines
src/braket/devices/local_simulator.py 42.64% 39 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main    #1000      +/-   ##
===========================================
- Coverage   100.00%   99.56%   -0.44%     
===========================================
  Files          135      135              
  Lines         8941     9005      +64     
  Branches      2008     2022      +14     
===========================================
+ Hits          8941     8966      +25     
- Misses           0       39      +39     

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

Comment on lines +421 to +428
dispatch = {
Circuit: self._run_multiple_internal_circuit,
Problem: self._run_multiple_internal_problem,
OpenQASMProgram: self._run_multiple_internal_openqasm_program,
SerializableProgram: self._run_multiple_internal_serializable_program,
AnalogHamiltonianSimulation: self._run_multiple_internal_ahs,
AHSProgram: self._run_multiple_internal_ahs_program,
}
Copy link
Contributor Author

@rmshaffer rmshaffer Jun 11, 2024

Choose a reason for hiding this comment

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

This is temporary and will be deleted. Need to refactor all of this and the _run_internal methods above, to get rid of duplication.

with Pool(min(max_parallel, len(tasks_and_inputs))) as pool:
param_list = [(task, shots, inp, *args, *kwargs) for task, inp in tasks_and_inputs]
results = pool.starmap(self._run_internal_wrap, param_list)
if isinstance(self._delegate, MultiSimulator):
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to avoid this if statement, if possible. Maybe after we refactor to minimize duplication, there will be a reasonable way to get rid of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'll do my best to get rid of this. I agree, I think there should be a more elegant way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Use Python's multiple dispatch package? 😇

Copy link
Member

Choose a reason for hiding this comment

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

You can also just use @singledispatchmethod

@rmshaffer
Copy link
Contributor Author

Closing this in favor of #1005

@rmshaffer rmshaffer closed this Jun 27, 2024
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