Closed willzeng closed 3 years ago
As another reference, I've done an experiment on how the optimization landscape looks like for different noise parameters when I was working on my VQF implementation, you can read the report here: https://github.com/mstechly/vqf/blob/master/research/2019_05_12_visualize_optimization_space/report/report.md .
And for some more realistic plots I recommend Fig 3 in https://arxiv.org/abs/2004.04197 .
I don't have time to work on this myself, but if anyone would like to, I'd be happy to chat :)
We may want to save this for some future hackathon events so I am gonna remove it from the milestone for now.
I've been looking for a project to work on this Summer and @rmlarose recommended I check out this issue. Would I be able to take on this task and work on it this Summer? I would probably be able to start on it in June.
Thanks @DSamuel1! Assigned to you.
I'm interested in solving this as part of the hackathon (as it appears on the project page), but the above conversation has me a little confused...is it cool if I give it a try?
@Misty-W Absolutely! Since these are examples in the docs, we can never have enough š If you have any other questions, feel free to ask here or on the Unitary Fund Discord.
Hi Sarah @crazy4pi314 , thanks for your reply! Iāve been working on the problem with PyQuil, but Iāve run into a few snags. To start, I used the problem shown in the Grove Noisy VQE tutorial at https://grove-docs.readthedocs.io/en/latest/vqe.html#links-and-further-reading as a kind of benchmark.
Thanks @Misty-W! I noticed your post and so I add my thoughts:
Hi Sarah @crazy4pi314 , thanks for your reply! Iāve been working on the problem with PyQuil, but Iāve run into a few snags. To start, I used the problem shown in the Grove Noisy VQE tutorial at https://grove-docs.readthedocs.io/en/latest/vqe.html#links-and-further-reading as a kind of benchmark.
Nice, a PyQuil example would be great!
- Whenever I run the VQE instance with the QVM from api.QVMConnection, I get the error 'QVMConnection' object has no attribute 'compile' I used a workaround noisy_qvm = get_qc("9q-square-noisy-qvm") to allow my code to run, but Iāll need to manipulate the noise level in the actual solution. Any ideas how to fix?
As far as I remember, one could define custom noise models by manually defining the associated Kraus operators. But I think your idea of using a simulated real device with noisy_qvm = get_qc("9q-square-noisy-qvm")
is even better and simpler.
In principle with Mitiq you can scale the noise indirectly by scaling the depth of your circuits without changing the physical noise of the beck-end (see e.g. here). So, maybe, you don't actually need to change the noise of the QVM.
- When using noisy_qvm, the result I obtained with ZNE didnāt make sense (6, when I believe the value should be close to -1). I also tried PEC but stopped it after running for ~ 1hr with no result.
I wouldn't use PEC in this example, since it requires the tomography of the gateset of your noisy QVM unless you manually define a custom noise model. ZNE is usually easier to apply but sometimes it may fail too. My suggestion is to start with the simplest extrapolation model factory = LinearFactory(scale_factors = [1.0, 3.0])
. If this fails too, there could be other problems.
a. I wrote an executable function to pass to the error mitigation function, and that executable calls the vqe.run. I realize now that's probably not the right approach. Shouldnāt the mitigation be performed on the intermediate expectation values, inside the āvqe runā? If so, then I assume I need to make my own VQE function and call the error mitigation function inside it. Unless there is another way?
The executor
function should take a circuit as input and return an expectation value. In a VQE algorithm there is a step in which the expectation value of the full Hamiltonian (or of its local terms) is evaluated from an input circuit. This is the step
in which Mitiq should be used. If your object grove.pyvqe.vqe.VQE
hides this step it may be a bit complicated to use Mitiq.
Maybe one needs to override the grove.pyvqe.vqe.VQE.expectation
method of this class...
b. Since the deadline is approaching, Iām not sure Iāll have time to create a VQE function from scratch and solve the original issue. Is it allowed to make a modified version? How do I credit the developers of the original function?
I would say that any nice example in which Mitiq is useful for solving a known NISQ algorithm is interesting. It doesn't need to be necessarily a VQE or MaxCut. Coping the code from some existing function is fine as long as credit is given. But these details can be fixed in a review process of a possible PR.
- Given the challenges Iām facing in PyQuil, would you recommend starting over in Qiskit instead? Iām new to both, but I do have an IBM-Q account, so maybe it would be easier to run on their devices.
Any quantum library is fine. We already have a Qiskit example in the docs and so it would be nice to have something in PyQuil. But this is not necessary.
Thanks for the suggestions @andreamari! I'll try them out and post any additional questions here.
@Misty-W I'm not sure if that's the case, but I discourage you from using VQE implementation in Grove, as it's not being maintained for over 2 years and has some bugs.
@mstechly thank you for the suggestion!
I opened a PR and tagged it [unitaryHACK]. The full flow doesn't run quite yet, but improvement suggestions are much appreciated.
@crazy4pi314, are you able to see my PR? I don't have much experience with GitHub, so I'm not sure if it ended up in the right place.
Even though the event is ending, I hope to get my code working and have the PR approved soon. It's been a lot of fun, and I really appreciate everyone's help! Special thanks to the organizers for setting it up!
@Misty-W I don't see your PR, did you make it to your own fork perhaps? If you want help getting it pushed to the right place just send me a DM on Discord and I can help ya out šŖ
@crazy4pi314, I think you're right. I just messaged you on Discord.
This issue had no activity for 2 months, and will be closed in one week unless there is new activity. Cheers!
Still working on this! Almost done I think.
Cool looking forward to it @Misty-W !
@willzeng I might have spoken a little too soon... my VQE example exhibited the desired behavior twice in a row, but I haven't been able to reproduce it since. Trying out some different noise models to see if that solves the problem.
This suggestion is inspired by a question from @mstechly.
"Have you seen an example where the landscape is flat without error mitigation and you can't optimize it, but becomes peaked with error mitigation and then you can optimize it?"
This would be a cool example to see and we could consider adding it to the documentation. It could even be for a relatively artificial variational problem, e.g. optimize some small ansatz against some example Hamiltonian using VQE.
Ideally the tutorial would show: