Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

The different behaviors between expect and expect' when inputting a pair of register and circuit #139

Open
frankwswang opened this issue Jun 15, 2020 · 0 comments

Comments

@frankwswang
Copy link

frankwswang commented Jun 15, 2020

I was reading the documentation of Yao and found that in the description of function expect', the Note (blue box) says that expect' is a slight modification of expect for the cases of batched registers when we input a pair of register and circuit, which I assume implies that expect can also return gradients.

However, it is also stated that "expect" only returns the expectation value of the observable, which is contradictory to the Note (blue box).

From my test

julia> expect(h, zero_state(4) => c) == expect(h, zero_state(4) |> c)
true
julia> expect'(h, zero_state(4)|>c)
ArrayReg{1, Complex{Float64}, Array...}
    active qubits: 4/4

So it seems that expect just returns the expectation value in either case and expect' doesn't return expectation value even when we don't input the pair of register and circuit.

Do you intend to differ expect and expect' by just the functionality of accumulating the outputs for multiple-batch cases? Or do you want to specify expect' as the function to get gradients of a differentiable circuit? So far I find the logic and documentation about those two functions are a bit confusing.

Also, I think it would be better if you could specify the requirement of the circuit inside the input pair. Does it have to be the variational_circuit from YaoExtension.jl or can it be any parameterized circuit but marked with differentiable blocks?

Thank you very much!

@frankwswang frankwswang changed the title Has the functionality of expect' already changed? Should expect return gradients of parameters when inputting a pair of register and circuit? Jun 17, 2020
@frankwswang frankwswang changed the title Should expect return gradients of parameters when inputting a pair of register and circuit? The different behaviors between expect and expect' when inputting a pair of register and circuit Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant