nuTens is an engine for calculating neutrino oscillation proabilities using tensors which allow it to be fast, flexible, and fully differentiable.
See the full documentation for more details.
nuTens is built on top of PyTorch's c++ libtorch library. This allows it to leverage the many useful features of pytorch such as automatic differentiation, highly optimised linear algebra funcionality, and in-built hardware acceleration.
Currently the following features are supported in nuTens:
- Perform neutrino oscillation calculations in vacuum and constant density matter
- Automatic differentiation, allowing gradients of final quantities like oscillation probabilities, or likelihoods, to be calculated with respect to model parameters
- Fast execution due to the highly optimised and parallelised libtorch backend library
- Easy hardware acceleration using e.g. GPUs
- Extremely flexible neutrino oscillation modelling, allowing you to define your own oscillation model, and have it work with all other features described
- c++ and Python interfaces, allowing for both easy experimentation, and efficient integration with efficient integration with other neutrino related software libraries
- CMake - Should work with most modern versions. If you wish to use precompiled headers to speed up build times you will need CMake > 3.16.
- Compiler with support for c++17 standard - Tested with gcc
- PyTorch - The recommended way to install is using PyTorch_requirements.txt:
pip install -r PyTorch_requirements.txt
(or see PyTorch installation instructions for instructions on how to build yourself)
Assuming PyTorch was built using pip, nuTens can be built using
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=`python3 -c 'import torch;print(torch.utils.cmake_prefix_path)'`
make <-j Njobs>
(installation with a non-pip install of PyTorch have not been tested but should be possible)
Once nuTens has been built, you can verify your installation by running
make test
nuTens provides a python interface for it's high level functionality. The Pypi release of nuTens can be found here and can be installed using
pip install nuTens
The python interface can be installed manually after cloning the repository using pip by running
pip install .
in the root directory of nuTens
Additionally, the nuTens python module can be installed by specifying the CMake option
cmake -DNT_ENABLE_PYTHON=ON <other options> <source dir>
during configuration and then doing make && make install
When trying to run using the python interface you may get complaints relating to not being able to locate libtorch.so or libtorch_cpu.so library files. If so running
export LD_LIBRARY_PATH=`python3 -c 'import os;import torch;print(os.path.abspath(torch.__file__)[:-11])'`/lib:$LD_LIBRARY_PATH
should allow these files to be found
There is an incompatibility between some torch cpu versions and the yaml-cpp library (see here for discussion).
If you are trying to use nuTens with the cpu version of torch in a project which also uses yaml-cpp, you will need to install torch version torch==<version>+cpu.cxx11.abi instead of just torch==<version>+cpu.
A few simple example scripts using nuTens are available here
nuTens uses Googles benchmark library to perform benchmarking and tracks the results uing Bencher. Each benchmark consists of calculating neutrino oscillations for 1024 random variations of parameters in the 3 flavour formalism for 1024 neutrino energies in vacuum and in constant density matter:
