Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG with put function. #13

Open
frankwswang opened this issue Aug 6, 2019 · 3 comments
Open

BUG with put function. #13

frankwswang opened this issue Aug 6, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@frankwswang
Copy link

frankwswang commented Aug 6, 2019

MWE:

julia> using CuYao

julia> c1 = put(10, (7,8,9)=>chain(3, chain(3, chain(3, chain(3, put(3, 1=>Ry(pi)), put(3, 2=>Ry(pi)))))))
nqubits: 10
put on (7, 8, 9)
└─ chain
   └─ chain
      └─ chain
         └─ chain
            ├─ put on (1)
            │  └─ rot(Y gate, 3.141592653589793)
            └─ put on (2)
               └─ rot(Y gate, 3.141592653589793)


julia> rand_state(10, nbatch = 1000) |> cu |> c1
ArrayReg{1000, Complex{Float64}, CuArray...}
    active qubits: 10/10

julia> c2 = put(11, (7,8,9,10)=>chain(4, chain(4, chain(4, chain(4, put(4, 1=>Ry(pi)), put(4, 2=>Ry(pi)))))))
nqubits: 11
put on (7, 8, 9, 10)
└─ chain
   └─ chain
      └─ chain
         └─ chain
            ├─ put on (1)
            │  └─ rot(Y gate, 3.141592653589793)
            └─ put on (2)
               └─ rot(Y gate, 3.141592653589793)


julia> rand_state(11, nbatch = 1000) |> cu |> c2
ERROR: CUDA error: device kernel image is invalid (code #200, ERROR_INVALID_IMAGE)

julia> c3 = put(11, (7,8,9)=>chain(3, chain(3, chain(3, chain(3, put(3, 1=>Ry(pi)), put(3, 2=>Ry(pi)))))))
nqubits: 11
put on (7, 8, 9)
└─ chain
   └─ chain
      └─ chain
         └─ chain
            ├─ put on (1)
            │  └─ rot(Y gate, 3.141592653589793)
            └─ put on (2)
               └─ rot(Y gate, 3.141592653589793)


julia> rand_state(11, nbatch = 1000) |> cu |> c3
ArrayReg{1000, Complex{Float64}, CuArray...}
    active qubits: 11/11
@Roger-luo Roger-luo added the bug Something isn't working label Aug 6, 2019
@GiggleLiu
Copy link
Member

The static matrix in kernel is too large, please use

c2 = concentrate(11, chain(4, chain(4, chain(4, chain(4, put(4, 1=>Ry(pi)), put(4, 2=>Ry(pi)))))), 7:10)

@GiggleLiu
Copy link
Member

GiggleLiu commented Aug 7, 2019

put is not suited for large blocks, since it will use static gates to avoid allocation, speed up the simulation. Which is not proper for large blocks.

For CPU, it coverts the gate to a dynamic matrix if the gate matrix is too large, however, the same trick is not possible for CuYao, I can fix it by throwing a better error message.

@Roger-luo
Copy link
Member

I tagged this because we need better error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants