Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

ToffoliSimulator outputs different result when executing Adjoint ApplyAnd #677

Open
weucode opened this issue Jul 15, 2023 · 0 comments
Open
Labels
Kind-Bug Something isn't working

Comments

@weucode
Copy link
Contributor

weucode commented Jul 15, 2023

Describe the bug
When running the following Q# program, the result of running on ToffoliSimulator is different from running on QuantumSimulator and SparseSimulator.

This behavior might be due to the different implementations among the three simulators. Since ToffoliSimulator does not support H gate, a specific version of ApplyAnd is designed on this page. However, when the values of t1, t2, qs are |1>, |1>, |0>, the return value of CCNOT(t1, t2, qs) is |1>, |1>, |1>, which violate the initial input rule that qs must be |0>, resulting in different outputs among three simulators.

To Reproduce

namespace Project {
    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Diagnostics;
    open Microsoft.Quantum.Canon;
    open Microsoft.Quantum.Measurement;
    open Microsoft.Quantum.Math;

    @EntryPoint()
    operation RunProgram() : Unit {
        use t1 = Qubit();
        X(t1);
        use t2 = Qubit();
        X(t2);
        use qs = Qubit();
        Adjoint ApplyAnd(t1, t2, qs);
        DumpMachine();
        ResetAll([t1,t2,qs]);
    }
}

Outputs
The output of QuantumSimulator and SparseSimulator:

|3⟩ 1.000000 + 0.000000 i == ******************** [ 1.000000 ] --- [ 0.00000 rad ]

The output of ToffoliSimulator:

Offset State Data
======== ==========
00000000 111

System information

  • OS: Windows10 & Ubuntu18.04
  • DotNet version : 7.0.100
  • QDK : 0.28.277227
@weucode weucode added the Kind-Bug Something isn't working label Jul 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Kind-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant