Type annotations and runtime checking for shape and dtype of JAX/NumPy/PyTorch/etc. arrays.
Project description
jaxtyping
Type annotations and runtime type-checking for:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jaxtyping-0.2.36.tar.gz
.
File metadata
- Download URL: jaxtyping-0.2.36.tar.gz
- Upload date:
- Size: 45.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 781ac44a3cf8982063d7ee48b5008ccfad7b13793bf878eb3058d5319aa08f0f |
|
MD5 | 48bb10d295f92939ae9fdcae2c93b389 |
|
BLAKE2b-256 | a6cc76e38d7d24e590d1a819c9b203b537e5c6416e1c1aebc8c25f598a00d474 |
File details
Details for the file jaxtyping-0.2.36-py3-none-any.whl
.
File metadata
- Download URL: jaxtyping-0.2.36-py3-none-any.whl
- Upload date:
- Size: 55.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b19bcbd4009df8734602203402483a4066ad2eb3382904432e370588e9c9707d |
|
MD5 | 0de638b0fdd44eb0cd1a23e1d552ccbd |
|
BLAKE2b-256 | 9499c83c6a97f4382caf1c9bfeeeca935d3eb1f479f711665aeadf4408048107 |