Skip to content

Commit

Permalink
Fix test for multi_qubit_measurements/state_modification (#1830)
Browse files Browse the repository at this point in the history
Doing Reset on the first qubit before checking the state of the second
qubit can lead to empty solution being judged as correct (with low
probability). We have to check the state of the second qubit first and
only then reset the first one.
  • Loading branch information
tcNickolas authored Aug 12, 2024
1 parent 2062d8f commit 4de42e1
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ namespace Kata.Verification {
// Prepare the state to be input to the testImplementation
StateInitialize_StateSelection(alpha, qs);

// operate testImplementation
Kata.StateSelection(qs, ind);
// reset the first qubit, since its state does not matter
Reset(qs[0]);

// apply adjoint reference operation and check that the result is correct
// Apply adjoint of state preparation operation
Adjoint StatePrepare_StateSelection(alpha, ind, qs[1]);

if not CheckAllZero(qs) {
// We only care about the state of the second qubit;
// if it's still entangled with the first one or not in zero state, this check will fail.
if not CheckZero(qs[1]) {
ResetAll(qs);
Message("Incorrect.");
Message($"The state of the second qubit for {params}, ind = {ind} does not match expectation.");
return false;
}

Reset(qs[0]);
}
}
Message("Correct!");
Expand Down

0 comments on commit 4de42e1

Please sign in to comment.