You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
Hello! As shown in the below testcase, a qubit is defined, which is named NISLVariable0. When H is applied to NISLVariable0, it has a 50% chance of being 0 and a chance of 50% being 1. But when excepted is set to Zero and tolerance is set to 0.5, the operation AssertQubitWithinTolerance throws an exception. Is this a normal behavior of the operation? And what does the tolerance parameter mean?
Testcase
namespace NISLNameSpace {
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Diagnostics;
operation NISLOperation () : Unit {
mutable expected =Zero;
use NISLVariable0 =Qubit();
H(NISLVariable0);
mutable tolerance = 0.5;
AssertQubitWithinTolerance(expected, NISLVariable0, tolerance);
Reset(NISLVariable0);
}
@EntryPoint()
operation main() : Unit {
mutable tmp = NISLOperation();
}
}
Actual Behavior
Unhandledexception. Microsoft.Quantum.Simulation.Core.ExecutionFailException: Qubit in invalid state. Expecting: Zero with tolerance 0.5
Expected:1
Actual:0.4999999999999999
Expected Behavior
No exception
Environment
Operating system: Windows 10
dotnet version: 3.1.414
QDK: 0.21.2111177148
Command
dotnet run
The text was updated successfully, but these errors were encountered:
@QuXing9: I am transferring this issue, since AssertQubitWithinTolerance is implemented in this repository. It seems that the problem arises from this line:
ensemblePr will always return 0.500……1. Does this mean that when H operation is applied to a qubit, it returns Zero with a probability of 0.499……9 and One with a probability of 0.500……1 ? Why not just return 0.5?
Since the value of tolerance ranges from 0.0 to 1.0. If it is less than 0.0, the AssertQubitWithinTolerance will throw an exception always. If it is greater than 1.0. the AssertQubitWithinTolerance will execute correctly. Therefore, is it possible to add judgment or assertion on tolerance value at Line 28 of the AssertMeasurementProbability ? In this way, it will avoid the execution of redundant code and improve the efficiency of program execution.
Description
Hello! As shown in the below testcase, a qubit is defined, which is named
NISLVariable0
. WhenH
is applied toNISLVariable0
, it has a 50% chance of being 0 and a chance of 50% being 1. But when excepted is set toZero
and tolerance is set to0.5
, the operationAssertQubitWithinTolerance
throws an exception. Is this a normal behavior of the operation? And what does the tolerance parameter mean?Testcase
Actual Behavior
Expected Behavior
No exception
Environment
Operating system
: Windows 10dotnet version
: 3.1.414QDK
: 0.21.2111177148Command
dotnet run
The text was updated successfully, but these errors were encountered: