Skip to main content

Dynamic neural networks and function transformations in Python + Mojo

Project description

alt text

Nabla is a Python library that provides three key features:

  • Multidimensional Array computation (like NumPy) with strong GPU acceleration
  • Composable Function Transformations: vmap, grad, jit, and other Automatic Differentiation tools
  • Deep integration with MAX and (custom) Mojo kernels

For tutorials and API reference, visit: nablaml.com

Installation

Now available on PyPI!

pip install nabla-ml

Quick Start

import nabla as nb

# Example function using Nabla's array operations
def foo(input):
    return nb.sum(input * input, axes=0)

# Vectorize, differentiate, accelerate
foo_grads = nb.jit(nb.vmap(nb.grad(foo)))
gradients = foo_grads(nb.randn((10, 5)))

Development Setup and Reproducibility

This guide is for contributors or for reproducing the validation and benchmark results.

1. Initial Setup

First, clone the repository and set up a virtual environment with all necessary dependencies.

# Clone the repository
git clone https://github.com/nabla-ml/nabla.git
cd nabla

# Create and activate a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate

# Install all core and development dependencies
pip install -r requirements-dev.txt
pip install -e ".[dev]"

2. Run the Correctness Validation Suite

This runs the full test suite to verify Nabla's correctness against JAX.

# Navigate to the unit test directory from the project root
cd nabla/tests/unit

# Execute the unified test script
python unified.py all -all-configs

3. Run the Performance Benchmarks

This script reproduces the performance benchmarks for Nabla, JAX, and PyTorch.

# Navigate to the benchmark directory
cd nabla/tests/benchmarks

# Run the benchmark script
python benchmark1.py

Repository Structure

alt text

nabla/
├── nabla/                     # Core Python library
│   ├── core/                  # Array class and MAX compiler integration
│   ├── nn/                    # Neural network modules and models
│   ├── ops/                   # Mathematical operations (binary, unary, linalg, etc.)
│   ├── transforms/            # Function transformations (vmap, grad, jit, etc.)
│   └── utils/                 # Utilities (formatting, types, MAX-interop, etc.)
├── tests/                     # Comprehensive test suite
├── tutorials/                 # Notebooks on Nabla usage for ML tasks
├── examples/                  # Example scripts for common use cases
└── experimental/              # Core (pure) Mojo library (WIP!)

Contributing

Contributions welcome! Discuss significant changes in Issues first. Submit PRs for bugs, docs, and smaller features.

License

Nabla is licensed under the Apache-2.0 license.


Thank you for checking out Nabla!

Development Status PyPI version Python 3.12+ License: Apache 2.0

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

nabla_ml-25.8061229.tar.gz (195.3 kB view details)

Uploaded Source

Built Distribution

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

nabla_ml-25.8061229-py3-none-any.whl (266.3 kB view details)

Uploaded Python 3

File details

Details for the file nabla_ml-25.8061229.tar.gz.

File metadata

  • Download URL: nabla_ml-25.8061229.tar.gz
  • Upload date:
  • Size: 195.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nabla_ml-25.8061229.tar.gz
Algorithm Hash digest
SHA256 79bf818eb2b1951419770a5b7d61e338c1a5bb991be307662e6c2b46fe00b518
MD5 90bb3cd333d01d65cd37d4c994bd3e0b
BLAKE2b-256 d182fac8b05dbd62b875852ce877d1bdb36819f7bc50738582ed9308729e267b

See more details on using hashes here.

File details

Details for the file nabla_ml-25.8061229-py3-none-any.whl.

File metadata

  • Download URL: nabla_ml-25.8061229-py3-none-any.whl
  • Upload date:
  • Size: 266.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for nabla_ml-25.8061229-py3-none-any.whl
Algorithm Hash digest
SHA256 7f8753f7a81ce3a0d71a1821558521ec2232b8beaf1ddc7eb03b8b1eb1b44ba9
MD5 d46d1de0a97224d853bf990c1c810b7d
BLAKE2b-256 5c4bc46fb62349a504baaee24096f22aebe7e476404e08506621f9b5bebef9fb

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