Skip to content
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

enable use of CVs defined by PyTorch neural network models #570

Merged
merged 109 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
a6f8e84
In the process of implementing torchann colvar
zwpku May 13, 2022
12c4ac7
Merge branch 'master' of https://github.com/zwpku/colvars
zwpku May 13, 2022
6336c4b
Implementing torchann
zwpku May 14, 2022
0d6c2c6
Implemented calc_gradients and apply_forces
zwpku May 15, 2022
80a293e
Start working
zwpku May 16, 2022
6275dfb
Handling periodicity; test torchANN with phi angle
zwpku May 20, 2022
2d06095
Add output_index to specify the component of output layer that is used
zwpku May 24, 2022
eb5cfe5
update with upstream
Feb 8, 2023
70ef673
up
zwpku Feb 9, 2023
c4aa08b
Update gromacs-2021.6 patch
zwpku Feb 10, 2023
3363f39
modify patch files for namd to support LibTorch
zwpku Feb 11, 2023
56ee5d1
Merge branch 'Colvars:master' into torchann
zwpku Mar 13, 2023
3711f0d
updated with upstream:master
Jul 20, 2023
3f5eb82
Add test for torchann
Jul 21, 2023
45064d6
Merge pull request #1 from zwpku/torchann1
zwpku Jul 21, 2023
2edb0ff
minor changes
zwpku Jul 21, 2023
5a781d8
Modified test for torchann component
zwpku Aug 2, 2023
4776e5e
Add figures for AutoEncoder CV
Aug 2, 2023
41f5618
Convert unit of atom coordinates to angstrom before feeding to torch …
zwpku Aug 3, 2023
66b69b4
Bug fixed in gradient of torchann
zwpku Aug 3, 2023
53bbf6a
Add Torch in lammps' cmake
Aug 10, 2023
c049f84
Added test files for torchann in NAMD
Aug 14, 2023
c68df86
Merge branch 'Colvars:master' into torchann
zwpku Aug 14, 2023
2c5ae86
Minor changes in torchann component
zwpku Aug 14, 2023
1286028
Updated patches for Gromacs 2020.x and 2022.x
Aug 15, 2023
78789ed
Updated torchann in header file; Removed test for torchann component
Aug 15, 2023
13753ff
Add tests for Gromacs and NAMD
zwpku Aug 15, 2023
0ae580c
Add tests for Gromacs and NAMD
zwpku Aug 15, 2023
47f4a87
Updated torchann-namd test and references
zwpku Aug 15, 2023
b59830c
Reimplement torchann as a derived class of LinearCombination
zwpku Aug 24, 2023
ce24547
declare torchann cvc as scalar
zwpku Aug 24, 2023
57c8502
allocate memory of cv_force before use
zwpku Aug 25, 2023
388c6be
c++17 instead of c++14
Aug 25, 2023
7d3b23e
removed file to correct place
Aug 25, 2023
a08ed74
removed file to correct place
Aug 25, 2023
c3de09c
Minor correction in apply_force of torchann
zwpku Aug 26, 2023
2230af1
Add tests for gromacs and NAMD
zwpku Aug 26, 2023
bbe0360
merged with master
zwpku Aug 26, 2023
21ee264
Modified the definition of cv_force such that it contains the informa…
zwpku Aug 28, 2023
94034f8
Add option to set data type in torchann
zwpku Aug 30, 2023
d2e34ea
Add option to set data type in torchann
zwpku Aug 30, 2023
3acc188
Enable GPU support; Further tests are needed.
Aug 31, 2023
ce7329e
updated patch for gromacs-2021.x
Sep 1, 2023
257a58d
updated patch for gromacs-2022
Sep 1, 2023
1c29409
Updated patch for gromacs-2020.x
Sep 1, 2023
8d4dcb1
Update namd config to support GPU
Sep 1, 2023
14ace25
Do not require libtorch in lammps by default
zwpku Sep 1, 2023
39c1a4f
Minor changes (spaces/indent) in code; Removed tests for namd and gro…
zwpku Sep 2, 2023
7987232
update namd config patch to make namd3 work
zwpku Sep 2, 2023
8aec443
Merge branch 'master' into torchann
zwpku Sep 6, 2023
cbd7c3d
merge with master
zwpku Sep 6, 2023
566621e
Merge branch 'upmaster' into torchann
Sep 8, 2023
2118759
updated patch for gromacs 2023 to support torchann
Sep 8, 2023
4b6ba2f
Merge branch 'master' into torchann
zwpku Sep 14, 2023
b3d7247
merge torchann squash
Oct 16, 2023
f060d9e
conflicts resolved
Oct 16, 2023
5f4e6f7
Do not use GPU
Oct 18, 2023
ee5254f
Merge branch 'upmaster' (early part) into torchann
Oct 18, 2023
87f730f
Merge branch 'master' into torchann
zwpku Nov 3, 2023
d87ef94
Merge branch 'upmaster' into torchann
Nov 16, 2023
55e4128
merged with master and changed torchann class based on HanatoK's sugg…
Nov 16, 2023
2c9fba1
Merge branch 'github' into torchann
Nov 16, 2023
035eaff
Added torchann tests for gromacs and namd (only when libtorch is linked)
zwpku Nov 17, 2023
891b37e
Add torch option to library CMake file
jhenin Nov 20, 2023
7357ee7
Merge branch 'master' into torchann
zwpku Nov 27, 2023
ba18c36
Use the same code from distanceZ to handle nearest-image convection
zwpku Nov 27, 2023
bca42a3
Squash-merge of master branch
giacomofiorin Dec 1, 2023
9a72e53
Integrate libTorch CMake recipe into GROMACS main
giacomofiorin Dec 1, 2023
a244537
Fixed conflicts
zwpku Dec 11, 2023
eeee166
Fixed Conflicts
Dec 12, 2023
158f335
Fixed Conflicts
Dec 12, 2023
82ce569
Fix NAMD build dependencies
giacomofiorin Dec 20, 2023
7e07b4a
Merge branch 'master' into torchann
zwpku Feb 22, 2024
e163328
Merge branch 'master' into torchann
giacomofiorin Jul 5, 2024
2ea5b57
Restore componentDisabled and make it more generally usable
giacomofiorin Jul 6, 2024
86fefbf
Integrate cvc base class improvements with torchANN
giacomofiorin Jul 6, 2024
7ec36da
Merge branch 'master' into torchann
giacomofiorin Jul 6, 2024
bb3b4c2
Fix CMakeFile for Gromacs 2024
jhenin Sep 18, 2024
bb8a774
Set PRNG seed in Gromacs regtests
jhenin Sep 20, 2024
a607a7e
Update patches for GMX CMake files
jhenin Sep 20, 2024
9840ebe
Add patch for gmxManageColvars.cmake
jhenin Sep 20, 2024
5e41ea0
Merge branch 'master' into torchann
jhenin Sep 23, 2024
2ab80ae
Use Clang and ccache more often when available
giacomofiorin Sep 27, 2024
b768be2
Find PyTorch through CMake and switch to -DCOLVARS_TORCH as macro
giacomofiorin Sep 27, 2024
b2ffb3e
Update CentOS9-devel container recipe
giacomofiorin Sep 28, 2024
41f7060
Use libTorch from container when available
giacomofiorin Oct 3, 2024
be0a02f
Remove pre-C++11 stuff
giacomofiorin Oct 3, 2024
a0bdfb9
Add torchann test for standalone library
giacomofiorin Oct 3, 2024
c8a0531
Disable torchann test when not building with libTorch
giacomofiorin Oct 3, 2024
70b1858
Enable Torch interface only when the requested C++ standard supports it
giacomofiorin Oct 4, 2024
4f4b7bb
Raise the CMAKE_CXX_STANDARD to 17 if libtorch is used and
HanatoK Oct 4, 2024
4640193
Squash-merge of master branch
giacomofiorin Oct 4, 2024
c4d8c9d
Remove patch files for old and unsupported GROMACS versions
giacomofiorin Oct 4, 2024
48657cb
Merge branch 'master'
giacomofiorin Oct 10, 2024
2a7cbcb
- Isolated torch-related code
Oct 11, 2024
9f7cd27
minor fix
Oct 11, 2024
c471ae8
Add torch header file to dependence file of backends
Oct 11, 2024
d500a88
fixed bug when torch is not available
Oct 11, 2024
28d80b4
Merge branch 'master'
giacomofiorin Oct 11, 2024
871cfa0
Enable Torch in GROMACS builds when available from CI container
giacomofiorin Oct 11, 2024
3c08493
Do not duplicate libTorch C++ flags
giacomofiorin Oct 19, 2024
7830857
Document apptainer push
giacomofiorin Oct 22, 2024
fbcbd0d
Let GROMACS use the newer CMake when available
giacomofiorin Oct 22, 2024
1b6f9ad
Squash-merge of master branch
giacomofiorin Nov 7, 2024
b76d60e
Squash-merge of master branch
giacomofiorin Nov 8, 2024
1ade0dc
Set damping=0 in gromacs regtest for torchann class.
Nov 13, 2024
f75efd1
Updated references files generated by Gromacs with double precision
Nov 14, 2024
e7597c0
Minor corrections in reference files.
Nov 14, 2024
1c4bf10
Squashed merge of master branch
giacomofiorin Nov 14, 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
Prev Previous commit
Next Next commit
Convert unit of atom coordinates to angstrom before feeding to torch …
…model
  • Loading branch information
