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

Just a Question: why not use quatnum AD in some examples? #17

Closed
EigenSolver opened this issue May 29, 2020 · 5 comments
Closed

Just a Question: why not use quatnum AD in some examples? #17

EigenSolver opened this issue May 29, 2020 · 5 comments
Labels
question Further information is requested

Comments

@EigenSolver
Copy link
Contributor

Still shocked by the first example given in Yao.jl paper (which got 300,000 parameters)...

😃. I am just wondering why don't you use automatic differentiation in the examples like QAOA or VQE...(I mean, something like expect', and !dispatch maybe).

Actually COBYLA is used in QAOA and VQE uses ADAM as optimizer, it seems like there is no calculation for gradient...

I consider AD one of the most powerful features of Yao, so confusing..

@Roger-luo
Copy link
Member

Thanks for your question. Unfortunately, we have poor tutorials at this moment.

VQE is using AD to get the gradient. not sure why you think it's not.
https://github.com/QuantumBFS/QuAlgorithmZoo.jl/blob/master/examples/VQE/VQE.jl#L59

if you check the date of QAOA example, it is written in pre-AD era (17 months ago).

@GiggleLiu might have some other comments.

@Roger-luo Roger-luo added the question Further information is requested label May 29, 2020
@GiggleLiu
Copy link
Member

COBYLA is used in QAOA and VQE uses ADAM as optimizer

ADAM requires gradients and we have already used the gradient here.

grad_input, grad_params = expect'(hami, zero_state(N) => c)

It should be possible to train QAOA with gradient as well, however, the parameters are shared in QAOA. One can combine Zygote and Yao to achieve parameter sharing.

QuantumBFS/CuYao.jl#56

@GiggleLiu
Copy link
Member

The QAOA example requires some polish though. I will look into it later.

@EigenSolver
Copy link
Contributor Author

Yep..I noticed ADAM. By the way I just tried VQE on 4 qubits H2 (under Jordan-Weiger transformation) with Yao and OpenFermion. (Has given a PR)

Also I tried AD on QAOA, it's so fast. (毕设看到了希望:pray: .. 感激不尽)

Think this issue can be closed now, thanks for answer.

@GiggleLiu
Copy link
Member

Great, 希望毕业顺利!

BTW: In our example, we used the time evolution in QAOA, which is not nesseary in that case. One can use rot(kron(Z, Z), theta) to decompose the time evolution, so that the simulation can go faster (one need to share parameter though).

We didn't use this trick for that in real experiment, the Hamiltonian can be different and such decomposition is not always possible.

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

3 participants