braket.circuits.serialization module

class braket.circuits.serialization.IRType(value)[source]

Bases: str, Enum

Defines the available IRTypes for circuit serialization.

OPENQASM = 'OPENQASM'
JAQCD = 'JAQCD'
class braket.circuits.serialization.QubitReferenceType(value)[source]

Bases: str, Enum

Defines how qubits should be referenced in the generated OpenQASM string. See https://qiskit.github.io/openqasm/language/types.html#quantum-types for details.

VIRTUAL = 'VIRTUAL'
PHYSICAL = 'PHYSICAL'
class braket.circuits.serialization.SerializableProgram[source]

Bases: ABC

abstract to_ir(ir_type: IRType = IRType.OPENQASM) str[source]

Serializes the program into an intermediate representation.

Parameters:

ir_type (IRType) – The IRType to use for converting the program to its IR representation. Defaults to IRType.OPENQASM.

Raises:

ValueError – Raised if the supplied ir_type is not supported.

Returns:

str – A representation of the program in the ir_type format.

class braket.circuits.serialization.OpenQASMSerializationProperties(qubit_reference_type: QubitReferenceType = QubitReferenceType.VIRTUAL)[source]

Bases: object

Properties for serializing a circuit to OpenQASM.

qubit_reference_type (QubitReferenceType): determines whether to use

logical qubits or physical qubits (q[i] vs $i).

qubit_reference_type: QubitReferenceType = 'VIRTUAL'
format_target(target: int) str[source]

Format a target qubit to the appropriate OpenQASM representation.

Parameters:

target (int) – The target qubit.

Returns:

str – The OpenQASM representation of the target qubit.

braket.circuits.serialization.SerializationProperties

alias of OpenQASMSerializationProperties