zwpku committed Aug 3, 2023
commit 41f5618e22c000ecd05df94785bf553c095cfe64
11 changes: 8 additions & 3 deletions src/colvarcomp_torchann.cpp
Original file line number Diff line number Diff line change
@@ -39,12 +39,14 @@ colvar::torchANN::~torchANN() {

void colvar::torchANN::calc_value() {

colvarproxy *proxy = cvm::main()->proxy;

std::vector<double> pos_data(atoms->size() * 3) ;
size_t ia, j;
// obtain the values of the arguments
for (ia = 0; ia < atoms->size(); ia++) {
for (j = 0; j < 3; j++)
pos_data[3*ia + j] = (*atoms)[ia].pos[j];
pos_data[3*ia + j] = proxy->internal_to_angstrom((*atoms)[ia].pos[j]);
}
// change to torch Tensor
torch::Tensor arg_tensor = torch::from_blob(pos_data.data(), {1, (long int) atoms->size(),3}, torch::TensorOptions().dtype(torch::kFloat64).requires_grad(false));
@@ -60,13 +62,15 @@ void colvar::torchANN::calc_value() {

void colvar::torchANN::calc_gradients() {

colvarproxy *proxy = cvm::main()->proxy;

std::vector<double> pos_data(atoms->size() * 3) ;
size_t ia, j;

// obtain the values of the arguments
for (ia = 0; ia < atoms->size(); ia++)
for (j = 0; j < 3; j++)
pos_data[3*ia + j] = (*atoms)[ia].pos[j];
pos_data[3*ia + j] = proxy->internal_to_angstrom((*atoms)[ia].pos[j]);

// change to torch Tensor
torch::Tensor arg_tensor = torch::from_blob(pos_data.data(), {1, (long int) atoms->size(),3}, torch::TensorOptions().dtype(torch::kFloat64).requires_grad(true));
@@ -84,7 +88,7 @@ void colvar::torchANN::calc_gradients() {
for (cvm::atom_iter ai = atoms->begin() ; ai != atoms->end(); ai++, ia++)
{
for (size_t j = 0; j < 3; j ++)
ai->grad[j] = grad[0][ia][j].item<double>() ;
ai->grad[j] = proxy->internal_to_angstrom(grad[0][ia][j].item<double>()) ;
}
}

@@ -101,6 +105,7 @@ cvm::real colvar::torchANN::dist2(colvarvalue const &x1, colvarvalue const &x2)
{
diff = (diff < - period * 0.5 ? diff + period : (diff > period * 0.5 ? diff - period : diff));
}

return diff * diff;
}