Describe the bug
The test_gates() in the capi_test.cpp file, tests the gate implementation in the native simulator code.
The relevant part of the test for this bug is the following:
X(sim_id, 0);
CRx(sim_id, 1.0, 0, 1);
H(sim_id, 1);
CRx(sim_id, -1.0, 0, 1);
H(sim_id, 1);
assert(M(sim_id, 1) == false);
Here, the assert following the the gate sequence, does not pass deterministically and was demonstrated to fail after a number of runs
To Reproduce
The bug can be reproduced by running capi_test multiple times either manually or using a powershell script as follows:
$i = 0 ; while(!$LASTEXITCODE){.\capi_test.exe > out-null ; $i++ ; write-host $i ; sleep 2}
Expected behavior
The expected behavior is that all tests in capi_test pass deterministically every time, and printing the following:
Testing allocate
Testing gates
Testing teleport
Testing basis state permutation
Testing dump
Actual behavior
The error observed is an assertion fail, like the following:
Testing allocate
Testing gates
Assertion failed: M(sim_id, 1)==false, file D:\github\qsharp-runtime\src\Simulation\Native\src\simulator\capi_test.cpp, line 121
System information
Additional context
Add any other context about the problem here.