qiskit_braket_provider.providers.to_braket

to_braket(circuits=None, *args, qubit_labels=None, target=None, verbatim=None, basis_gates=None, coupling_map=None, angle_restrictions=None, optimization_level=0, callback=None, num_processes=None, pass_manager=None, braket_device=None, add_measurements=True, circuit=None, connectivity=None)[source]

Converts a single or list of Qiskit QuantumCircuits to a single or list of Braket Circuits.

The recommended way to use this method is to minimally pass in qubit labels and a target (instead of basis gates and coupling map). This ensures that the translated circuit is actually supported by the device (and doesn’t, for example, include unsupported parameters for gates). The latter guarantees that the output Braket circuit uses the qubit labels of the Braket device, which are not necessarily contiguous.

Parameters:
  • circuits (QuantumCircuit | Circuit | Program | str | Iterable) – Qiskit or Braket circuit(s) or OpenQASM 3 program(s) to transpile and translate to Braket.

  • qubit_labels (Sequence[int] | None) – A list of (not necessarily contiguous) indices of qubits in the underlying Amazon Braket device. If not supplied, then the indices are assumed to be contiguous. Default: None.

  • target (Target | None) – A backend transpiler target. Can only be provided if basis_gates is None. Default: None.

  • verbatim (bool) – Whether to translate the circuit without any modification, in other words without transpiling it. Default: False.

  • basis_gates (Sequence[str] | None) – The gateset to transpile to. Can only be provided if target is None. If None and target is None, the transpiler will use all gates defined in the Braket SDK. Default: None.

  • coupling_map (list[list[int]] | None) – If provided, will transpile to a circuit with this coupling map. Default: None.

  • angle_restrictions (Mapping[str, Mapping[int, set[float] | tuple[float, float]]] | None) – Mapping of gate names to parameter angle constraints used to validate numeric parameters. Default: None.

  • optimization_level (int | None) –

    The optimization level to pass to qiskit.transpile. From Qiskit:

    • 0: no optimization - basic translation, no optimization, trivial layout

    • 1: light optimization - routing + potential SaberSwap, some gate cancellation and 1Q gate folding

    • 2: medium optimization - better routing (noise aware) and commutative cancellation

    • 3: high optimization - gate resynthesis and unitary-breaking passes

    Default: 0.

  • callback (Callable | None) – A callback function that will be called after each transpiler pass execution. Default: None.

  • num_processes (int | None) – The maximum number of parallel transpilation processes for multiple circuits. Default: None.

  • pass_manager (PassManager) – PassManager to transpile the circuit; will raise an error if used in conjunction with a target, basis gates, or connectivity. Default: None.

  • braket_device (Device) – Braket device to transpile to. Can only be provided if target and basis_gates are None. Default: None.

  • add_measurements (bool) – Whether to add measurements when translating Braket circuits. Default: True.

  • circuit (QuantumCircuit | Circuit | Program | str | Iterable | None) – Qiskit or Braket circuit(s) or OpenQASM 3 program(s) to transpile and translate to Braket. Default: None. DEPRECATED: use first positional argument or circuits instead.

  • connectivity (list[list[int]] | None) – If provided, will transpile to a circuit with this connectivity. Default: None. DEPRECATED: use coupling_map instead.

Raises:

ValueError – If more than one of target, basis_gates or coupling_map/connectivity, pass_manager, and braket_device are passed together, or if qubit_labels is passed with braket_device.

Returns:

Braket circuit or circuits

Return type:

Circuit | list[Circuit]