VASPml library: Difference between revisions
No edit summary |
No edit summary |
||
(5 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
= Supported features = | = Supported features = | ||
* [[Running | * [[Running machine-learned force fields in LAMMPS]] | ||
* Fast prediction-only mode in {{VASP}} ({{TAGO|ML_MODE|run}}) | * Fast prediction-only mode in {{VASP}} ({{TAGO|ML_MODE|run}}) | ||
Line 15: | Line 15: | ||
* Thermodynamic integration ({{TAG|ML_LCOUPLE}}) | * Thermodynamic integration ({{TAG|ML_LCOUPLE}}) | ||
* Heat flux calculation ({{TAG|ML_LHEAT}}) | * Heat flux calculation ({{TAG|ML_LHEAT}}) | ||
= Dependencies = | |||
The VASPml library depends on the following compilers and external libraries: | |||
* C++ compiler supporting the C++17 language standard | |||
* MPI | |||
* BLAS and the corresponding C interface CBLAS | |||
* LAPACK and the corresponding C interface LAPACKE | |||
These requirements are usually already covered by the [[Installing_VASP.6.X.X#Requirements|{{VASP}} requirements]]. | |||
= Build instructions = | = Build instructions = | ||
Line 29: | Line 38: | ||
... | ... | ||
Apart from the mandatory <code>-Dlibvaspml</code> flag there are the following possible <code>CPP_OPTIONS</code>: | Apart from the mandatory <code>-Dlibvaspml</code> flag there are the following possible <code>CPP_OPTIONS</code>: | ||
* <code>-DVASPML_USE_CBLAS</code>: Use CBLAS (C interface for BLAS routines) for linear algebra. This is the default and should always be used. | * <code>-DVASPML_USE_CBLAS</code>: Use CBLAS (C interface for BLAS routines) for linear algebra. This is the default and should always be used. | ||
* <code>-DVASPML_USE_MKL</code>: Use Intel MKL for linear algebra. | * <code>-DVASPML_DEBUG_LEVEL=[0|1|2|3]</code>: If set to 1, 2 or 3 enables various sanity checks during runtime with low, medium and high impact on performance, respectively. Setting it to 0 or omitting the flag disables runtime checks. {{NB|mind|Do not use this flag for production runs as it may decrease performance.|:}} | ||
* <code>-DVASPML_USE_MKL</code>: Use Intel MKL for linear algebra (must be used in combination with <code>-DVASPML_USE_CBLAS</code>). | |||
In addition, VASPml requires to set its own compiler, flags and include path: | In addition, VASPml requires to set its own compiler, flags and include path: | ||
* <code>CXX_ML</code>: This should be a C++17-compatible C++ compiler with MPI support. | * <code>CXX_ML</code>: This should be a C++17-compatible C++ compiler with MPI support (usually an MPI wrapper corresponding to the selected toolchain, e.g. <code>mpic++</code>, <code>mpicxx</code>, <code>mpicpx</code> or <code>mpinc++</code>). | ||
* <code>CXXFLAGS_ML</code>: Specifies the flags for the C++ compiler. | * <code>CXXFLAGS_ML</code>: Specifies the flags for the C++ compiler. Typically, here the optimization level (<code>-O3</code>) and the compliance with C++17 is specified. | ||
* <code>INCLUDE_ML</code>: | * <code>INCLUDE_ML</code>: Include flags for the required dependencies should be added here. {{NB|tip|For some [[toolchains]] it is not necessary to explicitly add paths here because the compilers automatically include the correct directories (e.g. Intel oneAPI, NVHPC). In other cases (e.g. GNU compiler with openBLAS) the given path must contain the desired C++ headers of the dependencies: | ||
* CBLAS: <code>cblas.h</code> | |||
* LAPACKE: <code>lapacke.h</code>|:}} | |||
The VASPml project (source code and related files) is located within the <code>src/vaspml</code> directory relative to the {{VASP}} root folder. Upon compilation it is copied to the <code>build/std</code>, <code>build/gam</code> and/or <code>build/ncl</code> build folders, just like all other {{VASP}} sources. If the VASPml library was successfully compiled <code>libvaspml.a</code> will be located in <code>build/std/vaspml/lib/</code> (similarly for the <code>gam</code> and <code>ncl</code> versions). However, it is usually not necessary to check its presence because the {{VASP}} build will handle this (and fail if VASPml cannot be built). | |||
[[Category:Machine-learned force fields]] |
Revision as of 08:33, 24 January 2025
VASPml is a C++ library accompanying VASP, providing functionality related to machine-learned force fields. It is supposed to extend, and eventually replace, the original Fortran machine learning code inside VASP. Currently, it does not yet offer any training capabilities but rather focuses on inference. At this point VASPml is in a beta-testing stage and provides its first application, an interface to the popular molecular dynamics (MD) software LAMMPS. This allows users to combine VASP-generated machine-learned force fields with the large amount of MD-related features provided by LAMMPS, some of which may not be offered in VASP directly.
Warning: As of VASP 6.5.0 the VASPml library is experimental and results should be carefully checked against the standard Fortran code (compile without -Dlibvaspml or set ML_LIB = .FALSE. ).
|
Supported features
- Running machine-learned force fields in LAMMPS
- Fast prediction-only mode in VASP (
ML_MODE = run
)
If VASP is compiled with the VASPml library and a requested feature is supported by both, the original Fortran code and the C++ VASPml implementation, then the latter code path is used by default. To override this behavior and explicitly avoid the use of the VASPml library set ML_LIB = .FALSE.
in the INCAR file.
Restrictions
Since the VASPml library is still under development some features available in the original Fortran code are not yet available:
- No machine learning related file output (e.g. ML_LOGFILE)
Tip: For running the fast prediction-only mode in VASP there is currently only negligible performance gains from the VASPml library. Hence, if file output is important (e.g. when monitoring the spilling factor) we recommend using the original Fortran code ( ML_LIB = .FALSE.
).
- Thermodynamic integration (ML_LCOUPLE)
- Heat flux calculation (ML_LHEAT)
Dependencies
The VASPml library depends on the following compilers and external libraries:
- C++ compiler supporting the C++17 language standard
- MPI
- BLAS and the corresponding C interface CBLAS
- LAPACK and the corresponding C interface LAPACKE
These requirements are usually already covered by the VASP requirements.
Build instructions
The VASPml library is automatically built alongside VASP if -Dlibvaspml
is added to the CPP_OPTIONS
precompiler option in the makefile.include file. In addition, a few more compiler settings regarding the C++ compiler, include paths and VASPml options may be required. The makefile.include templates provided in VASP's arch
directory contain pre-filled blocks corresponding to the VASPml build. Uncomment the VASPml-related lines and fill with values according to your toolchain. For example, when using the GCC toolchain with OpenBLAS the makefile.include section may look like this:
... # For machine learning library vaspml (experimental) CPP_OPTIONS += -Dlibvaspml CPP_OPTIONS += -DVASPML_USE_CBLAS #CPP_OPTIONS += -DVASPML_DEBUG_LEVEL=3 CXX_ML = mpic++ CXXFLAGS_ML = -O3 -std=c++17 -pedantic-errors -Wall -Wextra INCLUDE_ML = -I$(OPENBLAS_ROOT)/include ...
Apart from the mandatory -Dlibvaspml
flag there are the following possible CPP_OPTIONS
:
-DVASPML_USE_CBLAS
: Use CBLAS (C interface for BLAS routines) for linear algebra. This is the default and should always be used.-DVASPML_DEBUG_LEVEL=[0|1|2|3]
: If set to 1, 2 or 3 enables various sanity checks during runtime with low, medium and high impact on performance, respectively. Setting it to 0 or omitting the flag disables runtime checks.
Mind: Do not use this flag for production runs as it may decrease performance.
-DVASPML_USE_MKL
: Use Intel MKL for linear algebra (must be used in combination with-DVASPML_USE_CBLAS
).
In addition, VASPml requires to set its own compiler, flags and include path:
CXX_ML
: This should be a C++17-compatible C++ compiler with MPI support (usually an MPI wrapper corresponding to the selected toolchain, e.g.mpic++
,mpicxx
,mpicpx
ormpinc++
).CXXFLAGS_ML
: Specifies the flags for the C++ compiler. Typically, here the optimization level (-O3
) and the compliance with C++17 is specified.INCLUDE_ML
: Include flags for the required dependencies should be added here.
Tip: For some toolchains it is not necessary to explicitly add paths here because the compilers automatically include the correct directories (e.g. Intel oneAPI, NVHPC). In other cases (e.g. GNU compiler with openBLAS) the given path must contain the desired C++ headers of the dependencies: - CBLAS:
cblas.h
- LAPACKE:
lapacke.h
- CBLAS:
The VASPml project (source code and related files) is located within the src/vaspml
directory relative to the VASP root folder. Upon compilation it is copied to the build/std
, build/gam
and/or build/ncl
build folders, just like all other VASP sources. If the VASPml library was successfully compiled libvaspml.a
will be located in build/std/vaspml/lib/
(similarly for the gam
and ncl
versions). However, it is usually not necessary to check its presence because the VASP build will handle this (and fail if VASPml cannot be built).