-
Notifications
You must be signed in to change notification settings - Fork 582
feat(jax): checkpoint I/O #4236
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f6b30bf
feat(jax): energy model (no grad support)
njzjz 3e13a33
address comments
njzjz fa9a000
export EnergyModel
njzjz d3b5ce3
jax2tf
njzjz 91ec084
apply flax_module to energy model
njzjz 14fab30
checkpoint
njzjz 390ace5
fix atomic model
njzjz a4cd627
apply flax_module
njzjz 71a4b55
checkpoint
njzjz 5024f70
done
njzjz f0bc8b8
add dependencies
njzjz 2a177df
Merge branch 'devel' into save-jax
njzjz 8c25e87
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7e003b2
Remove jax2tf
njzjz 536bbcd
Update pyproject.toml
njzjz f90fc52
update the model with the state
njzjz 9b571d1
fix is_available
njzjz fb3df8b
bugfix
njzjz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from deepmd.jax.common import ( | ||
| to_jax_array, | ||
| ) | ||
| from deepmd.jax.utils.exclude_mask import ( | ||
| AtomExcludeMask, | ||
| PairExcludeMask, | ||
| ) | ||
|
|
||
|
|
||
| def base_atomic_model_set_attr(name, value): | ||
| if name in {"out_bias", "out_std"}: | ||
| value = to_jax_array(value) | ||
| elif name == "pair_excl" and value is not None: | ||
| value = PairExcludeMask(value.ntypes, value.exclude_types) | ||
| elif name == "atom_excl" and value is not None: | ||
| value = AtomExcludeMask(value.ntypes, value.exclude_types) | ||
| return value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from typing import ( | ||
| Any, | ||
| ) | ||
|
|
||
| from deepmd.dpmodel.atomic_model.dp_atomic_model import DPAtomicModel as DPAtomicModelDP | ||
| from deepmd.jax.atomic_model.base_atomic_model import ( | ||
| base_atomic_model_set_attr, | ||
| ) | ||
| from deepmd.jax.common import ( | ||
| flax_module, | ||
| ) | ||
| from deepmd.jax.descriptor.base_descriptor import ( | ||
| BaseDescriptor, | ||
| ) | ||
| from deepmd.jax.fitting.base_fitting import ( | ||
| BaseFitting, | ||
| ) | ||
|
|
||
|
|
||
| @flax_module | ||
| class DPAtomicModel(DPAtomicModelDP): | ||
| base_descriptor_cls = BaseDescriptor | ||
| """The base descriptor class.""" | ||
| base_fitting_cls = BaseFitting | ||
| """The base fitting class.""" | ||
|
|
||
| def __setattr__(self, name: str, value: Any) -> None: | ||
| value = base_atomic_model_set_attr(name, value) | ||
| return super().__setattr__(name, value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,12 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from deepmd.jax.descriptor.dpa1 import ( | ||
| DescrptDPA1, | ||
| ) | ||
| from deepmd.jax.descriptor.se_e2_a import ( | ||
| DescrptSeA, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "DescrptSeA", | ||
| "DescrptDPA1", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from deepmd.dpmodel.descriptor.make_base_descriptor import ( | ||
| make_base_descriptor, | ||
| ) | ||
| from deepmd.jax.env import ( | ||
| jnp, | ||
| ) | ||
|
|
||
| BaseDescriptor = make_base_descriptor(jnp.ndarray) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,10 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from deepmd.jax.fitting.fitting import ( | ||
| DOSFittingNet, | ||
| EnergyFittingNet, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "EnergyFittingNet", | ||
| "DOSFittingNet", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| from deepmd.dpmodel.fitting.make_base_fitting import ( | ||
| make_base_fitting, | ||
| ) | ||
| from deepmd.jax.env import ( | ||
| jnp, | ||
| ) | ||
|
|
||
| BaseFitting = make_base_fitting(jnp.ndarray) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.