jax-dataclasses
Dataclasses + JAX
What it is and what it does
jax_dataclasses is a thin wrapper around Python's standard dataclasses that integrates them seamlessly into JAX's pytree system. It automatically registers decorated classes as pytree nodes, making them usable at JAX API boundaries (e.g., as function arguments to jitted code). The package adds support for marking fields as static—meaning they are constant at compile time and won't be traced—and enables serialization through flax.serialization.
The main value proposition is ergonomic: unlike hand-registering pytrees, you write normal dataclass syntax and get pytree behavior automatically. The package also provides copy_and_mutate(), a context manager that temporarily unfreezes nested dataclass structures for easier in-place modifications, addressing a common pain point when working with deeply nested immutable objects in JAX.
Use it for:
- Define model parameters and state as frozen dataclasses in JAX neural network code, automatically compatible with jit and vmap.
- Mark configuration fields as static to prevent JAX from recompiling when only non-array metadata changes.
- Serialize and deserialize JAX model checkpoints via flax.serialization without manual pytree registration.
- Modify deeply nested dataclass structures in a readable way using copy_and_mutate instead of chained dataclasses.replace() calls.
- Use standard type checkers and IDE autocomplete on JAX dataclasses since the decorator matches the standard library API.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a JAX-compatible wrapper around Python dataclasses that automatically registers them as pytrees and enables serialization, while supporting static fields and nested mutations.
Yes, if you are building JAX applications with structured state or model parameters. The package solves a real integration gap between Python dataclasses and JAX's pytree system with minimal overhead. Install friction is low and the MIT license is unrestrictive. The aging maintenance status (238 days since last release) is a minor concern but not a blocker—the package is stable, unarchived, and has no known vulnerabilities.
Install
jax-dataclasses on PyPI
pip
pip install jax-dataclassesuv
uv add jax-dataclassespoetry
poetry add jax-dataclassesInstalling jax-dataclasses
Before you install
Low friction: pure Python wheel with three runtime dependencies (jax, jaxlib, typing_extensions). Maintenance status is aging—last release was 238 days ago—but the repository remains active and unarchived.
License in practice
MIT license (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install jax_dataclasses
import jax_dataclasses as jdc
import jax
@jdc.pytree_dataclass
class Model:
params: jax.Array
name: jdc.Static[str]
model = Model(params=jax.numpy.zeros(10), name="test")
Requires Python >=3.9 and jax/jaxlib installed.
Verify before relying
- Whether flax.serialization integration works with all flax versions or requires a specific version.
- Performance characteristics when working with very deeply nested dataclass structures.
- Compatibility with JAX's latest pytree API changes beyond Python 3.12.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — jax, jaxlib, typing_extensions |
| Maintenance | aging — 238 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 103,209/month — #12,821 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: jax_dataclasses-1.6.3-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
dataclass-wizardDataclass Wizard converts Python dataclasses to…
permissive · top 5,000 on PyPI
databind.jsonDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
djangorestframework-dataclassesAutomatically generates Django REST Framework…
permissive · top 5,000 on PyPI
equinoxEquinox provides neural network and model…
permissive · top 5,000 on PyPI
databindDatabind deserializes JSON-like nested data…
permissive · top 15,000 on PyPI
itemadapterItemAdapter wraps data container objects…
permissive · top 5,000 on PyPI
serpyco-rsSerializes and deserializes Python dataclasses…
permissive · top 15,000 on PyPI
dataclasses-jsonConverts Python dataclasses to and from JSON…
permissive · top 1,000 on PyPI
databind.coreDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
typed-json-dataclassAdds JSON serialization and type validation to…
permissive · top 15,000 on PyPI