-
Notifications
You must be signed in to change notification settings - Fork 113
QIR
Quantum Intermediate Representation (QIR) is a program representation based on LLVM IR. The specification is developed by the QIR Alliance.
QIR specifies different profiles for different hardware capabilities. The Q# compiler can generate QIR that is compatible with the 'base' profile, which is limited to programs that can be represented as a sequence of operations. The compiler can also generate QIR that is compatible with the 'adaptive' profile as an experimental feature. The 'adaptive' profile allows additional capabilities such as mid-circuit measurement, branching based on measurement results or performing classical integer computations at runtime.
There are two settings that control the 'adaptive' profile QIR generation experimental feature:
- Q# > Qir: Enable Adaptive Profile.
- Q# > Qir: Experimental Code Generation.
You must enable both to be able to generate QIR for adaptive programs, and to submit them to Azure Quantum targets that support adaptive capabilities. Currently, there are two limitations with this experimental feature:
- Some dynamic Boolean operations do not have support for QIR generation yet. E.g.
MResetZ(q0) == One and MResetZ(q1) == One
. - QIR generation for exponentiation is not supported yet. E.g.
(MResetZ(q) == Zero ? 0 | 1) ^ 2
.
Q# code that runs in the local simulator is not limited to any subset of QIR described in a 'profile'. We refer to this as Unrestricted
. When developing Q# code, you can set the target profile via either the "Set the Azure Quantum QIR target profile" command (as shown below) or clicking on the editor status bar which will display the current target profile (either "QIR base", "Unrestricted" or "QIR Adaptive RI" if the experimental settings are enabled).

If the current program is not compatible with the selected target profile, you will get errors in the editor when targeting "QIR Base" or "QIR Adaptive RI". If the program is compatible, you can view the generated QIR via the "Get QIR for the current Q# program" menu item (also shown in the clipping above).