qbraid-qir
define the rules, restrictions,
and capabilities that govern how OpenQASM 3 programs are converted to QIR. When converting a QASM
program to QIR using qbraid-qir
, you must specify a profile—either Base or Adaptive—which
determines the allowed quantum operations, branching, measurement handling, and output recording.
This ensures that the generated QIR is compliant with the requirements of the target quantum backend
or workflow.
Available Profiles
Base Profile
- Name:
Base
- Capabilities:
- Conditional execution (
if
statements) is supported. - Only sequential output recording is supported.
- Conditional execution (
- Restrictions:
- No forward branching (no
goto
or loops). - Qubit reuse after measurement is not allowed.
- Measurement tracking is not enabled.
- No grouped output recording.
- No qubit reuse after measurement.
- Barriers must cover all qubits (no subset barriers).
- Only a fixed set of gates is supported.
- No forward branching (no
Adaptive Profile
- Name:
AdaptiveExecution
- Capabilities:
- Conditional execution and forward branching are supported.
- Qubit reuse after measurement is allowed.
- Measurement tracking is enabled.
- Grouped output recording is supported (register structure is preserved).
- Barriers must cover all qubits.
- Supports a broader set of gates and more flexible control flow.
- Restrictions:
- Subset barriers are not allowed (barriers must cover all qubits).
- Only constant parameters for parameterized gates.
How to Use
When converting QASM to QIR, specify the profile using theprofile
argument:
qir_base
and qir_adaptive
variables will contain the generated QIR code for the specified profile.
Example QASM Programs
Conclusion
When converting QASM to QIR withqbraid-qir
, always choose the profile that matches your target
backend’s requirements The Base
profile is strict and suitable for simple, hardware-oriented
workflows, while the Adaptive
profile enables more advanced quantum programming features such as
qubit reuse, grouped output, and flexible control flow.