Skip to main content

Logo

DOI GitHub Release PyPI - Version GitHub License

CI badge pip test - coverage cpp - linter

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:

Const Density Osc Benchmark for nuTens - Bencher

Vacuum Osc Benchmark for nuTens - Bencher

Release files for nuTens 0.6.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nuTens 0.6.5
File Size Uploaded
nutens-0.6.5.tar.gz 226.9 kB Details

Release files / nutens-0.6.5.tar.gz

Download URL nutens-0.6.5.tar.gz
Size 226.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fe0598b51ef708792494474a297ae01cbe3c874a455275deaf8a7c877f875e37
BLAKE2b-256 checksum
How to use checksums
4467e22a5c4f70018545bdae558823318fe1470ee5b75879a8fe2be2d6d5e6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

0.6.7

1 release file

0.6.6

1 release file

This release

0.6.5 This release

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page