-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
[unitaryhack] Updated molecular hydrogen tutorial #1296
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lockwo, thank you for submitting a PR to Mitiq! We will respond as soon as possible, and if you have any questions in the meantime, you can ask us on the Unitary Fund Discord.
Codecov Report
@@ Coverage Diff @@
## master #1296 +/- ##
==========================================
+ Coverage 98.13% 98.15% +0.01%
==========================================
Files 60 61 +1
Lines 2739 2762 +23
==========================================
+ Hits 2688 2711 +23
Misses 51 51
Continue to review full report at Codecov.
|
I think the check is unsuccessful ( |
Thanks @lockwo, very interesting! As a second option, we can try to add |
Thanks @lockwo. I like the fact that the hard coded table is replaced with values taken from
|
I expanded a bit on the function description. Is there anything specific you would like to see? As for the citation, I still see it there (in the image). Did you want that referenced again when talking about the coefficients? |
Great, this first suggestion worked! |
Hi @lockwo,
|
So the formula is the similar it just doesn't have the YY term (hence why the unmitigated case seems to do a tiny bit better it looks), the symmetry reduction comes from: https://arxiv.org/abs/1701.08213. However, this also makes it so the circuit doesn't need the initial X gate on the second qubit. I think a combination of your suggestions might work. Perhaps adding the exact description of the OF Hamiltonian in addition to providing the parameters from the original work might be a good way to do it. I will make those changes in a little bit to see how they look. |
Sounds good! Considering that unitaryhack will start in two weeks there is no rush. |
Alright, finally got around to making those changes. |
Thanks, @lockwo. Next week I'll make a proper review, but looks already very good! |
Sounds good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lockwo, I added some comments.
Please have a look when you have some time.
This is close to be accepted.
Very nice work.
qubit_operator = qubit_operator_to_pauli_sum(bk_op) | ||
return Observable(*qubit_operator) | ||
|
||
hamiltonians = [get_hamiltonian(i) for i in radii] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any simple way to show that these Hemiltonians have indeed the structure mentioned in the latex formula?
E.g. something like
print(get_hamiltonian( some_both_lenght))
.
Or any other way to check which Hamiltonian OpenFermion is actually producing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a print function for the hamiltonian, so you can see it is of the same form. Let me know if that is what you were looking for.
+1 this looks very neat, especially for the use of OpenFermion for the tabulated data instead of a hardcoded table. |
Co-authored-by: Andrea Mari <[email protected]>
Can you add the use of OpenFermion in the notebook title? To differentiate from #1337 that is done with PennyLane. |
Hmmm it has somehow broken the build, it works when I build locally. I see an error with the QAOA tutorial, but I'm not sure if that is the source (since this link is now dead: https://quantumai.google/cirq/tutorials/qaoa) I will fix it anyway and see |
That was the problem actually (not sure if you want to make that fix a separate PR, but it is in this one). |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @lockwo, LGTM!
And thanks for fixing the broken link too!
Moreover congratulations for merging a unitaryhack PR and so for getting the associated bounty!
This reverts commit fe58bb2.
Hi @lockwo, there was a problem with OpenFermion not working with Windows tests on the master branch. So we had to temporarily revert the merging commit. Of course we still want to have your example but we need to merge it more carefully. Could you open a new PR with the same code as this one? Re-opening this one is fine too (if possible). |
Just made it |
Description
This is made to address #1094. The goal is to address both components of that issue. I made it so the hamiltonian is calculated using openfermion. The hamiltonian is not the same as in the paper (still 2 qubits, just not the same ops). It would be very easy to programmatically change that, I just don't know how to do that exact symmetry reduction in openfermion. Additionally, the hamiltonian is a mitiq.Observable and the executor is no longer a wrapper for the energy function but just the density matrix simulator. I am new to mitiq so this second part is what I think that issue meant, but if it should change just let me know.
Checklist
Check off the following once complete (or if not applicable) after opening the PR. The PR will be reviewed once this checklist is complete and all tests are passing.
If some items remain, you can mark this a draft pull request.
License
Tips
If the validation check fails:
Run
make check-types
(from the root directory of the repository) and fix any mypy errors.Run
make check-style
and fix any flake8 errors.Run
make format
to format your code with the black autoformatter.For more information, check the Mitiq style guidelines.
Write "Fixes #XYZ" in the description if this PR fixes Issue #XYZ.