Sample two-qubit XEB circuits given a sampler.

Used in the notebooks

Used in the tutorials

sampler A Cirq sampler for executing circuits.
circuits A library of two-qubit circuits generated from random_rotations_between_two_qubit_circuit of sufficient length for cycle_depths.
cycle_depths A sequence of cylce depths at which we will truncate each of the circuits to execute.
repetitions Each (circuit, cycle_depth) will be sampled for this many repetitions.
batch_size We call run_batch on the sampler, which can speed up execution in certain environments. The number of (circuit, cycle_depth) tasks to be run in each batch is given by this number.
progress_bar A progress context manager following the tqdm API or None to not report progress.
combinations_by_layer Either None or the result of rqcg.get_random_combinations_for_device. If this is None, the circuits specified by circuits will be sampled verbatim, resulting in isolated XEB characterization. Otherwise, this contains all the random combinations and metadata required to combine the circuits in circuits into wide, parallel-XEB-style circuits for execution.
shuffle If provided, use this random state or seed to shuffle the order in which tasks are executed.
dataset_directory If provided, save each batch of sampled results to a file {dataset_directory}/xeb.{uuid4()}.json where uuid4() is a random string. This can be used to incrementally save results to be analyzed later.

A pandas dataframe with index given by ['circuit_i', 'cycle_depth']. Columns always include "sampled_probs". If combinations_by_layer is not None and you are doing parallel XEB, additional metadata columns will be attached to the returned DataFrame.