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

Fix Lattice + OpenBC in batched drivers #5210

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

ye-luo
Copy link
Contributor

@ye-luo ye-luo commented Nov 6, 2024

Proposed changes

When using spline orbitals with boundary condition "n", legacy drivers does one more check when a step is proposed. If the new position is located out of the box in any of the direction marked "n", the proposed move is marked invalid. This bug fixes handled this case.

Think about running a single atom VMC using HF with QE WF and then use "n n n". if electrons are allowed outside the box, the wavefunction norm is infinite due to finite electron density everywhere. Confining electrons within the box prevents this bad situation effectively making electron density 0 outside the box.

Another note. makeMoveAndCheck also rejects moves larger than half of the box as long as a lattice is defined. This is not implemented in the batched API. However, this requires me to regenerate reference numbers for deterministic-diamondC_2x1x1_pp-vmcbatch-dmcbatch-mwalkers-serialized_sdj tests.

What type(s) of changes does this code introduce?

  • Bugfix

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Bora

Checklist

  • Yes. This PR is up to date with current the current state of 'develop'
  • Yes. Code added or changed in the PR has been clang-formatted

@ye-luo
Copy link
Contributor Author

ye-luo commented Nov 6, 2024

Test this please

…ialized_sdj reference values.

serialize calls makeMoveAndCheck which has outOfBound(displ) check.
@ye-luo
Copy link
Contributor Author

ye-luo commented Nov 6, 2024

Test this please

@ye-luo
Copy link
Contributor Author

ye-luo commented Nov 7, 2024

Series 0 is VMC, 1 is DMC.
Legacy

(base) yeluo@bora:/scratch3/yeluo/debug/TEST_batch_small/legacy$ qmca -q ev dmcleg.s00?.scalar.dat
 
                            LocalEnergy               Variance           ratio 
dmcleg  series 0  -36.538548 +/- 0.012871   3.494229 +/- 0.114336   0.0956 
dmcleg  series 1  -36.853090 +/- 0.003588   2.724231 +/- 0.018199   0.0739 

batch before fix

(base) yeluo@bora:/scratch3/yeluo/debug/TEST_batch_small/batch_bad$ qmca -q ev dmc.s00?.scalar.dat
 
                            LocalEnergy               Variance           ratio 
dmc  series 0  -31.004785 +/- 1.808544   21.503997 +/- 6.378338   0.6936 
dmc  series 1  -36.463603 +/- 0.007947   2.973913 +/- 0.021162   0.0816 

batch after fix

(base) yeluo@bora:/scratch3/yeluo/debug/TEST_batch_small/batch$ qmca -q ev dmc.s00?.scalar.dat
 
                            LocalEnergy               Variance           ratio 
dmc  series 0  -36.534624 +/- 0.013333   3.501475 +/- 0.144681   0.0958 
dmc  series 1  -36.852782 +/- 0.004356   2.705856 +/- 0.015095   0.0734 

@ye-luo
Copy link
Contributor Author

ye-luo commented Nov 7, 2024

Test this please

@prckent prckent added the bug label Nov 7, 2024
Copy link
Contributor

@prckent prckent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for tracking this down.

I was tempted to ask about masking the work in the use_drift section of VMCBatches.cpp:136+ and the similar section of DMCBatched.cpp:201+, where we might have invalid moves… but do you agree that updating the function signatures wouldn’t bring enough benefit given it is a rare event?

I will ask if we are certain it is safe to call the functions in these regions with invalid moves?

I think it is safe with the current implementations but the comments/docs for the WaveFunctionComponents and ParticleSet should be updated with a suitable note/warning that they have to handle arbitrary positions.

@ye-luo
Copy link
Contributor Author

ye-luo commented Nov 7, 2024

Calculating drift (flex_calcRatioGrad) is fine even positions are invalid because all our SPOs can be evaluated at any position. Jastrows are always defined throughout the space as required by LCAO molecule cases. There is no need to mask use_drift.

"handle arbitrary positions" is a vague requirement. Sometimes, we just need WFCs to run as the results will be discarded regardless. I don't think feel the necessity to put extra note on WFC which might cause unnecessary confusion to developers. The handling is at driver level with both ParticleSet and TWF involved, Individual WFC doesn't need to take responsibility.

PaticleSet yes, I added an extra note mw_makeMove, "Note that: drivers should reject invalid moves." PSdispatcher::flex_makeMove actually requires std::vector<bool>& are_valid return.

@prckent
Copy link
Contributor

prckent commented Nov 7, 2024

The code coverage report reminds us that the CoordsType::POS_SPIN code path is not hit here. Not a big deal given the simplicity and that we are presumably missing that in lots of places. Something to chip away at in future.

@prckent prckent merged commit 1405c8c into QMCPACK:develop Nov 7, 2024
42 of 43 checks passed
@ye-luo ye-luo deleted the fix-openbc-batch branch January 17, 2025 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants