Skip to content

cc: add torch backend support for Multiple backend #3162

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 122 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
dac7a76
add torch backend support
CaRoLZhangxy Jan 22, 2024
d3befec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
0512118
fix some bugs and add atomic output
CaRoLZhangxy Jan 25, 2024
e7a5cb7
Merge branch 'devel' into devel
CaRoLZhangxy Jan 25, 2024
018a035
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
5ebb9bf
fix atom compute bugs
CaRoLZhangxy Jan 25, 2024
6924e06
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
26217bf
fix bugs
CaRoLZhangxy Jan 25, 2024
5e52ede
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Jan 25, 2024
c9bbd83
include deeppotpt.h
CaRoLZhangxy Jan 25, 2024
54e8166
add float and vector energytype implement
CaRoLZhangxy Jan 25, 2024
8f0219b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
0a8e19e
modify pt nlistdata name
CaRoLZhangxy Jan 25, 2024
ecd6651
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Jan 25, 2024
02cf214
fix some bugs
CaRoLZhangxy Jan 25, 2024
1d5fb1c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
f8dab4d
fix bug
CaRoLZhangxy Jan 25, 2024
795058c
fix bug
CaRoLZhangxy Jan 25, 2024
a3cd2ef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
f4c6901
fix compute api
CaRoLZhangxy Jan 25, 2024
a9c47ec
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Jan 25, 2024
08ea8df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
ca70171
Deprecated valuetype
CaRoLZhangxy Jan 25, 2024
7c66cf7
Deprecated valuetype
CaRoLZhangxy Jan 25, 2024
b9c74db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
295751c
fix compute definition
CaRoLZhangxy Jan 26, 2024
fc3040b
implement virtual function
CaRoLZhangxy Jan 26, 2024
3e70a28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
1576fbb
fix bug
CaRoLZhangxy Jan 26, 2024
af415f4
try direct =
CaRoLZhangxy Jan 26, 2024
306f7d9
fix vtype and type bug
CaRoLZhangxy Jan 26, 2024
39a8de4
fix energy to vector
CaRoLZhangxy Jan 26, 2024
c86c14e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
a2e2144
using namespace deepmd
CaRoLZhangxy Jan 26, 2024
e9b1078
fix bug
CaRoLZhangxy Jan 26, 2024
18c8cd3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
6b27552
pass no backend test
CaRoLZhangxy Jan 26, 2024
0d494b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
b1cc754
implement detect backend
CaRoLZhangxy Jan 26, 2024
cedcdc7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
d157a4f
fix compilation error
njzjz Jan 26, 2024
522b7c8
a backet is missing...
njzjz Jan 26, 2024
f75dab6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
46f17ef
Merge branch 'deepmodeling:devel' into devel
CaRoLZhangxy Feb 3, 2024
6750312
fix model inference interface and add cpu
CaRoLZhangxy Feb 3, 2024
0a3e208
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2024
3de36b0
fix bug: device init
CaRoLZhangxy Feb 3, 2024
7bb1b1c
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 3, 2024
e5d1533
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2024
e61a509
fix bug: device constructor
CaRoLZhangxy Feb 3, 2024
6c4a641
fix bug:device constructor
CaRoLZhangxy Feb 3, 2024
f0c1742
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 3, 2024
22d1a7e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2024
a68742d
add tests, although not passed
njzjz Feb 3, 2024
e7a8878
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 20, 2024
9bcd8b7
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 21, 2024
ba510e8
fix memory leak and nlist dim
CaRoLZhangxy Feb 23, 2024
f05570b
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 23, 2024
936b29a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
93c9ddb
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 23, 2024
16a3e6b
get cublasCreate(handle) error local
CaRoLZhangxy Feb 23, 2024
7245470
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
7b92391
fix error in no nlist impl
CaRoLZhangxy Feb 23, 2024
077473c
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 23, 2024
fc084db
fix loading info
CaRoLZhangxy Feb 23, 2024
93dacb6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
eda885a
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 26, 2024
8b49cf1
pass cpu test
CaRoLZhangxy Feb 26, 2024
12c2796
download libtorch in test_cuda action
njzjz Feb 26, 2024
b390e6a
install wget...
njzjz Feb 26, 2024
48c1759
install unzip
njzjz Feb 26, 2024
768dd93
update the frozen model
njzjz Feb 26, 2024
2af65a7
update test ret
njzjz Feb 26, 2024
e9f582f
try to fix float type error
CaRoLZhangxy Feb 26, 2024
90e28a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 26, 2024
19099e2
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
fdeb914
fix memory bug
CaRoLZhangxy Feb 27, 2024
89e151b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
fc18da6
fix bug: precision diff in model and inference api
CaRoLZhangxy Feb 27, 2024
cb5fe58
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
55db59a
Merge branches 'devel' and 'devel' of https://github.com/CaRoLZhangxy…
CaRoLZhangxy Feb 27, 2024
e6dc86a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
f960626
try to fix overflow
CaRoLZhangxy Feb 27, 2024
9627078
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
6ba4125
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
d169d81
fix compile error
CaRoLZhangxy Feb 27, 2024
eea944e
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
e77f5f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
7cb94ae
try to fix overflow
CaRoLZhangxy Feb 27, 2024
ed453fd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
3a06dbf
update model
CaRoLZhangxy Feb 27, 2024
db798a7
try to fix nopbc
CaRoLZhangxy Feb 27, 2024
0a440c5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
bb45b40
try to export ut output
CaRoLZhangxy Feb 27, 2024
75c8bb9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
0450873
try to export ut input
CaRoLZhangxy Feb 27, 2024
19e3cd5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
5da17cb
modify output
CaRoLZhangxy Feb 27, 2024
e4b3265
try
CaRoLZhangxy Feb 27, 2024
55db21f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
600e534
try
CaRoLZhangxy Feb 27, 2024
7ba3fcf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
3be3cbc
delete print
CaRoLZhangxy Feb 27, 2024
1785cbd
get extended coord and atype
CaRoLZhangxy Feb 27, 2024
962cf64
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
b005365
delete output
CaRoLZhangxy Feb 27, 2024
499ed17
remove memset
CaRoLZhangxy Feb 28, 2024
f872b1f
try to resize atom energy
CaRoLZhangxy Feb 28, 2024
aab6771
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
414fffe
fix atom ener size
CaRoLZhangxy Feb 28, 2024
f3f6402
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
c074687
precision transfer in common api and skip type sel tests
CaRoLZhangxy Feb 28, 2024
de0e3ab
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 28, 2024
b1ad4bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
1fa1afc
del ener model precison
CaRoLZhangxy Feb 28, 2024
4464966
updata test model
CaRoLZhangxy Feb 28, 2024
011f157
fix LD_LIBRARY_PATH
njzjz Feb 28, 2024
8d6c11c
fix codeql warning
njzjz Feb 28, 2024
99dd474
add tests for ipi and lammps
njzjz Feb 28, 2024
f4a3271
fix model path
njzjz Feb 28, 2024
1e8bdff
consistent box
njzjz Feb 28, 2024
da18860
remove commented codes
njzjz Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
TF_INTRA_OP_PARALLELISM_THREADS: 1
TF_INTER_OP_PARALLELISM_THREADS: 1
LAMMPS_PLUGIN_PATH: ${{ github.workspace }}/dp_test/lib/deepmd_lmp
LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib
LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib:${{ github.workspace }}/libtorch/lib
if: ${{ !matrix.check_memleak }}
# test ipi
- run: pytest --cov=deepmd source/ipi/tests
Expand All @@ -65,7 +65,7 @@ jobs:
TF_INTRA_OP_PARALLELISM_THREADS: 1
TF_INTER_OP_PARALLELISM_THREADS: 1
PATH: ${{ github.workspace }}/dp_test/bin:$PATH
LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib
LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib:${{ github.workspace }}/libtorch/lib
if: ${{ !matrix.check_memleak }}
- uses: codecov/codecov-action@v4
env:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/test_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
with:
useLocalCache: true
useCloudCache: false
- name: Install wget and unzip
run: apt-get update && apt-get install -y wget unzip
- run: |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \
&& sudo dpkg -i cuda-keyring_1.0-1_all.deb \
Expand All @@ -53,7 +55,13 @@ jobs:
DP_ENABLE_NATIVE_OPTIMIZATION: 1
- run: dp --version
- run: python -m pytest source/tests --durations=0
- run: source/install/test_cc_local.sh
- name: Download libtorch
run: |
wget https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.2.1%2Bcu121.zip -O libtorch.zip
unzip libtorch.zip
- run: |
export CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/libtorch
source/install/test_cc_local.sh
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
Expand All @@ -63,7 +71,7 @@ jobs:
DP_VARIANT: cuda
DP_USE_MPICH2: 1
- run: |
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/dp_test/lib:$CUDA_PATH/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/dp_test/lib:$GITHUB_WORKSPACE/libtorch/lib:$CUDA_PATH/lib64:$LD_LIBRARY_PATH
export PATH=$GITHUB_WORKSPACE/dp_test/bin:$PATH
python -m pytest source/lmp/tests
python -m pytest source/ipi/tests
Expand Down
7 changes: 7 additions & 0 deletions deepmd/pt/model/model/make_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
communicate_extended_output,
fit_output_to_model_output,
)
from deepmd.pt.utils import (
env,
)
from deepmd.pt.utils.nlist import (
extend_input_and_build_neighbor_list,
nlist_distinguish_types,
Expand Down Expand Up @@ -115,6 +118,9 @@ def forward_common(
The keys are defined by the `ModelOutputDef`.

"""
coord = coord.to(env.GLOBAL_PT_FLOAT_PRECISION)
if box is not None:
box = box.to(env.GLOBAL_PT_FLOAT_PRECISION)
(
extended_coord,
extended_atype,
Expand Down Expand Up @@ -183,6 +189,7 @@ def forward_common_lower(
the result dict, defined by the `FittingOutputDef`.

"""
extended_coord = extended_coord.to(env.GLOBAL_PT_FLOAT_PRECISION)
nframes, nall = extended_atype.shape[:2]
extended_coord = extended_coord.view(nframes, -1, 3)
nlist = self.format_nlist(extended_coord, extended_atype, nlist)
Expand Down
Loading