ConnectivityValidator

class braket.emulation.passes.circuit_passes.connectivity_validator.ConnectivityValidator(connectivity_graph=None, fully_connected=False, num_qubits=None, qubit_labels=None, directed=True)[source]

Bases: ValidationPass

A ConnectivityValidator instance takes in a qubit connectivity graph and validates that a circuit that uses verbatim circuits makes valid hardware qubit references in single and two-qubit gate operations.

Parameters:
  • connectivity_graph (dict[int, Iterable[int]], DiGraph | None) – Either a sparse matrix or DiGraph representation of the device connectivity. Can be None if fully_connected is true.

  • fully_connected (bool) – If true, the all qubits in the device are connected.

  • num_qubits (int | None) – The number of qubits in the device; if fully_connected is True, create a complete graph with num_qubits nodes; ignored if connectivity_graph is provided and fully_connected if False.

  • qubit_labels (Iterable[int], QubitSet | None) – A set of qubit labels; if fully_connected is True, the qubits_labels are used as nodes of a fully connected topology; ignored if connectivity_graph is provided and fully_connected if False.

  • directed (bool) – Denotes if the connectivity graph is directed or undirected. If the connectivity graph is undirected, this constructor attempts to fill in any missing back edges.

Raises:
  • ValueError – If the inputs do not correctly yield a connectivity graph; i.e.

  • fully_connected is true but neither/both num qubits and qubit labels are defined

  • or a valid DiGraph or dict representation of a connectivity graph is not provided.

validate(circuit)[source]

Verifies that any verbatim box in a circuit is runnable with respect to the device connectivity definied by this validator. If any sub-circuit of the input circuit is verbatim, we validate the connectivity of all gate operations in the circuit.

Parameters:

circuit (Circuit | ProgramSet) – The Braket circuit whose gate operations to validate.

Raises:

ValueError – If a hardware qubit reference does not exist in the connectivity graph.

Return type:

None