Support for the `run_batch()` method on `LocalSimulator`
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]
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 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!
Since we're introducing run_batch to the local simulator, it's also worth adding the method to the top-level Device class.
I'm working on this feature; just to clarify, is it ok to use multiprocessing.Pool for the parallelization?
Closed by #566
@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.
Good morning @kshitijc , I have to be assigned to this issue in order to receive the bounty; thank you
Apologies for missing to do that earlier. Assigned to you now @dakk!
Np @kshitijc , thank you 👍