Skip to content

Conversation

@ErjieWu
Copy link
Collaborator

@ErjieWu ErjieWu commented Apr 11, 2025

Linked Issue

Fix #6107

Unit Tests and/or Case Tests for my changes

  • Add integrate test for v_delta(k) label for multi-k cases in DeePKS.
  • Add integrate test for deepks_out_labels=2 in multi-k cases.
  • Add relax/md/nscf tests for DeePKS.
  • Change the unit test for multi-k case.
  • Add unit test for orbital and orbpre calculations in DeePKS.
  • Add unit test for vdpre calculation in DeePKS.
  • Rearrange the tests for DeePKS:
    • Rename their names, 100 for UT, 101 for orbital generation, 102 for DeePKS applications, 103 for trainning files generation with different labels, 104 for DeePKS label preparation.
    • Change the checking terms to match different cases.
    • Add notes for each integrate test using now.
  • Temporarily close the check for gedm in DeePKS UT since there's a numerical difference caused by different environments (GNU vs intel).

What's changed?

  • Add some check functions used for unit tests in DeePKS.
  • Add support for complex number checking in DeePKS unit tests.

@ErjieWu
Copy link
Collaborator Author

ErjieWu commented Apr 11, 2025

I found that the reference files for vdpre is extremely large and is difficult to be reduced effectively. I don't know whether to add it or keep the original situation (no checks for vdpre). @mohanchen

@mohanchen mohanchen added Refactor Refactor ABACUS codes Machine Learning Issues related to the DeePKS Unit Tests/Integreate Tests Issues/PR related to unit tests and integrate tests labels Apr 12, 2025
@ErjieWu
Copy link
Collaborator Author

ErjieWu commented Apr 15, 2025

I change the multi-k UT by using SZ orbitals for H2O, which significantly reduces the lines of reference files. Also number of K-point is setting to 5 3 1 (avoid using 2 2 2, which may not catch the falut caused by sign problems).

@ErjieWu
Copy link
Collaborator Author

ErjieWu commented Apr 16, 2025

The result for UT differs in different machine. Seems like a hidden bug is not found yet. Not ready for merge.

@ErjieWu
Copy link
Collaborator Author

ErjieWu commented Apr 22, 2025

I found that the source of the difference is the compilation using Intel or GNU. The step where the difference occurs is the step of calling torch::autograd::grad() in the cal_edelta_gedm() function. The differences in values in the test samples can be greater than 1e-4 and thus cannot be ignored. I'm not sure if it is caused by the underlying implementation of Pytorch. Currently, I'm trying to upgrade the version of libtorch to observe whether these differences in different environments will disappear.

@ErjieWu
Copy link
Collaborator Author

ErjieWu commented Apr 22, 2025

@mohanchen
I've tried different version of libtorch and use both intel&GNU compiler for test. The result shows that:

  • For GNU, all the results are the same for different version of libtorch.
  • For intel, the results are different from GNU, but same in version <2.5.0. For libtorch=2.5.0 (highest version support for ABACUS now), the results is different from both GNU result and intel results of other versions.

Currently, the result in this pr is from GNU version.

@ErjieWu ErjieWu reopened this Apr 28, 2025
@ErjieWu
Copy link
Collaborator Author

ErjieWu commented Apr 29, 2025

I've already accelerated these testing process now and closed the check for gedm temporarily.
Ready for merge. @mohanchen

@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge Input&Output Suitable for coders without knowing too many DFT details The Absolute Zero Reduce the "entropy" of the code to 0 labels Apr 29, 2025
@mohanchen mohanchen merged commit 0dc5e8b into deepmodeling:develop Apr 29, 2025
14 checks passed
@ErjieWu ErjieWu deleted the refactor branch April 30, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Features Needed The features are indeed needed, and developers should have sophisticated knowledge Input&Output Suitable for coders without knowing too many DFT details Machine Learning Issues related to the DeePKS Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 Unit Tests/Integreate Tests Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test required for new labels in DeePKS.

2 participants