author | description | ms.date | ms.author | ms.service | ms.subservice | ms.topic | no-loc | title | uid | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SoniaLopezBravo |
This document provides an overview of target profile types available in Azure Quantum and their limitations. |
11/18/2024 |
sonialopez |
azure-quantum |
core |
how-to |
|
Target Profile Types |
microsoft.quantum.target-profiles |
Quantum devices are still an emerging technology, and not all of them can run every Q# code. As such, you need to keep some restrictions in mind when developing quantum programs.
The target profile types are used to define the capabilities of the quantum devices that you can target with your Q# programs.
This article discusses the different types of target profiles available in Azure Quantum, their limitations, and how to configure them in the Quantum Development Kit (QDK).
Currently, Azure Quantum and the QDK manage three different target profiles:
- :::no-loc text="Unrestricted":::: This profile can run any QIR program, and thus any Q# program, within the limits of memory for simulators or the number of qubits for physical quantum computers.
- :::no-loc text="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. - :::no-loc text="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.
:::no-loc text="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 :::no-loc text="Unrestricted"::: Q# programs on simulators provided by the QDK.
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)
:::no-loc text="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 :::no-loc text="QIR Base"::: target:
operation FlipQubitOnZero() : Unit {
use q = Qubit();
if M(q) == Zero {
X(q);
}
}
If you try to run this operation on a :::no-loc text="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.
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)
Currently, the following :::no-loc text="QIR Base"::: targets are available in 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 (
:::no-loc text="QIR Adaptive RI"::: profile targets can run a wide variety of Q# applications, with some constraints. This profile type supposes an improvement over :::no-loc text="QIR Base"::: profiles, but still is subject to some limitations.
:::no-loc text="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 :::no-loc text="QIR Adaptive RI"::: target:
operation MeasureQubit(q : Qubit) : Result {
return M(q);
}
operation SetToZero(q : Qubit) : Unit {
if MeasureQubit(q) == One { X(q); }
}
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)
Currently, the following :::no-loc text="QIR Adaptive RI"::: targets are available in 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 (