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.

Finally

See also: other libraries in the JAX ecosystem

Equinox: neural networks.

Optax: first-order gradient (SGD, Adam, ...) optimisers.

Diffrax: numerical differential equation solvers.

Optimistix: root finding, minimisation, fixed points, and least squares.

Lineax: linear solvers.

BlackJAX: probabilistic+Bayesian sampling.

Orbax: checkpointing (async/multi-host/multi-device).

sympy2jax: SymPy<->JAX conversion; train symbolic expressions via gradient descent.

Eqxvision: computer vision models.

Levanter: scalable+reliable training of foundation models (e.g. LLMs).

PySR: symbolic regression. (Non-JAX honourable mention!)

Disclaimer

This is not an official Google product.

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.28.tar.gz (30.4 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.2.28-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jaxtyping-0.2.28.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for jaxtyping-0.2.28.tar.gz
Algorithm Hash digest
SHA256 cd20bf1558a90c6d77c589354e35670ecc5b94925ef45bf1c020fde7b44fac8d
MD5 faa788c95760608f6778ba2c2bd57b49
BLAKE2b-256 47fbbe2d0183f5cb48227cf32adf4aef70740b44c26c43146990261bbe9e989a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jaxtyping-0.2.28-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for jaxtyping-0.2.28-py3-none-any.whl
Algorithm Hash digest
SHA256 4a54eb964087cd46463d9a86c805b4e4f5c20cce5f22049d6f35a26d9f105bd3
MD5 ca70bb1eb4cad11a4e574e25aef9d5f6
BLAKE2b-256 9a0c8055b6e60e6b2795c1cee6058287c39f168466e5937d6437b58b6c7e77f7

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