jaxtyping  by patrick-kidger

Typing library for array shapes/dtypes

Created 3 years ago
1,530 stars

Top 27.1% on SourcePulse

GitHubView on GitHub
Project Summary

jaxtyping provides type annotations and runtime checking for the shape and dtype of arrays from JAX, PyTorch, NumPy, MLX, and TensorFlow, as well as PyTrees. It enables developers to enforce array dimensions and data types at runtime, improving code robustness and maintainability for machine learning and scientific computing tasks.

How It Works

The library uses a novel annotation system where array types are specified with a base type (e.g., Float, Int) followed by shape and dtype constraints within square brackets (e.g., Float[Array, "batch height width"]). This allows for precise specification of array structures, which can then be validated at runtime by compatible type-checking libraries like typeguard or beartype. This approach offers a declarative way to ensure array integrity without manual checks.

Quick Start & Requirements

  • Install via pip: pip install jaxtyping
  • Requires Python 3.10+. JAX is an optional dependency.
  • Compatible with typeguard or beartype for runtime checking.
  • Documentation: https://docs.kidger.site/jaxtyping/

Highlighted Details

  • Supports JAX, PyTorch, NumPy, MLX, and TensorFlow arrays.
  • Enables type checking for PyTrees containing primitive types or arrays.
  • Annotations are compatible with popular runtime type checkers.
  • Offers a clear, declarative syntax for array shape and dtype specification.

Maintenance & Community

  • Developed by Patrick Kidger.
  • Further details on community and roadmap are not explicitly provided in the README.

Licensing & Compatibility

  • License: MIT.
  • Compatible with commercial and closed-source projects.

Limitations & Caveats

The library is primarily focused on static analysis and runtime checking of array shapes and dtypes; it does not perform numerical computations itself. JAX-specific types are unavailable if JAX is not installed.

Health Check
Last Commit

4 months ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
4
Star History
27 stars in the last 30 days

Explore Similar Projects

Starred by Awni Hannun Awni Hannun(Author of MLX; Research Scientist at Apple), Patrick Kidger Patrick Kidger(Core Contributor to JAX ecosystem), and
4 more.

einx by fferflo

0%
408
Tensor operation library using Einstein-inspired notation
Created 2 years ago
Updated 5 months ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Roy Frostig Roy Frostig(Coauthor of JAX; Research Scientist at Google DeepMind), and
8 more.

penzai by google-deepmind

0.2%
2k
JAX research toolkit for neural network building, editing, and visualization
Created 1 year ago
Updated 2 months ago
Starred by Bojan Tunguz Bojan Tunguz(AI Scientist; Formerly at NVIDIA), Alex Chen Alex Chen(Cofounder of Nexa AI), and
19 more.

ggml by ggml-org

0.3%
13k
Tensor library for machine learning
Created 3 years ago
Updated 2 days ago
Feedback? Help us improve.