Skip to main content

Enabling Unit-aware Computations for AI-driven Scientific Computing.

Project description

Header image of SAIUnit.

Supported Python Version LICENSE Documentation Status PyPI version Continuous Integration PyPI Downloads

Motivation

SAIUnit (/saɪ ˈjuːnɪt/) is designed to provide physical units and unit-aware mathematical systems tailored for Scientific AI within JAX. In this context, Scientific AI refers to the use of AI models or tools to advance scientific computations. SAIUnit evolves from our BrainUnit, a unit framework originally developed for brain dynamics modeling, extending its capabilities to support a broader range of scientific computing applications. SAIUnit is committed to providing rigorous and automatic physical unit conversion and analysis system for general AI-driven scientific computing.

Features

Compared to existing unit libraries, such as Quantities and Pint, SAIUnit introduces a rigorous physical unit system specifically designed to support AI computations (e.g., automatic differentiation, just-in-time compilation, and parallelization). Its unique advantages include:

  • Integration of over 2,000 commonly used physical units and constants
  • Implementation of more than 500 unit-aware mathematical functions
  • Deep integration with JAX, providing comprehensive support for modern AI framework features including automatic differentiation (autograd), just-in-time compilation (JIT), vectorization, and parallel computation
  • Unit conversion and analysis are performed at compilation time, resulting in zero runtime overhead
  • Strict physical unit type checking and dimensional inference system, detecting unit inconsistencies during compilation
graph TD
    A[SAIUnit] --> B[Physical Units]
    A --> C[Mathematical Functions]
    A --> D[JAX Integration]
    B --> B1[2000+ Units]
    B --> B2[Physical Constants]
    C --> C1[500+ Unit-aware Functions]
    D --> D1[Autograd]
    D --> D2[JIT Compilation]
    D --> D3[Vectorization]
    D --> D4[Parallelization]

We hope these features establish SAIUnit as a reliable physical unit handling solution for general AI-driven scientific computing scenarios.

A quick example:

import saiunit as u

# Define a physical quantity
x = 3.0 * u.meter
x
# [out] 3. * meter

# autograd
f = lambda x: x ** 3
u.autograd.grad(f)(x)
# [out] 27. * meter2 


# JIT
import jax
jax.jit(f)(x)
# [out] 27. * klitre

# vmap
jax.vmap(f)(u.math.arange(0. * u.mV, 10. * u.mV, 1. * u.mV))
# [out]  ArrayImpl([  0.,   1.,   8.,  27.,  64., 125., 216., 343., 512., 729.]) * mvolt3

Installation

saiunit has been well tested on python>=3.9 + jax>=0.4.30 environments, and can be installed on Windows, Linux, and MacOS.

You can install saiunit via pip:

pip install saiunit --upgrade

which should install in about 1 minute. If you want to install the latest version from the source, you can clone the repository and install it:

git clone https://github.com/chaobrain/saiunit.git
cd saiunit
pip install -e .

Alternatively, you can install BrainX, which bundles saiunit with other compatible packages for a comprehensive brain modeling ecosystem:

pip install BrainX -U

Documentation

The official documentation is hosted on Read the Docs: https://saiunit.readthedocs.io

Citation

@article{wang2025integrating,
  title={Integrating physical units into high-performance AI-driven scientific computing},
  author={Wang, Chaoming and He, Sichao and Luo, Shouwei and Huan, Yuxiang and Wu, Si},
  journal={Nature Communications},
  volume={16},
  number={1},
  pages={3609},
  year={2025},
  publisher={Nature Publishing Group UK London},
  url={https://doi.org/10.1038/s41467-025-58626-4}
}

Ecosystem

saiunit has been deeply integrated into following diverse projects, such as:

  • brainstate: A State-based Transformation System for Program Compilation and Augmentation
  • braintaichi: Leveraging Taichi Lang to customize brain dynamics operators
  • braintools: The Common Toolbox for Brain Dynamics Programming.
  • dendritex: Dendritic Modeling in JAX
  • pinnx: Physics-Informed Neural Networks for Scientific Machine Learning in JAX.

Other unofficial projects include:

  • diffrax: Numerical differential equation solvers in JAX.
  • jax-md: Differentiable Molecular Dynamics in JAX
  • Catalax: JAX-based framework to model biological systems
  • ...

Acknowledgement

The initial version of the project benefited a lot from the following projects:

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

saiunit-0.1.4.tar.gz (303.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

saiunit-0.1.4-py3-none-any.whl (382.1 kB view details)

Uploaded Python 3

File details

Details for the file saiunit-0.1.4.tar.gz.

File metadata

  • Download URL: saiunit-0.1.4.tar.gz
  • Upload date:
  • Size: 303.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for saiunit-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1ab5c5f5642080c9756cff227351808858c02058c9311a67c3d80f70d381ea65
MD5 e41b5ffd73e5fbe8cab88cd187d7ae4d
BLAKE2b-256 d04e65b1ee4912911fe1839b0288580a26796c1b4244f54a22528f4b9546f55a

See more details on using hashes here.

File details

Details for the file saiunit-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: saiunit-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 382.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for saiunit-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ee62cc81eaef66541f4d20da1a2cee99fbeac97365efbf02115b4a9f509a588a
MD5 f20733eac5067a2f8c2645a82a7c8aaf
BLAKE2b-256 633776b6e1d8fad63d58cbcaf6ef9749f3de9542e8d12eceb90a858e7bd89f14

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page