Skip to content

Commit d760f00

Browse files
Add option to specify batch size (#6809)
1 parent e0087b0 commit d760f00

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cirq-core/cirq/experiments/two_qubit_xeb.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ def parallel_xeb_workflow(
401401
ax: Optional[plt.Axes] = None,
402402
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
403403
pool: Optional['multiprocessing.pool.Pool'] = None,
404+
batch_size: int = 9,
404405
**plot_kwargs,
405406
) -> Tuple[pd.DataFrame, Sequence['cirq.Circuit'], pd.DataFrame]:
406407
"""A utility method that runs the full XEB workflow.
@@ -418,6 +419,9 @@ def parallel_xeb_workflow(
418419
no plot is created.
419420
pairs: Pairs to use. If not specified, use all pairs between adjacent qubits.
420421
pool: An optional multiprocessing pool.
422+
batch_size: We call `run_batch` on the sampler, which can speed up execution in certain
423+
environments. The number of (circuit, cycle_depth) tasks to be run in each batch
424+
is given by this number.
421425
**plot_kwargs: Arguments to be passed to 'plt.Axes.plot'.
422426
423427
Returns:
@@ -462,6 +466,7 @@ def parallel_xeb_workflow(
462466
combinations_by_layer=combs_by_layer,
463467
shuffle=rs,
464468
repetitions=n_repetitions,
469+
batch_size=batch_size,
465470
)
466471

467472
fids = benchmark_2q_xeb_fidelities(
@@ -482,6 +487,7 @@ def parallel_two_qubit_xeb(
482487
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
483488
ax: Optional[plt.Axes] = None,
484489
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
490+
batch_size: int = 9,
485491
**plot_kwargs,
486492
) -> TwoQubitXEBResult:
487493
"""A convenience method that runs the full XEB workflow.
@@ -498,6 +504,9 @@ def parallel_two_qubit_xeb(
498504
ax: the plt.Axes to plot the device layout on. If not given,
499505
no plot is created.
500506
pairs: Pairs to use. If not specified, use all pairs between adjacent qubits.
507+
batch_size: We call `run_batch` on the sampler, which can speed up execution in certain
508+
environments. The number of (circuit, cycle_depth) tasks to be run in each batch
509+
is given by this number.
501510
**plot_kwargs: Arguments to be passed to 'plt.Axes.plot'.
502511
Returns:
503512
A TwoQubitXEBResult object representing the results of the experiment.
@@ -515,6 +524,7 @@ def parallel_two_qubit_xeb(
515524
cycle_depths=cycle_depths,
516525
random_state=random_state,
517526
ax=ax,
527+
batch_size=batch_size,
518528
**plot_kwargs,
519529
)
520530
return TwoQubitXEBResult(fit_exponential_decays(fids))
@@ -533,6 +543,7 @@ def run_rb_and_xeb(
533543
xeb_combinations: int = 10,
534544
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
535545
pairs: Optional[Sequence[tuple['cirq.GridQubit', 'cirq.GridQubit']]] = None,
546+
batch_size: int = 9,
536547
) -> InferredXEBResult:
537548
"""A convenience method that runs both RB and XEB workflows.
538549
@@ -547,6 +558,9 @@ def run_rb_and_xeb(
547558
xeb_combinations: The number of combinations to generate for XEB.
548559
random_state: The random state to use.
549560
pairs: Pairs to use. If not specified, use all pairs between adjacent qubits.
561+
batch_size: We call `run_batch` on the sampler, which can speed up execution in certain
562+
environments. The number of (circuit, cycle_depth) tasks to be run in each batch
563+
is given by this number.
550564
551565
Returns:
552566
An InferredXEBResult object representing the results of the experiment.
@@ -575,6 +589,7 @@ def run_rb_and_xeb(
575589
cycle_depths=depths_xeb,
576590
n_combinations=xeb_combinations,
577591
random_state=random_state,
592+
batch_size=batch_size,
578593
)
579594

580595
return InferredXEBResult(rb, xeb)

0 commit comments

Comments
 (0)