QIR target profile types in Azure Quantum
This article discusses the different type of QIR target profile types available in the quantum computing providers in Azure Quantum. The QIR target profile types are used to define the capabilities of the quantum devices that you can target with your Q# programs.
Target profiles and their limitations
Quantum devices are still an emerging technology, and not all of them can run all Q# code. As such, you need to keep some restrictions in mind when developing programs for different targets. Currently, Azure Quantum and the QDK manage three different target profiles:
- Unrestricted: This profile can run any QIR program within the limits of memory for simulators or the number of qubits for physical quantum computers.
- QIR base: This profile can run any Q# program that doesn't require the use of the results from qubit measurements to control the program flow. Within a Q# program targeted for this kind of QPU, values of type
Result
don't support equality comparison. - QIR Adaptive RI: This profile has limited ability to use the results from qubit measurements to control the program flow. Within a Q# program targeted for this kind of QPU, you can compare values of type
Result
as part of conditions withinif
statements in operations, allowing mid-circuit measurement.
Create and run applications for Unrestricted target profile
Unrestricted target profiles can run any program, meaning you can write Q# programs without functionality restrictions. Azure Quantum doesn't provide any target with this profile. However, you can run Unrestricted Q# programs on simulators provided by the QDK.
Configure Unrestricted target profile
In Visual Studio Code:
- Select View -> Command Palette and type Q#: Set the Azure Quantum QIR target profile. Press Enter.
- Select Unrestricted.
In Python, you can set the target profile using the qsharp.init
method.
qsharp.init(target_profile=qsharp.TargetProfile.Unrestricted)
Create and run applications for QIR Base target profile
QIR Base target profiles can run a wide variety of Q# applications, with the constraint that they can't use results from qubit measurements to control
the program flow. More specifically, values of type Result
don't support equality comparison.
For example, this operation can't be run on a QIR Base target:
operation FlipQubitOnZero() : Unit {
use q = Qubit();
if M(q) == Zero {
X(q);
}
}
If you try to run this operation on a QIR Base target, the operation will fail because it does a comparison using a measurement result (M(q) == Zero
)
to control the computation flow with an if
statement. The same is applicable to any type of conditional branching, such as elif
and else
statements.
Configure QIR Base target profile
In Visual Studio Code:
- Select View -> Command Palette and type Q#: Set the Azure Quantum QIR target profile. Press Enter.
- Select QIR base.
In Python, you can set the target profile using the qsharp.init
method.
qsharp.init(target_profile=qsharp.TargetProfile.Base)
Supported targets
Currently, these QIR Base targets are available for Azure Quantum:
Provider: IonQ
- IonQ simulator (
ionq.simulator
) - IonQ QPU (
ionq.qpu.*
)
- IonQ simulator (
Provider: Rigetti
- Rigetti Simulator (
rigetti.sim.*
) - Rigetti QPU (
rigetti.qpu.*
)
- Rigetti Simulator (
Create and run applications for QIR Adaptive RI profile targets
QIR Adaptive RI profile targets can run a wide variety of Q# applications, with some constraints. This profile type supposes an improvement over QIR Base profiles, but still is subject to some limitations.
QIR Adaptive RI profile targets allow measurement-based conditional operations and mid-circuit measurements, meaning that qubits can be selectively measured at a point other than the final statement of a quantum program, and the output of the measurement can be used in other operations. Mid-circuit measurement enables multiple measurements at any point throughout the quantum program. The quantum information of the measured qubits collapses to a classical state (zero or one), but the non-measured qubits remain in their quantum state.
In Q# when measuring a qubit, a value of type Result
is returned. If you want to use this result in a conditional statement, you have to directly compare in the conditional statement. The corresponding conditional blocks may not contain return
or set
statements.
For example, the following Q# code would be allowed in a QIR Adaptive RI target:
operation MeasureQubit(q : Qubit) : Result {
return M(q);
}
operation SetToZero(q : Qubit) : Unit {
if MeasureQubit(q) == One { X(q); }
}
Configure QIR Adaptive RI target profile
In Visual Studio Code:
- Select View -> Command Palette and type Q#: Set the Azure Quantum QIR target profile. Press Enter.
- Select QIR Adaptive RI.
In Python, you can set the target profile using the qsharp.init
method.
qsharp.init(target_profile=qsharp.TargetProfile.Adaptive_RI)
Supported targets
Currently, these QIR Adaptive RI targets are available for Azure Quantum:
- Provider: Quantinuum
- Quantinuum Emulators (
quantinuum.sim.h1-1e
,quantinuum.sim.h2-1e
) - Quantinuum QPUs (
quantinuum.qpu.h1-1
,quantinuum.qpu.h2-1
)
- Quantinuum Emulators (