general_superstaq.validation
Functions
|
Gets the maximum number of qubits that should be initialized for all jaqal_programs. |
|
Generates an options dictionary packaging all keyword args into a format compatible for |
|
Checks that bitmap is in an array format acceptable by the Atom picture API. |
|
Validates that integer_param is an integer and positive (or above a minimum value). |
|
Validates that an ACES noise model is valid. |
|
Validates that the input can be converted into a valid QUBO. |
|
Checks that target conforms to a valid Superstaq format and device type. |
Module Contents
- general_superstaq.validation.get_validated_jaqal_qubits(jaqal_programs: collections.abc.Sequence[str]) int
Gets the maximum number of qubits that should be initialized for all jaqal_programs.
- Parameters:
jaqal_programs – The Jaqal programs to infer qubit count from.
- Returns:
The max qubit register size needed for all jaqal_programs.
- Raises:
ValueError – If no qubit count could be inferred from jaqal_programs.
- general_superstaq.validation.get_validated_qscout_options(inferred_num_qubits: int, *, num_eca_circuits: int | None = None, mirror_swaps: bool = False, base_entangling_gate: str = 'xx', num_qubits: int | None = None, error_rates: _typeshed.SupportsItems[tuple[int, Ellipsis], float] | None = None, atol: float = 1e-08, atol_map: _typeshed.SupportsItems[tuple[int, Ellipsis], float] | None = None, keep_qubit_order: bool = False, random_seed: int | None = None, **kwargs: object) dict[str, Any]
- Generates an options dictionary packaging all keyword args into a format compatible for
/qscout_compile and /compile (for Jaqal).
- Parameters:
inferred_num_qubits – The determined number of qubits needed by the endpoint these options correspond to.
num_eca_circuits – Optional number of logically equivalent random circuits for Equivalent Circuit Averaging (ECA).
mirror_swaps – Whether to use mirror swapping to reduce two-qubit gate overhead.
base_entangling_gate – The base entangling gate to use: (“xx”, “zz”, “sxx”, or “szz”). Compilation with the “xx” and “zz” entangling bases will use arbitrary parameterized two-qubit interactions, while the “sxx” and “szz” bases will only use fixed maximally-entangling rotations. Defaults to “xx”.
num_qubits – An optional number of qubits that should be initialized in the backend (by default this will be determined from inferred_num_qubits).
error_rates – Optional dictionary assigning relative error rates to pairs of physical qubits, in the form {<qubit_indices>: <error_rate>, …} where <qubit_indices> is a tuple physical qubit indices (ints) and <error_rate> is a relative error rate for gates acting on those qubits (for example {(0, 1): 0.3, (1, 2): 0.2}). If provided, Superstaq will attempt to map the circuit to minimize the total error on each qubit. Omitted qubit pairs are assumed to be error-free.
atol – Optional tolerance (trace distance bound) used for approximate compilation. Superstaq will elide gates which can be approximated within the given tolerance by identity operations.
atol_map – Optional dictionary assigning compilation tolerances to physical qubits, in the form {<qubit_indices>: <atol>, …} where <qubit_indices> is a tuple of physical qubit indices (ints) and <atol> is an absolute tolerance (trace distance bound) for gates acting on those qubits (for example {(0, 1): 0.3, (1, 2): 0.2}). If provided, these tolerances will override atol for gates on the given qubits. Omitted qubit pairs default to atol.
keep_qubit_order – If True, do not reorder input qubits when compiling with ECA.
random_seed – Used to seed any stochastic compilation passes (especially for ECA).
kwargs – Other desired options.
- Returns:
The validated options dictionary packaging all args.
- Raises:
ValueError – If base_entangling_gate is not a valid gate option.
ValueError – If provided num_qubits is less than the register size determined by inferred_num_qubits.
- general_superstaq.validation.validate_bitmap(bitmap: numpy.typing.ArrayLike) None
Checks that bitmap is in an array format acceptable by the Atom picture API.
- Parameters:
bitmap – The array-like object to validate.
- Raises:
TypeError – If bitmap is not a two-dimensional array.
TypeError – If bitmap is not a square two-dimensional array.
ValueError – If bitmap contains any values outside of {0, 1, 2}.
- general_superstaq.validation.validate_integer_param(integer_param: object, min_val: int = 1, *, parameter_name: str | None = None) None
Validates that integer_param is an integer and positive (or above a minimum value).
- Parameters:
integer_param – The input parameter to validate.
min_val – Optional parameter to validate if integer_param is greater than min_val.
parameter_name – Optional name to print for integer_param in exception messages.
- Raises:
TypeError – If integer_param is not an integer.
ValueError – If integer_param is less than min_val.
- general_superstaq.validation.validate_noise_type(noise: dict[str, object], n_qubits: int) None
Validates that an ACES noise model is valid.
- Parameters:
noise – A noise model parameter.
n_qubits – Number of qubits the noise model is applied to.
- Raises:
ValueError – If noise is not valid.
- general_superstaq.validation.validate_qubo(qubo: object) None
Validates that the input can be converted into a valid QUBO.
- Parameters:
qubo – The input value to validate.
- Raises:
TypeError – If qubo is not a dict-like object.
TypeError – If the keys of qubo are of an invalid type.
ValueError – If qubo contains cubic or further higher degree terms.
TypeError – If the values in qubo are not real numbers.
- general_superstaq.validation.validate_target(target: str) str
Checks that target conforms to a valid Superstaq format and device type.
- Parameters:
target – A string containing the name of a target device.
- Raises:
ValueError – If target has an invalid format or device type.