skillfed

chex

Chex: Testing made fun, in JAX!

chex v0.1.92 2.3M downloads/30d#3,144 on PyPI952
Permissive license Active released

What it is and what it does

Chex is a testing and debugging library for JAX code that bridges the gap between Python's type system and JAX's array constraints. It provides shape, rank, dtype, and device assertions that work within JAX's tracing model, along with utilities to test code across variants (jitted vs non-jitted execution). The library also includes JAX-compatible dataclass implementations and helpers to detect unintended function re-tracing during JIT compilation.

The package is built on top of jax, jaxlib, numpy, and related dependencies. It's designed for machine learning practitioners and researchers who need to catch shape mismatches, type errors, and numerical issues early in development. Assertions can be customized with exception types and messages, and value assertions (those requiring actual tensor values) are supported within jitted functions via the chex.chexify() decorator.

Use it for:

  • Add shape and dtype validation to JAX functions to catch dimension mismatches before they propagate through a training loop.
  • Test the same JAX code path under both jitted and non-jitted execution to verify correctness across compilation modes.
  • Detect unintended JIT re-tracing that causes performance degradation by asserting maximum trace counts.
  • Validate that model parameters remain finite during training with custom error messages.
  • Create JAX-compatible dataclasses that work seamlessly with tree operations.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Chex provides utilities for writing reliable JAX code, including assertions for tensor properties, debugging helpers, and test variants to validate code across different JAX execution modes.

Yes. Chex is actively maintained, has no known vulnerabilities, and provides essential utilities for JAX development. The low install friction, permissive license, and focus on catching common JAX pitfalls make it a practical addition to any JAX project. Install it if you write JAX code and want better visibility into shape, dtype, and execution-mode issues.

Install

chex on PyPI

pip

pip install chex

uv

uv add chex

poetry

poetry add chex

Installing chex

Before you install

Low friction installation with six runtime dependencies including jax, jaxlib, and numpy. Active maintenance with a recent release 63 days ago and ongoing repository activity.

License in practice

Permissive license allows broad use, modification, and distribution with minimal restrictions.

Quickstart

pip install chex

import chex
import jax.numpy as jnp

@chex.dataclass
class Parameters:
  x: chex.ArrayDevice
  y: chex.ArrayDevice

parameters = Parameters(
    x=jnp.ones((2, 2)),
    y=jnp.ones((1, 2)),
)

chex.assert_equal_shape([parameters.x, parameters.y])

Requires Python 3.11 or later; jax and jaxlib must be installed and functional.

Verify before relying

  • Whether all assertion types work identically in jitted vs non-jitted contexts without additional setup
  • Performance overhead of value assertions when using chex.chexify() wrapper in production code
  • Compatibility guarantees with specific JAX versions beyond the stated Python 3.11+ requirement

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 6 — absl-py, typing_extensions, jax, jaxlib, numpy, toolz
Maintenance actively maintained — 63 days since the last release
Last repo commit
First released
Downloads 2,315,756/month — #3,144 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: chex-0.1.92-py3-none-any.whl

Keywords: jax, testing, debugging, python, machine learning

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Software Development :: Libraries :: Python Modules

Tags

jax testing utilitiesjax assertions shape dtypejax debugging toolsjax code validationjax test variantstensor property checksjax reliability helpers
jax-ecosystemnumerical-validation

More Python Modules packages