general_superstaq.validation ============================ .. py:module:: general_superstaq.validation Functions --------- .. autoapisummary:: general_superstaq.validation.get_validated_jaqal_qubits general_superstaq.validation.get_validated_qscout_options general_superstaq.validation.validate_bitmap general_superstaq.validation.validate_integer_param general_superstaq.validation.validate_noise_type general_superstaq.validation.validate_qubo general_superstaq.validation.validate_target Module Contents --------------- .. py:function:: 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`. :param 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`. .. py:function:: 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). :param inferred_num_qubits: The determined number of qubits needed by the endpoint these options correspond to. :param num_eca_circuits: Optional number of logically equivalent random circuits for Equivalent Circuit Averaging (ECA). :param mirror_swaps: Whether to use mirror swapping to reduce two-qubit gate overhead. :param 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". :param num_qubits: An optional number of qubits that should be initialized in the backend (by default this will be determined from `inferred_num_qubits`). :param error_rates: Optional dictionary assigning relative error rates to pairs of physical qubits, in the form `{: , ...}` where `` is a tuple physical qubit indices (ints) and `` 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. :param 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. :param atol_map: Optional dictionary assigning compilation tolerances to physical qubits, in the form `{: , ...}` where `` is a tuple of physical qubit indices (ints) and `` 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`. :param keep_qubit_order: If `True`, do not reorder input qubits when compiling with ECA. :param random_seed: Used to seed any stochastic compilation passes (especially for ECA). :param kwargs: Other desired options. :returns: The validated options dictionary packaging all `args`. :raises ValueError: If `base_entangling_gate` is not a valid gate option. :raises ValueError: If provided `num_qubits` is less than the register size determined by `inferred_num_qubits`. .. py:function:: validate_bitmap(bitmap: numpy.typing.ArrayLike) -> None Checks that `bitmap` is in an array format acceptable by the Atom picture API. :param bitmap: The array-like object to validate. :raises TypeError: If `bitmap` is not a two-dimensional array. :raises TypeError: If `bitmap` is not a square two-dimensional array. :raises ValueError: If `bitmap` contains any values outside of {0, 1, 2}. .. py:function:: 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). :param integer_param: The input parameter to validate. :param min_val: Optional parameter to validate if `integer_param` is greater than `min_val`. :param parameter_name: Optional name to print for `integer_param` in exception messages. :raises TypeError: If `integer_param` is not an integer. :raises ValueError: If `integer_param` is less than `min_val`. .. py:function:: validate_noise_type(noise: dict[str, object], n_qubits: int) -> None Validates that an ACES noise model is valid. :param noise: A noise model parameter. :param n_qubits: Number of qubits the noise model is applied to. :raises ValueError: If `noise` is not valid. .. py:function:: validate_qubo(qubo: object) -> None Validates that the input can be converted into a valid QUBO. :param qubo: The input value to validate. :raises TypeError: If `qubo` is not a dict-like object. :raises TypeError: If the keys of `qubo` are of an invalid type. :raises ValueError: If `qubo` contains cubic or further higher degree terms. :raises TypeError: If the values in `qubo` are not real numbers. .. py:function:: validate_target(target: str) -> str Checks that `target` conforms to a valid Superstaq format and device type. :param target: A string containing the name of a target device. :raises ValueError: If `target` has an invalid format or device type.