# patrick-kidger/torchtyping

Type annotations and dynamic checking for a tensor's shape, dtype, names, etc.

Repository: https://github.com/patrick-kidger/torchtyping
Canonical: https://ross.abutalabs.com/products/torchtyping
Language: Python
License: Apache-2.0
License Family: permissive
Topics: tensors, named-tensors, shape, pytorch, typing, python-typing
Last push: 2025-05-02T08:44:58+00:00

## Health v2 (maintenance only)
Score: 41/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 19, release rhythm 35, longevity 100
- inputs: {"age_days": 1984, "days_push": 488, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1482, forks 43 (observed 2026-08-28T04:04:51.150050+00:00)

## What it is
A Python library providing type annotations for PyTorch tensors' shape, dtype, layout, and dimension names, with optional runtime checking via typeguard. It is now in maintenance mode; the author recommends its successor jaxtyping for new projects.

## Use cases
- annotate tensor shapes in pytorch function signatures
- runtime-check tensor shapes and dtypes
- document tensor dimensions instead of comments
- catch shape mismatch bugs in pytorch code
- type-check named tensor dimensions

## When to choose
- maintaining an existing codebase already using torchtyping
- you need runtime shape checking on PyTorch and cannot switch libraries

## When to avoid
- starting a new project - use jaxtyping instead
- you need compatibility with static type checkers
- you use typeguard >= 3.0

## Facets
- artifact type: library
- maturity: maintenance
- function: type-system, testing
- domain: machine-learning, deep-learning, developer-tools
- platform: python
- tags: pytorch, tensor-shapes, runtime-type-checking, type-annotations, superseded-by-jaxtyping

## Member repositories
- patrick-kidger/torchtyping (main) score 41

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:51.150050+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:34:08.494866+00:00, confidence not recorded.
  - readme: https://github.com/patrick-kidger/torchtyping (fetched 2026-08-28T04:04:51.150050+00:00, sha 0baf66a1666d)
  - registry_pypi: https://pypi.org/pypi/torchtyping/json (fetched 2026-08-29T11:40:45.558594+00:00, sha e5208597f35f)
- Data as of 2026-08-30T08:39:29.467469+00:00.
