Registry / ai-ml / haliax

haliax

JSON →
library1.3pypypiunverified

Haliax (version 1.3) provides named tensors for JAX, enhancing legibility and reducing common shape-related errors in deep learning models. It builds on JAX's power by allowing users to refer to tensor dimensions by name, simplifying complex operations like broadcasting, reduction, and concatenation. The library is actively developed with frequent minor releases and occasional major updates.

pip install haliax
INSTALL
IMPORT
SIG · HALIAX
H
haliax
ai-mlpythonv1.3
Install
13.1s avg
Import
Disk
620MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 12.83s
py 3.11
✕ timeout
✓ 13s
py 3.12
✕ timeout
✓ 13.43s
py 3.13
✕ timeout
✓ 13.15s
py 3.9
✕ build_error
✕ build_error
620MB installed
● package 620MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NamedArray
from haliax import NamedArray
Axis
from haliax import Axis
product
from haliax import product
nn
import haliax.nn as nn
Linear
from haliax.nn import Linear
from haliax import Linear
Linear is part of the haliax.nn submodule, not top-level.

This quickstart demonstrates how to define named axes, create `NamedArray` instances with these axes, and perform basic operations like reduction and dot products, highlighting how Haliax manages dimension alignment by name.

import haliax as hx import jax import jax.random as jr # 1. Define axes with their names and sizes Batch = hx.Axis("batch", 4) Features = hx.Axis("features", 8) # 2. Create a NamedArray # The axes argument explicitly lists the named dimensions in order key = jr.PRNGKey(0) data_array = hx.random.normal(key, (Batch, Features)) print(f"NamedArray axes: {data_array.axes}") print(f"Value for batch index 0: {data_array.take(0, Batch).array.round(2)}") # 3. Perform an operation, e.g., sum over the Features axis summed_array = data_array.sum(Features) print(f"Summed array axes: {summed_array.axes}") # Expected: (Batch,) print(f"Summed array values: {summed_array.array.round(2)}") # 4. Dot product example # Define another axis for the second array, same size for contraction Features2 = hx.Axis("features2", Features.size) data_array_2 = hx.random.normal(jr.PRNGKey(1), (Features2, Batch)) # Dot product, explicitly contracting over Features and Features2 product_array = hx.dot(data_array, data_array_2, (Features, Features2)) print(f"Dot product array axes: {product_array.axes}") # Expected: (Batch, Batch) print(f"Dot product values shape: {product_array.array.shape}")
Debug
Known issues
breakingMajor API changes occurred in version 1.0, including refactoring of `haliax.nn` modules and removal of `haliax.partition` functions.
fix
Consult the Haliax 1.0+ documentation for updated API calls, especially for neural network layers and partitioning utilities. Many functions were integrated into `NamedArray` methods.
affects: <1.0
gotchaMixing `NamedArray` with raw `jax.Array` or `numpy.ndarray` can lead to loss of named dimension information or shape errors if not handled explicitly.
fix
Use `NamedArray.array` to access the underlying JAX array when interfacing with JAX functions not aware of Haliax. Convert back using `hx.NamedArray(raw_array, axes)` to restore named dimension benefits.
affects: All
gotchaJAX's `jax.jit` compilation can make debugging axis-related errors challenging, as some issues only manifest at runtime after tracing.
fix
Debug code without `jax.jit` first. Ensure `Axis` objects are hashable and defined globally or passed consistently, avoiding their creation inside `jit`-ted functions where they might be re-instantiated.
affects: All
deprecated`AxisSpec` (e.g., tuples of `Axis` objects to specify a dimension) has been largely superseded by directly using `Axis` objects or tuples of `Axis` for clarity.
fix
Where possible, replace `AxisSpec` patterns with direct `Axis` objects or explicit tuples of `Axis` instances to define dimensions.
affects: >=0.10.0
Upgrade
Version history
1.3latest on PyPI · released Apr 8, 2024
Audit
Dependencies
jaxrequiredCore dependency for tensor computation, Haliax is built on JAX.
numpyrequiredFundamental array operations and interoperability.
typing_extensionsrequiredProvides type hints for advanced Python features.
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
haliax — pip install haliax · libregistry