← Back to Leaderboard
Fgoogle

google/flax

JAX neural-network library with stateful Python modules for custom training and inference

AI FrameworkQuickstart ↓
Engineering Health (Methodology)
A+ · 95/100
Maintenance Activity
● Updated 3d ago
Latest Release
v0.12.12
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption20/25
Release Cadence20/20
License Clarity20/20
CLI
Total Stars
★ 7,371
24h Growth
+1
7d Growth
+2
Forks
860

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

google/flax Star History (2020-01-12 - 2026-12-03) ALL-TIME STAR HISTORY (2020-01 – 2026-12) +7.4k in 2517d · avg +3/day 7.8k 3.9k 0 2020-01-12: ★ 12020-06-13: ★ 8332020-11-14: ★ 1,0902021-04-17: ★ 1,5242021-09-18: ★ 2,0072022-02-19: ★ 2,5382022-07-23: ★ 3,1882022-12-24: ★ 3,6722023-05-27: ★ 4,1942023-10-28: ★ 4,6602024-03-30: ★ 5,2392024-08-31: ★ 5,7642025-02-01: ★ 6,1712025-07-05: ★ 6,5452025-12-06: ★ 6,8662026-05-09: ★ 7,1422026-12-03: ★ 7,371 ★ 7.4k 2020-01 2023-06 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

Flax is a Python neural-network library on top of JAX. In flax.nnx, a model is a tree or graph of ordinary Python objects: its constructor assembles layers, __call__ computes on JAX arrays, and shared references let multiple parts of a model reuse the same object. NNX supports mutable module state, while Linen remains a distinct API with its own documentation.

The main extension point is module composition: write an nnx.Module or assemble existing layers rather than build a plugin for a separate process. JAX supplies array operations, transformations, and device execution. The package manifest also declares NumPy, Optax for optimization, and MsgPack, along with Python-version-conditional dependencies on Orbax Checkpoint and TensorStore.

Key Capabilities & Differentiators

NNX provides linear and convolutional layers, batch, layer, and group normalization, multi-head attention, LSTM and GRU cells, and dropout. nnx.Rngs manages randomness for operations such as initialization and dropout. The MLP, CNN, and autoencoder examples show how to assemble these components as custom modules rather than select a fixed model from a catalog.

Flax also provides utilities and patterns for replicated training, metrics, device prefetching, serialization, and checkpointing. The same module abstraction can be used for forward passes at inference time, but attention layers and checkpoint support do not make Flax a turnkey LLM server. Request batching, network endpoints, and serving observability belong to the application or a separate runtime.

Trade-offs & Limitations

NNX makes it easy to inspect models, share submodules, and keep state with the object that owns it. The tradeoff is that state changes and reference sharing need deliberate validation at JAX transformation boundaries. Linen's explicit variable collections may be preferable in a mature Flax codebase with established checkpoints and state-handling conventions. Migration is not a simple import change.

For a PyTorch-first team, switching to Flax means porting model code and checking weight and output parity, not just swapping execution backends. For a team that only needs to serve an existing LLM, a dedicated runtime is a closer fit because Flax leaves service concerns to the application. There is no fixed hardware footprint: measure compilation latency, steady-state performance, and peak memory with representative input shapes, batch sizes, and concurrency.

Hardware & Deployment Guide

Install Flax into the application's Python environment with pip install flax, and install the appropriate JAX backend for CPU, GPU, or TPU. For the snapshot reviewed, the package manifest requires Python 3.12+ and JAX 0.11.1+. It declares Orbax Checkpoint and TensorStore only below Python 3.15, so teams adopting 3.15 should explicitly test their save-and-restore workflow rather than assume those dependencies will be installed.

Flax runs in process without a required remote inference API. Pin and test the Python, Flax, JAX, and accelerator stack together. That matters even across patch releases: v0.12.11 fixed tracing-cache misses in nnx.cond and added a Module.sow capture option, while v0.12.12 reverted a breaking change to traversal utilities. Exercise tracing, state traversal, and checkpoint restoration in upgrade tests.

Module semantics: flax.nnx.Module supports mutable Python objects and shared references between submodules.
Randomness and state: nnx.Rngs supplies randomness for initialization and stochastic layers; BatchNorm adds state whose train/eval behavior must be checked.
Layer coverage: Linear, convolutions, multi-head attention, LSTM and GRU cells, dropout, and multiple normalization layers.
Training utilities: Optax is a declared dependency; Flax provides patterns for replicated training, metrics, device prefetching, and checkpointing.
Compatibility floor: The supplied manifest requires Python 3.12+ and JAX 0.11.1+ and declares Orbax Checkpoint and TensorStore only below Python 3.15.
Release signal: v0.12.11 addressed nnx.cond tracing-cache misses; v0.12.12 reverted a breaking change to traversal utilities.
Best For

JAX teams building custom models or training loops that want inspectable Python modules and control over state, randomness, and checkpointing.

Skip If

You need a turnkey LLM endpoint, or your PyTorch code and checkpoints already meet your needs without a costly port.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

CLI
pip install flax

Comparison vs. Top LLMs & Inference Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
flax ★7.4k+2Jupyter NotebookApache-2.0JAX neural-network library with stateful Python modules for custom training and
keras64.5k+24PythonApache-2.0Multi-backend Python SDK for building, training, and running deep learning model
jax36.7k+44PythonApache-2.0Python array SDK for composable autodiff, XLA compilation, and device sharding
einops9.6k+5PythonMITA backend-agnostic Python library for explicit tensor shape transformations

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/google/flax.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

google/flax Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about flax

Should I start with NNX or migrate an existing Linen model?

Use NNX for new JAX code if you want Python object semantics, including shared references and mutable state. For an existing Linen model, keep its current API unless migration has a clear payoff. Before switching, verify that shared parameters, normalization state, and train/eval behavior still work as intended under your JAX transformations.

How much GPU memory does Flax need?

There is no single Flax VRAM requirement. Size the environment around the model, input shapes, dtype, and batch size. Training also needs room for gradients, saved activations, and optimizer state; inference memory can grow with concurrency. Measure peak memory and separate first-run JAX compilation from steady-state latency on the target hardware.

Can we use Flax commercially and run it on our own infrastructure?

Yes. Apache-2.0 permits commercial use and self-hosting. When redistributing Flax, comply with the applicable license and notice requirements and mark modified files as required. Check dependency, model-weight, and dataset terms separately; Flax’s license does not grant rights to those assets.

When is Flax a better fit than PyTorch or an LLM serving runtime?

Choose Flax if the model and its surrounding code are built for JAX. If the codebase, checkpoints, and tooling are already in PyTorch, Flax is not a drop-in replacement; switching means porting and validating the model. If the only goal is to expose an existing LLM through an API, evaluate a dedicated serving runtime rather than adding a model library.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining google/flax? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature google/flax on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare