Skip to main content

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

Project description

jaxtyping

IMPORTANT: this relaxes the python constraint to python3.8 to be installable with eztils, but will throw a RuntimeError if you actually try to run with python3.8.

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 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

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.

Lineax: linear solvers and linear least squares.

Eqxvision: computer vision models.

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

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

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

ezjaxtyping-0.2.20.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

ezjaxtyping-0.2.20-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file ezjaxtyping-0.2.20.tar.gz.

File metadata

  • Download URL: ezjaxtyping-0.2.20.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for ezjaxtyping-0.2.20.tar.gz
Algorithm Hash digest
SHA256 aaa2396bdb515516903fb1aa73a22d53e8d79e5bdd68ac16b47805930692e291
MD5 8cb142baa917186cc456de4a10df8962
BLAKE2b-256 0086fe8f5de46329268db82473a79f7b5ca8027c5eb11e4bbf1048e86dc5a3a3

See more details on using hashes here.

File details

Details for the file ezjaxtyping-0.2.20-py3-none-any.whl.

File metadata

File hashes

Hashes for ezjaxtyping-0.2.20-py3-none-any.whl
Algorithm Hash digest
SHA256 466f483aec7265fe60cf622592861d64fb73b2f0d1bbc7cdbcef63e22e422116
MD5 fe5b23ccc97db5cd619533f375d6b278
BLAKE2b-256 a1b2bb7d6534c83419d42410ace10faacc116646442cb19b4371b53e36f8ca84

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