Skip to main content

Type annotations and runtime checking for shape and dtype of JAX/NumPy/PyTorch/etc. arrays.

Project description

jaxtyping

A library providing type annotations and runtime type-checking for the shape and dtype of JAX/PyTorch/NumPy/MLX/TensorFlow arrays and tensors.

The name 'jax'typing is now historical, we support all of the above and have no JAX dependency!

from jaxtyping import Float
from torch import Tensor

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

Installation

pip install jaxtyping

Requires Python 3.10+.

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).
paramax: parameterizations and constraints for PyTrees.

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.3.7.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jaxtyping-0.3.7-py3-none-any.whl (56.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jaxtyping-0.3.7.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for jaxtyping-0.3.7.tar.gz
Algorithm Hash digest
SHA256 3bd7d9beb7d3cb01a89f93f90581c6f4fff3e5c5dc3c9307e8f8687a040d10c4
MD5 8da5437cbfcd20726478ce35945c98e0
BLAKE2b-256 3840a2ea3ce0e3e5f540eb970de7792c90fa58fef1b27d34c83f9fa94fea4729

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jaxtyping-0.3.7-py3-none-any.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for jaxtyping-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 303ab8599edf412eeb40bf06c863e3168fa186cf0e7334703fa741ddd7046e66
MD5 539f05705010ccc2bc265ada9627daf6
BLAKE2b-256 7842caf65e9a0576a3abadc537e2f831701ba9081f21317fb3be87d64451587a

See more details on using hashes here.

Supported by

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