API Reference:
qbraid.programs
Quantum Program Registry
TheQPROGRAM_REGISTRY
contains dictionary mappings of shorthand identifiers for “registered” quantum program types.
By default (i.e. without any optional dependencies installed) this simply includes three variations of OpenQASM programs:
openqasm3.ast.Program
object, while ‘qasm2’ and ‘qasm3’ are aliases
for raw OpenQASM 2 and OpenQASM 3 strings, respectively.
For each of its 10 natively supported program type aliases, the qBraid-SDK will automatically detect whether the corresponding library is installed,
and add that program type along with its type alias to the QPROGRAM_REGISTRY
. For example, after installing the following optional dependencies,
QPROGRAM_REGISTRY
is automatically updated:
Register New Program Types
You can register new quantum program types using either custom or default type aliases, and overwrite existing type aliases when necessary. For example:Load Program
Any quantum program of a natively supported type can be encapsulated within aqbraid.programs.QbraidProgram
object. This encapsulation provides a unified framework for circuit manipulation—such as removing idle qubits
and reversing qubit order—and for extracting valuable metadata, including the number of qubits, circuit depth,
and the unitary representation.
As an example, we’ll start with a simple qiskit circuit that creates the bell state,
load the quantum circuit object into the qBraid representation, verify the
circuit depth number of qubits, calculate the circuit’s unitary representation,
and draw the circuit.
qbraid.NATIVE_REGISTRY
can be loaded and utilized in this manner.
Each QbraidProgram
object has num_qubits
and depth
attributes and unitary()
method, regardless of the input circuit type.
For example, we could load an Amazon Braket circuit, and repeat similar steps:
remove_idle_qubits()
method allows you to remap qubit indices
without having to reconstruct the circuit:
remove_idle_qubits
method, we mapped the qubit indices of the
Amazon Braket circuit from [0, 2, 4]
to the contiguous [0, 1, 2]
convention.