AllowAtMostNQubits operation
Warning
This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.
Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.
Namespace: Microsoft.Quantum.Diagnostics
Package: Microsoft.Quantum.Standard
Between a call to this operation and its adjoint, asserts that at most a given number of additional qubits are allocated with using statements.
operation AllowAtMostNQubits (nQubits : Int, message : String) : Unit is Adj
Input
nQubits : Int
The maximum number of qubits that may be allocated.
message : String
A message to be displayed upon failure.
Output : Unit
Example
The following snippet will fail when executed on machines which support this diagnostic:
within {
AllowAtMostNQubits(3, "Too many qubits allocated.");
} apply {
// Fails since this allocates four qubits.
using (register = Qubit[4]) {
}
}
Remarks
This operation may be replaced by a no-op on targets which do not support it.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for