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

Strange behavior of 1-qbit circuit #437

Open
erlebach opened this issue Oct 29, 2022 · 2 comments
Open

Strange behavior of 1-qbit circuit #437

erlebach opened this issue Oct 29, 2022 · 2 comments
Labels
question Further information is requested

Comments

@erlebach
Copy link

erlebach commented Oct 29, 2022

I have created a simple circuit with a single qbit, and defined a simple function creating a qbit. Applying the circuit to this qbit several times in a row changes the state of the input qbit. I demonstrate this below:

using cuYao, Plots

X1 = chain(1, put(1 => X))
bb = ArrayReg(bit"1")
state(bb  |> X1) 
state(bb |> X1)

Each time I apply the circuit to bb, the quantum bit flips. That would imply that the input qbit bb changes. The output of the code above, typed into REPL, is:

julia> state(bb |> X1)
2×1 Matrix{ComplexF64}:
 1.0 + 0.0im
 0.0 + 0.0im

julia> state(bb |> X1)
2×1 Matrix{ComplexF64}:
 0.0 + 0.0im
 1.0 + 0.0im

Why should it change? I do not understand. Thank you for any insight!

@erlebach
Copy link
Author

I answered my own question. I read that |> is equivalent to apply!, which overwrites the qbit that went through the circuit. So my question is: what was the rationale for overloading the pipe operator |>? I thought this operator was equivalent to | in the bash shell, it is very useful for clearer mathematical expressions. Overwriting it to mean apply! seems to complicate matters. Why not overload it to mean apply?

In an actual quantum computer, are there situations where the input qbit to a unitary transformation actually changes as the output is computed? I was not aware of that fact.

Thanks!

 Gordon

@Roger-luo
Copy link
Member

Hi thanks for the issue. It's been my greatest gripe since the beginning of this overload. Mainly because it cannot represent the in place behavior of apply!. But this is the only available pipe operator at the moment in Julia.

in quantum physics because there is non-cloning algorithm, a register is alway mutated in-place physically. Thus in practice we find this is quite convenient.

There has been proposal on supporting !> as a pipe operator that denotes in-place function more explicitly which is something we can consider in the future.

@Roger-luo Roger-luo added the question Further information is requested label Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants