-
Notifications
You must be signed in to change notification settings - Fork 27
Resolving bug in low_rank and updated interface for exact evolution #128
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
Conversation
Resolves bug #127 which notices the incorrect usage of inplace. Also udpate the exact time evolution algorithm so FQE warns the user when the Taylor or Chebyshev expansions do not converge.
The Taylor expansion and Chebyshev expansion code had a hard stop at 30 terms and the interface to `apply_generated_unitary` had a true zero as the accuracy (which is never achieved in practice). Adjusting the code such that we no longer require true zero but instead numerical zero of 1.E-15 revealed a number of problems associated with taking a very long time and possible issues with inplace evolution. I will open issues for these after this PR. The algorithms update for Givens rotation and doubles evolution now no longer uses inplace evolution which seems to behave correctly.
inplace is behaving weirdly so for now overwrite the wavefunction in the appropriate `algorithms'
When running tests for debugging I added a main to run individual tests locally. I am now removing it.
|
@awhite862 can you request to review this? |
awhite862
left a comment
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.
Just a few minor things. The only major thing is fixing the reference data in the tests. Looks good otherwise!
| else: | ||
| base = self | ||
|
|
||
| max_expansion = max(30, expansion) |
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.
If you remove the max expansion order, maybe add a check (raise a ValueError or something) if it is unreasonably large?
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'll add a check for expansion being an integer. That way the user can't input a np.nan, np.inf, float...something that would make the loop fail.
tests/adapt_vqe_test.py
Outdated
| from tests.unittest_data.generate_openfermion_molecule import ( | ||
| build_lih_moleculardata,) | ||
|
|
||
| import pytest |
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.
duplicate import?
tests/fqe_decorators_test.py
Outdated
|
|
||
| if __name__ == "__main__": | ||
| test_evolve_spinful_fermionop() | ||
| # test_evolve_spinful_fermionop() |
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.
remove comment
| import fqe | ||
| from fqe.hamiltonians import general_hamiltonian | ||
| from tests.unittest_data.build_nh_data import build_nh_data | ||
| import pytest |
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.
import order: pytest should go with the other 3rd party imports
| # 'apply_array', 'apply_sparse', 'apply_diagonal', 'apply_quadratic', | ||
| # 'apply_dc' | ||
| # ]]) | ||
| @pytest.mark.skip(reason="Test seems to be failing due to bad reference_data") |
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 think if you put the skip above the parametrize it just skips all of them and you don't need to comment them out
| from tests.unittest_data.generate_openfermion_molecule import ( | ||
| build_lih_moleculardata,) | ||
|
|
||
| import pytest |
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.
woops this should go above
tests/davidson_test.py
Outdated
| import copy | ||
| from tests.unittest_data.build_lih_data import build_lih_data | ||
| from fqe.algorithm import davidson | ||
| import pytest |
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.
this too
awhite862
left a comment
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.
lgtm!
Resolves bug #127 which notices the incorrect usage of inplace.
Also udpate the exact time evolution algorithm so FQE warns the user when the Taylor or Chebyshev expansions do not converge.