Library to calculate neutrino oscillation probabilities in a fast, flexible, and differentiable way
Project description
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.
Features
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
Installation
Requirements
- 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)
Installation
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)
Verifying Installation
Once nuTens has been built, you can verify your installation by running
make test
Python
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
Manual Installation
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
Known Issues
Can't find libtorch.so
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
Torch - yaml-cpp Incompatibility
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.
Usage
A few simple example scripts using nuTens are available here
Benchmarks
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:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file nutens-0.4.1.tar.gz.
File metadata
- Download URL: nutens-0.4.1.tar.gz
- Upload date:
- Size: 208.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dc1167a3f98e11023bf23e8486f008e6ddaa11af54fa14b260865629ab7bce6
|
|
| MD5 |
c529703b8ac38974ae577d4ee0de032b
|
|
| BLAKE2b-256 |
969ec1f02783efb05160d22a501dffcd40a4d6c8502ce63d78f15c89571d9ec5
|
Provenance
The following attestation bundles were made for nutens-0.4.1.tar.gz:
Publisher:
pypi-distribution.yaml on ewanwm/nuTens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nutens-0.4.1.tar.gz -
Subject digest:
6dc1167a3f98e11023bf23e8486f008e6ddaa11af54fa14b260865629ab7bce6 - Sigstore transparency entry: 445685655
- Sigstore integration time:
-
Permalink:
ewanwm/nuTens@001612e17c53e7abc588b0b3bf0db9599202e22a -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/ewanwm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-distribution.yaml@001612e17c53e7abc588b0b3bf0db9599202e22a -
Trigger Event:
push
-
Statement type: