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

Update batch example #1129

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions docs/run/run-jobs-batch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ Batch mode can shorten processing time if all jobs can be provided at the outset
The following example shows how you can divide up a long list of circuits into multiple jobs and run them as a batch to take advantage of the parallel processing.

```python
from qiskit_ibm_runtime import SamplerV2 as Sampler, Batch

max_circuits = 100
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
beckykd marked this conversation as resolved.
Show resolved Hide resolved
all_partitioned_circuits = []
for i in range(0, len(circuits), max_circuits):
all_partitioned_circuits.append(circuits[i : i + max_circuits])
jobs = []
with Batch(backend) as batch:
estimator = Estimator(batch)
# calls within this context are part of the batch.
for obs_set in observable_sets:
jobs.append(estimator.run(circuits, observables=obs_set))
start_idx = 0

with Batch(backend=backend):
sampler = Sampler()
for partitioned_circuits in all_partitioned_circuits:
job = sampler.run(partitioned_circuits)
jobs.append(job)
```
Loading