Skip to main content

Type annotations and runtime checking for shape and dtype of JAX arrays, and PyTrees.

Project description

jaxtyping

Type annotations and runtime type-checking for:

  1. shape and dtype of JAX arrays; (Now also supports PyTorch, NumPy, and TensorFlow!)
  2. PyTrees.

For example:

from jaxtyping import Array, Float, PyTree

# Accepts floating-point 2D arrays with matching axes
def matrix_multiply(x: Float[Array, "dim1 dim2"],
                    y: Float[Array, "dim2 dim3"]
                  ) -> Float[Array, "dim1 dim3"]:
    ...

def accepts_pytree_of_ints(x: PyTree[int]):
    ...

def accepts_pytree_of_arrays(x: PyTree[Float[Array, "batch c1 c2"]]):
    ...

Installation

pip install jaxtyping

Requires Python 3.9+.

JAX is an optional dependency, required for a few JAX-specific types. If JAX is not installed then these will not be available, but you may still use jaxtyping to provide shape/dtype annotations for PyTorch/NumPy/TensorFlow/etc.

The annotations provided by jaxtyping are compatible with runtime type-checking packages, so it is common to also install one of these. The two most popular are typeguard (which exhaustively checks every argument) and beartype (which checks random pieces of arguments).

Documentation

Available at https://docs.kidger.site/jaxtyping.

See also: other libraries in the JAX ecosystem

Always useful
Equinox: neural networks and everything not already in core JAX!

Deep learning
Optax: first-order gradient (SGD, Adam, ...) optimisers.
Orbax: checkpointing (async/multi-host/multi-device).
Levanter: scalable+reliable training of foundation models (e.g. LLMs).

Scientific computing
Diffrax: numerical differential equation solvers.
Optimistix: root finding, minimisation, fixed points, and least squares.
Lineax: linear solvers.
BlackJAX: probabilistic+Bayesian sampling.
sympy2jax: SymPy<->JAX conversion; train symbolic expressions via gradient descent.
PySR: symbolic regression. (Non-JAX honourable mention!)

Awesome JAX
Awesome JAX: a longer list of other JAX projects.

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

jaxtyping-0.2.34.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

jaxtyping-0.2.34-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file jaxtyping-0.2.34.tar.gz.

File metadata

  • Download URL: jaxtyping-0.2.34.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for jaxtyping-0.2.34.tar.gz
Algorithm Hash digest
SHA256 eed9a3458ec8726c84ea5457ebde53c964f65d2c22c0ec40d0555ae3fed5bbaf
MD5 93607615da0e4fc4bc39b3f28d5ed100
BLAKE2b-256 32cb580f3ec30b9e52b79c0288c033a1f0a90378f3b820707a2e8894c076481b

See more details on using hashes here.

File details

Details for the file jaxtyping-0.2.34-py3-none-any.whl.

File metadata

  • Download URL: jaxtyping-0.2.34-py3-none-any.whl
  • Upload date:
  • Size: 42.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for jaxtyping-0.2.34-py3-none-any.whl
Algorithm Hash digest
SHA256 2f81fb6d1586e497a6ea2d28c06dcab37b108a096cbb36ea3fe4fa2e1c1f32e5
MD5 c210ad7a316fe09616348a7376aa029f
BLAKE2b-256 56ae220537f80eb82ae43a299de31edb2a91a28b8c5fb8046e9ff853ec7763cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page