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 checking for:

  1. shape and dtype of JAX arrays;
  2. PyTrees.

For example:

from jaxtyping import Array, Float, PyTree

# Accepts floating-point 2D arrays with matching dimensions
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

Also install your favourite runtime type-checking package. The two most popular are typeguard (which exhaustively checks every argument) and beartype (which checks random pieces of arguments).

Documentation

Full API reference

FAQ (static type checking, flake8, etc.)

Finally

See also: other tools in the JAX ecosystem

Neural networks: Equinox.

Numerical differential equation solvers: Diffrax.

Computer vision models: Eqxvision.

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

Acknowledgements

Shape annotations + runtime type checking is inspired by TorchTyping.

The concise syntax is partially inspired by etils.array_types.

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.10.tar.gz (14.6 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.10-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jaxtyping-0.2.10.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for jaxtyping-0.2.10.tar.gz
Algorithm Hash digest
SHA256 3a4c2f21ed9c2ba38cbb3bb1efe9980cd07128fe70ebea084b9bcabf05055b4e
MD5 a796d7460d38237f3d777e10bb51f03c
BLAKE2b-256 b7d38d20b68dfdad9dd7c9acf299a4122ab8f0d412e85acf83278eba4eea9c48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jaxtyping-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for jaxtyping-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 da65ac32648dcc9717a20d2e9c69a84d68d0decaa1eeba4052d8b91606c44d86
MD5 6f7c70c5b13380758f2f01de6f3d3665
BLAKE2b-256 58de899834732737ebfef77c11a4a42899287b4f60e97e7410792d7b43b22f22

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