pygsti.circuits.subcircuit_selection.sample_subcircuits#
- sample_subcircuits(full_circs, width_depths, coupling_map, instruction_durations, use_qiskit_for_instruction_durations=None, num_samples_per_width_depth=10, strategy='simple', strategy_args=None, depth_metric='layer_count', num_test_samples=None, rand_state=None)#
Samples subcircuits from a full circuit based on specified width and depth pairs.
- Parameters:
full_circs (Union[pygsti.circuits.Circuit, List[pygsti.circuits.Circuit]]) – The full circuit(s) from which to sample subcircuits.
width_depths (Dict[int, List[int]]) – A dictionary whose keys are subcircuit widths and whose values are lists of depths to sample for that subcircuit depth. Defines a list of (width, depth) pairs for subcircuits.
coupling_map (Union[str, qiskit.transpiler.CouplingMap]) – The coupling map defining the connectivity of qubits. Can be ‘all-to-all’, ‘linear’, or a qiskit CouplingMap object.
instruction_durations (qiskit.transpiler.InstructionDurations) – A qiskit InstructionDurations object used to determine delay times for idle subcircuit layers.
use_qiskit_for_instruction_durations (bool, optional) – Whether to use qiskit gatenames instead of pyGSTi gatenames when looking up instruction durations in instruction_durations. If this argument is not provided, then the lookup gatename is based on the type of instruction_durations. If instruction_durations is an InstructionDurations object, the qiskit gatenames are used, else the pyGSTi gatenames are used.
num_samples_per_width_depth (int, optional) – The number of subcircuits to sample for each width-depth combination. Default is 10.
strategy (Union[str, Callable[..., Any]], optional) – The subcircuit sampling strategy to use (‘simple’, ‘greedy’, or a custom function). Default is ‘simple’.
strategy_args (Dict, optional) – Additional arguments if a custom sampling strategy function is used. Default is None.
depth_metric (str, optional) – The metric to use for measuring depth (‘layer_count’ or ‘falcon_depth’). If layer_count, the depth is calculated as the number of layers in the subcircuit. If falcon_depth, the gate set must be U3-CX; U3 gates contribute 2 to the depth and CX gates contribute 1 to the depth. The falcon_depth metric is based on the Falcon generation of IBMQ devices. Default is ‘layer_count’.
num_test_samples (int, optional) – The number of test samples to use if the ‘greedy’ subcircuit sampling strategy is employed. If strategy is not greedy, this argument is ignored. Default is None.
rand_state (_np.random.RandomState, optional) – A random state for reproducibility. Default is None.
- Returns:
A FreeformDesign object containing the sampled subcircuits and auxiliary information, including a circuit ID and depth.
- Return type:
pygsti.protocols.FreeformDesign