Skip to content

Conversation

@iProzd
Copy link
Collaborator

@iProzd iProzd commented Feb 19, 2024

This PR support DPSpin for AtomicModel:

  • Spin base class to handle spin-related information.

  • SpinModel implementation in pt, which can generally take any backbone model, with input and output process for output like energy, dipole and etc.

  • SpinEnergyModel implementation inherited from SpinModel for energy calclulation.

  • Input improvement, now DPSpin model can take real spin as input with vitual_scale, which can support much more flexible input. (Also with dataset support for spin input.)

  • EnergySpinLoss class to process energy, force_real, force_mag, virial.

  • Add protection for environment calculations.

TODO:

  • Support forward_lower for SpinModel.
  • Add data_stat with general exclude_types for descriptors and fittings.
  • Add examples and UTs.
  • numpy model
  • Support multi-task training for SpinModel models.

Will fix in next PRs:

  • tf consistency test (?)

@codecov
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: Patch coverage is 83.60656% with 140 lines in your changes are missing coverage. Please review.

Project coverage is 77.04%. Comparing base (fa8e645) to head (c0700c9).

Files Patch % Lines
deepmd/dpmodel/model/spin_model.py 68.96% 45 Missing ⚠️
deepmd/pt/loss/ener_spin.py 69.15% 33 Missing ⚠️
deepmd/utils/spin.py 82.55% 15 Missing ⚠️
deepmd/dpmodel/model/model.py 33.33% 14 Missing ⚠️
deepmd/entrypoints/test.py 66.66% 12 Missing ⚠️
deepmd/pt/infer/deep_eval.py 83.33% 12 Missing ⚠️
deepmd/dpmodel/utils/exclude_mask.py 50.00% 3 Missing ⚠️
deepmd/pt/train/training.py 78.57% 3 Missing ⚠️
deepmd/pt/model/model/spin_model.py 99.54% 1 Missing ⚠️
deepmd/tf/descriptor/se_a.py 66.66% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3301      +/-   ##
==========================================
+ Coverage   76.97%   77.04%   +0.06%     
==========================================
  Files         423      394      -29     
  Lines       35950    31948    -4002     
  Branches     1620      909     -711     
==========================================
- Hits        27674    24613    -3061     
+ Misses       7408     6807     -601     
+ Partials      868      528     -340     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@wanghan-iapcm wanghan-iapcm left a comment

Choose a reason for hiding this comment

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

  • UT for all the spin implementations.
  • env_protection should be added to dpmodel
  • UT for env_protection.
  • the implementation of the dpmodel is not consistent with the pt side.

pref_e = self.limit_pref_e + (self.start_pref_e - self.limit_pref_e) * coef
pref_fr = self.limit_pref_fr + (self.start_pref_fr - self.limit_pref_fr) * coef
pref_fm = self.limit_pref_fm + (self.start_pref_fm - self.limit_pref_fm) * coef
pref_v = self.limit_pref_v + (self.start_pref_v - self.limit_pref_v) * coef

Check notice

Code scanning / CodeQL

Unused local variable

Variable pref_v is not used.
Copy link
Collaborator

@wanghan-iapcm wanghan-iapcm left a comment

Choose a reason for hiding this comment

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

I see

@iProzd iProzd requested review from njzjz and wanghan-iapcm March 7, 2024 07:38

class SpinTest(unittest.TestCase):
def setUp(self):
type_map_1 = ["H", "O"]

Check notice

Code scanning / CodeQL

Unused local variable

Variable type_map_1 is not used.
self.use_spin_1 = [False, False]
self.virtual_scale_1 = [0.1, 0.1]

type_map_2 = ["B", "Ni", "O"]

Check notice

Code scanning / CodeQL

Unused local variable

Variable type_map_2 is not used.
self.use_spin_2 = [False, True, False]
self.virtual_scale_2 = [0.1, 0.1, 0.1]

type_map_3 = ["H", "O", "B", "Ni", "O"]

Check notice

Code scanning / CodeQL

Unused local variable

Variable type_map_3 is not used.
@wanghan-iapcm
Copy link
Collaborator

LGTM

@njzjz njzjz enabled auto-merge March 7, 2024 17:22
@njzjz njzjz added this pull request to the merge queue Mar 7, 2024
Merged via the queue into deepmodeling:devel with commit 09bd522 Mar 7, 2024
@iProzd iProzd deleted the spin_rf branch March 28, 2024 07:40
@njzjz njzjz mentioned this pull request Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants