QuantumBFS / Yao.jl

Extensible, Efficient Quantum Algorithm Design for Humans.
https://yaoquantum.org
Other
910 stars 118 forks source link

Measure block acts differently on cpu registers and cuda registers #514

Closed nzy1997 closed 1 month ago

nzy1997 commented 1 month ago

Here is an MWE.

using Test
using CUDA
using Yao

@testset "fidelity" begin 
    reg = rand_state(2;nbatch =1)
    cureg = cu(reg)
    @test reg.state ≈ cureg.state |> Array

    qc = chain(2,put(2,(1,2)=> matblock(rand_unitary(4))))
    push!(qc, Measure(2; locs = [2], resetto = bit"0"))
    apply!(reg,qc)
    apply!(cureg,qc)
    @test reg.state ≈ cureg.state |> Array
end