CompilerDirectives

class braket.circuits.compiler_directives.StartVerbatimBox[source]

Bases: CompilerDirective

Prevents the compiler from modifying any ensuing instructions until the appearance of a corresponding EndVerbatimBox.

Inits a CompilerDirective.

Parameters:

ascii_symbols (Sequence[str]) – ASCII string symbols for the compiler directiver. These are used when printing a diagram of circuits.

counterpart()[source]

Returns the “opposite” counterpart to this compiler directive.

For example, the counterpart of a directive that starts a box is the directive that ends the box.

Return type:

CompilerDirective

Returns:

CompilerDirective – The counterpart compiler directive

property requires_physical_qubits: bool

Whether a circuit using this operator requires qubits to be physical.

Type:

bool

class braket.circuits.compiler_directives.EndVerbatimBox[source]

Bases: CompilerDirective

Marks the end of a portion of code following a StartVerbatimBox that prevents the enclosed instructions from being modified by the compiler.

Inits a CompilerDirective.

Parameters:

ascii_symbols (Sequence[str]) – ASCII string symbols for the compiler directiver. These are used when printing a diagram of circuits.

counterpart()[source]

Returns the “opposite” counterpart to this compiler directive.

For example, the counterpart of a directive that starts a box is the directive that ends the box.

Return type:

CompilerDirective

Returns:

CompilerDirective – The counterpart compiler directive

property requires_physical_qubits: bool

Whether a circuit using this operator requires qubits to be physical.

Type:

bool

class braket.circuits.compiler_directives.Barrier(qubit_indices)[source]

Bases: CompilerDirective

Barrier compiler directive.

Parameters:

qubit_indices (list[int])

Inits a CompilerDirective.

Parameters:
  • ascii_symbols (Sequence[str]) – ASCII string symbols for the compiler directiver. These are used when printing a diagram of circuits.

  • qubit_indices (list[int])

property qubit_indices: list[int]
property qubit_count: int
to_ir(target, ir_type, serialization_properties=None, **kwargs)[source]

Returns IR object of the compiler directive.

Parameters:
  • target (QubitSet | None) – target qubit(s). Defaults to None

  • ir_type (IRType) – The IRType to use for converting the compiler directive object to its IR representation. Defaults to IRType.JAQCD.

  • serialization_properties (SerializationProperties | None) – The serialization properties to use while serializing the object to the IR representation. The serialization properties supplied must correspond to the supplied ir_type. Defaults to None.

Return type:

Any

Returns:

Any – IR object of the compiler directive.

Raises:

ValueError – If the supplied ir_type is not supported.