10 Commits

Author SHA1 Message Date
Peter Eastman
681adc2329 Update Mac build to newer versions (#153)
* Update Mac build to newer versions

* Fixed filename

* Debugging

* Try a more tolerant check
2024-08-23 14:20:06 -07:00
Peter Eastman
d4476435f5 Attempts at fixing CI (#144)
* Try to fix CI on Linux

* Don't install POCL on Mac

* Don't install khronos-opencl-icd-loader

* Update OpenMM version

* Updated tested versions

* Fixed version number

* Install correct packages for CUDA 12

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Try different method of installing CUDA

* Try not installing CUDA packages from conda

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Don't build OpenCL on Mac

* Don't try to run tests that can't run correctly

* Update C++ version and minimum macOS version

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Debugging

* Fixed working directory for tests

* Fixes to testing

* Try using PyTorch 2.3

* Try using PyTorch 2.2

* Switch back to PyTorch 2.1
2024-05-27 09:26:16 -07:00
Raul
b76deb4df8 Making TorchForce CUDA-graph aware (#103)
* Add CUDA graph draft

* Initialize energy and force tensors in the GPU.

* Add comment on graph capture

* Catch torch exception if the model fails to capture.

* Replay graph just after construction
Finish capturing before rethrowing if an exception occurred during capture

* Add python-side test script for CUDA graphs

* Implement properties

* Update the Python bindings

* Unify the API for properties

* Pass the propery map to the constructor

* Skip graph tests if no GPU is present

* Guard CUDA graph behavior with the CUDA_GRAPH_ENABLE macro

* Check validity of the useCUDAGraphs property

* Add missing bracket to openmmtorch.i

* Fix bug in useCUDAgraph selection

* Update tests

* Add test for get/setProperty

* Update documentation with new functionality

* Add a CUDA graph test for a model that returns only energy

* Add contributors

* Reset pos grads after graph capture. Make energy and force tensors persistent.

* Add tests that execute the model many times to catch bugs related with
CUDA graph capture

* Run formatter

* Warmup model for several steps

* Include gradient reset into the graph

* Do not reset energy and force tensors before graph capture

* Remove unnecessary line

* Add tests for larger number of particles

* Remove unnecessary compilation guard now that Pytorch 1.10 is not supported

* Simplify getTensorPointer now that Pytorch 1.7 is not supported

* Change addForcesToOpenMM to addForces

* Change execute_graph to executeGraph

* Wrap graph warming up in a try/catch block

* Add correctness test for modules that only provide energy

* Revert "Add correctness test for modules that only provide energy"

This reverts commit d20f4bfa83.

* Explicit conversion to correct type in getTensorPointer

* Added a new property for TorchForce, CUDAGraphWarmupSteps.

* Clarify docs

* Document properties

* Throw if requested property does not exist

* Change getProperty(string) to getProperties()

* Add getProperties to python wrappers

* Fix formatting

* Set default properties

* Update tests

* Update some comments

---------

Co-authored-by: Raimondas Galvelis <r.galvelis@acellera.com>
2023-04-21 14:52:39 +02:00
Raul
769302afd3 Add a constructor to TorchForce that takes a torch::jit::Module (#97)
* Add version number as a member to TorchForceProxy

* Encode the model file contents when serializing TorchForce

* Add tests for new TorchForce serialization

* Fix test not finding Python executable

* Format include directives correctly

* Hardcode TorchForceProxy version number

* Fix formatting issues

* Move Python serialization test to the correct place

* Make function encodeFromFileName static

* Update serialization python test to correctly remove temporary files after executing

* Use the base64 encoding capabilities of openssl to serialize model file

* Update TorchForce serializer

* Add a constructor to TorchForce that takes a torch::jit::Module.
 TorchForce(string fileName) is implemented by delegating to the new
 constructor.
 Update serialization test accordingly to compare the module file name
 and the module itself.

* Remove unnecessary include

* Change i_file to file in TorchForce constructor

* Add swig typemaps to new TorchForce constructor

* Add setup.py as a dependency for the PythonInstall CMake rule

* Fix swig out typemap for torch::jit::Module
 Now it is possible to call getModule() on a TorchForce object from
 Python, which will return a module of the same type as, for instance, torch.jit.load()

* Remove commented line in CMakeLists.txt

* Remove unnecessary dependency in setup.py

* Add more tests for new constructor

* Add some comments for the new constructor

* Updates to TorchForce serialization

* Use hex encoding instead of base64 for serialization.
SSL no longer a direct dependency.

* Remove unnecessary header

* Update Python serialization test

* Minor changes

* Improve temporary path handling in python serialization tests

* More informative exception when failing to serialize TorchForce

* Remove unnecessary check in TorchForce serialization

* Changes to C++ serialization tests

* Changes to C++ serialization tests
2023-02-10 14:58:03 -08:00
Raimondas Galvelis
5dc727951b Fix interoperability with CustomCVForce (#80)
* Add a test with CustomCVForce

* Test all the platforms

* Add an iteroperability test for TorchANI and NNPOps

* Add a missing dependencies

* Skip for MacOS

* Move imports

* Fix import

* Retain the primary context

* Switch properly the contexts

* Set the oldest CUDA to 11.0

* Fix nvcc version

* Enable an extra check

* Clean up a temporary file

* Add more checks

* Add comments

* Remove a sync and clean up

* Move the primary context activation
2022-07-08 08:02:19 -07:00
Raimondas Galvelis
db7c009e47 Move the PyTorch module to a correct device (#70)
* Move the PyTorch module into a correct device

* Add a test

* Make the device constant
2022-03-01 01:08:55 +01:00
Raimondas Galvelis
13e87155b5 Fix the Python wrapper of "setOutputsForces" and "getOutputsForces" (#60)
* Fix the wrapper for "setOutputsForces" and "getOutputsForces"

* Implement a test

* Clean up
2022-01-21 23:41:19 +01:00
Raimondas Galvelis
4614813608 Test if a PyTorch module receives corrects arguments (#50)
* Test if a PyTorch module receives corrects arguments

* Skip if CUDA is not available
2022-01-08 01:10:10 +01:00
Peter Eastman
6c11437e4f Created Python test 2020-01-09 15:58:26 -08:00
peastman
ca3499ce2a Renamed class and namespace 2020-01-09 14:30:54 -08:00