QIR (Quantum Intermediate Representation) profiles in 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.
  • 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.

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 the profile argument:

from qbraid_qir.qasm3 import qasm3_to_qir

qasm3_code = """
OPENQASM 3;
qubit[2] q;
bit[2] c;
h q[0];
c[0] = measure q[0];
if (c[0]) {
    x q[1];
}
c[1] = measure q[1];
"""

# Convert using the Base profile
qir_base = qasm3_to_qir(qasm3_code, profile="base")
print(qir_base)

# Convert using the Adaptive profile
qir_adaptive = qasm3_to_qir(qasm3_code, profile="adaptive")
print(qir_adaptive)

The qir_base and qir_adaptive variables will contain the generated QIR code for the specified profile.

Example QASM Programs

OPENQASM 3;
qubit[2] q;
bit[2] c;
h q[0];
c[0] = measure q[0];
x q[1];      // Allowed
reset q[0];  // Not allowed in Base profile (qubit reuse forbidden)

The last line will cause an error in the Base profile because qubit reuse after measurement is not permitted

Conclusion

When converting QASM to QIR with qbraid-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.