amazon-braket-sdk-python icon indicating copy to clipboard operation
amazon-braket-sdk-python copied to clipboard

Support for the `run_batch()` method on `LocalSimulator`

Open kshitijc opened this issue 2 years ago • 3 comments

Describe the feature you'd like Support for the run_batch() method on LocalSimulator

How would this feature be used? Please describe. LocalSimulator allows users to test programs before submitting them to the service using the AwsDevice class. AwsDevice implements a run_batch() method, allowing multiple tasks to be submitted. As a user, if I replace AwsDevice with LocalSimulator, I'm unable to test a code snippet containing run_batch() calls.

Describe alternatives you've considered A user has to resort to implementing the batch run manually as:

batch = [device.run(c, shots=shots) for c in circuits]
batch_result = [b.result() for b in batch]

kshitijc avatar Apr 05 '22 17:04 kshitijc

I would like to try solving this issue. So the idea is to replicate the functionality of aws>aws_device.py>AwsDevice>run_batch() to devices>local_simulator.py. Are there any special considerations? Thanks!

born-2learn avatar Jun 02 '22 06:06 born-2learn

@born-2learn Awesome! Yes, exactly. We want to add the following functionality:

device = LocalSimulator()
num_tasks = 10

circuits = [bell for _ in range(num_tasks)]
batch = device.run_batch(circuits, shots=100)

for i in range(num_tasks):
    print(batch.results()[i].measurement_counts)  # The result of the ith task in the batch

There will likely be specific considerations you'll need to take into account for effectively implementing the parallelism; we want to see a performance improvement in line with the parallelization. Let us know if you have any more questions, thanks!

ajberdy avatar Jun 17 '22 18:06 ajberdy

Since we're introducing run_batch to the local simulator, it's also worth adding the method to the top-level Device class.

speller26 avatar Jun 17 '22 19:06 speller26

I'm working on this feature; just to clarify, is it ok to use multiprocessing.Pool for the parallelization?

dakk avatar May 26 '23 13:05 dakk

Closed by #566

kshitijc avatar Jun 01 '23 16:06 kshitijc

@kshitijc please ensure the hacker that should be awarded the bounty for resolving this issue is properly assigned! Looks to be @dakk in this case.

natestemen avatar Jun 02 '23 06:06 natestemen

Good morning @kshitijc , I have to be assigned to this issue in order to receive the bounty; thank you

dakk avatar Jun 07 '23 07:06 dakk

Apologies for missing to do that earlier. Assigned to you now @dakk!

kshitijc avatar Jun 07 '23 18:06 kshitijc

Np @kshitijc , thank you 👍

dakk avatar Jun 07 '23 18:06 dakk