-
Notifications
You must be signed in to change notification settings - Fork 582
Add pt compress commad line #4300
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
33 commits
Select commit
Hold shift + click to select a range
13f8620
add pt compress commad line
cherryWangY cfca381
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 28e0f95
seperate compress
cherryWangY 5ba079f
add compress suffix support
cherryWangY 6e20942
fix compress argument
cherryWangY 33e6417
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7985bc0
remove redundant code
cherryWangY 2d0bbbc
add file suffix for compress
cherryWangY b9acf04
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0afd3f3
Merge remote-tracking branch 'upstream/devel' into addCommandLine
cherryWangY 14ac57b
add pt command line end-to-end test
cherryWangY c91b8bb
add main for test
cherryWangY f087949
Merge remote-tracking branch 'upstream/devel' into addCommandLine
cherryWangY b186980
fix(pt): store `min_nbor_dist` in the state dict
njzjz d84e32c
Merge pull request #1 from njzjz/pt-fix-min-nbor-dist-state-dict
cherryWangY 41b5c2b
Merge branch 'addCommandLine' of https://github.com/cherryWangY/deepm…
cherryWangY 0ed83bb
info type error version
cherryWangY 232511e
add ParameterDict for compression
cherryWangY 1e6d388
Merge branch 'addCommandLine' of https://github.com/cherryWangY/deepm…
cherryWangY 9d36d83
this seems work
njzjz 73d7414
Merge branch 'addCommandLine' of https://github.com/cherryWangY/deepm…
cherryWangY 03ed3c7
vectorized tabulate
cherryWangY 1463745
add ParameterList for pt compression command line
cherryWangY ce089b9
fix device error
cherryWangY 7d8d190
try to fix min_nbor_list assign error
cherryWangY fe552fb
change compress examples and default value
cherryWangY b38a62e
remove redundant notaion
cherryWangY 5dd73df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2016a94
set default value and examples
cherryWangY d4fc7ef
remove redundant code
cherryWangY a84f161
Merge branch 'devel' into addCommandLine
njzjz 33d5fd9
fix tests
njzjz dbae8d0
fix failing tests
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # SPDX-License-Identifier: LGPL-3.0-or-later | ||
| import json | ||
|
|
||
| import torch | ||
|
|
||
| from deepmd.pt.model.model import ( | ||
| get_model, | ||
| ) | ||
|
|
||
|
|
||
| def enable_compression( | ||
| input_file: str, | ||
| output: str, | ||
| stride: float = 0.01, | ||
| extrapolate: int = 5, | ||
| check_frequency: int = -1, | ||
| ): | ||
| saved_model = torch.jit.load(input_file, map_location="cpu") | ||
| model_def_script = json.loads(saved_model.model_def_script) | ||
| model = get_model(model_def_script) | ||
| model.load_state_dict(saved_model.state_dict()) | ||
|
|
||
| model.enable_compression( | ||
| extrapolate, | ||
| stride, | ||
| stride * 10, | ||
| check_frequency, | ||
| ) | ||
|
|
||
| model = torch.jit.script(model) | ||
| torch.jit.save(model, output) | ||
cherryWangY marked this conversation as resolved.
Show resolved
Hide resolved
cherryWangY marked this conversation as resolved.
Show resolved
Hide resolved
cherryWangY marked this conversation as resolved.
Show resolved
Hide resolved
cherryWangY marked this conversation as resolved.
Show resolved
Hide resolved
njzjz marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,6 @@ | ||
| 0 | ||
| 1 | ||
| 1 | ||
| 0 | ||
| 1 | ||
| 1 |
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,2 @@ | ||
| O | ||
| H |
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,85 @@ | ||
| { | ||
| "_comment1": " model parameters", | ||
| "model": { | ||
| "type_map": [ | ||
| "O", | ||
| "H" | ||
| ], | ||
| "descriptor": { | ||
| "type": "se_e2_a", | ||
| "sel": [ | ||
| 46, | ||
| 92 | ||
| ], | ||
| "rcut_smth": 0.50, | ||
| "rcut": 6.00, | ||
| "_comment": "N2=2N1, N2=N1, and otherwise can be tested", | ||
| "neuron": [ | ||
| 4, | ||
| 8, | ||
| 17, | ||
| 17 | ||
| ], | ||
| "resnet_dt": false, | ||
| "axis_neuron": 16, | ||
| "seed": 1, | ||
| "_comment2": " that's all" | ||
| }, | ||
| "fitting_net": { | ||
| "neuron": [ | ||
| 20, | ||
| 20, | ||
| 20 | ||
| ], | ||
| "resnet_dt": true, | ||
| "seed": 1, | ||
| "_comment3": " that's all" | ||
| }, | ||
| "_comment4": " that's all" | ||
| }, | ||
|
|
||
| "learning_rate": { | ||
| "type": "exp", | ||
| "decay_steps": 5000, | ||
| "start_lr": 0.001, | ||
| "stop_lr": 3.51e-8, | ||
| "_comment5": "that's all" | ||
| }, | ||
|
|
||
| "loss": { | ||
| "type": "ener", | ||
| "start_pref_e": 0.02, | ||
| "limit_pref_e": 1, | ||
| "start_pref_f": 1000, | ||
| "limit_pref_f": 1, | ||
| "start_pref_v": 0, | ||
| "limit_pref_v": 0, | ||
| "_comment6": " that's all" | ||
| }, | ||
|
|
||
| "training": { | ||
| "training_data": { | ||
| "systems": [ | ||
| "model_compression/data" | ||
| ], | ||
| "batch_size": "auto", | ||
| "_comment7": "that's all" | ||
| }, | ||
| "validation_data": { | ||
| "systems": [ | ||
| "model_compression/data" | ||
| ], | ||
| "batch_size": 1, | ||
| "numb_btch": 3, | ||
| "_comment8": "that's all" | ||
| }, | ||
cherryWangY marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "numb_steps": 1, | ||
| "seed": 10, | ||
| "disp_file": "lcurve.out", | ||
| "disp_freq": 1, | ||
| "save_freq": 1, | ||
| "_comment9": "that's all" | ||
| }, | ||
cherryWangY marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| "_comment10": "that's all" | ||
| } | ||
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.