$npx skillfedfor your agent

torchtyping

Runtime type annotations for the shape, dtype etc. of PyTorch Tensors.

With conditionsPyPI Artificial IntelligenceReleased Aug 2024186.2K downloads / moApache-2.0Pure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — torchtyping-0.1.5-py3-none-any.whl
v0.1.5 · released 2024-08-01 · Python >=3.7.0 · 2 runtime deps: torch, typeguard

Yes, if you are actively developing PyTorch models and want runtime shape validation. The low install friction and permissive license make adoption straightforward. However, be aware that the package is aging and the author recommends jaxtyping for new projects due to better static type checker support. If you need static type checking or are starting a new project, consider jaxtyping instead; if you have an existing codebase using torchtyping or prefer runtime-only validation, it remains functional.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires typeguard <3.0.0 if using runtime checking; Python >=3.7 and PyTorch >=1.7.0.
  • Low friction installation with only torch and typeguard as runtime dependencies.
  • Maintenance status is aging—last release was in 2024—but the repository remains active and unarchived with 1484 stars.

License · maintenance · safety

Apache-2.0 (permissive) — Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

last release 2024-08-01 (743 days) · last repo commit 2025-05-02 · 1,484 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 186,194 downloads/mo, #9,992 on PyPI

Verify before relying

pip install torchtyping typeguard

from torch import rand
from torchtyping import TensorType, patch_typeguard
from typeguard import typechecked

patch_typeguard()

@typechecked
def func(x: TensorType["batch"], y: TensorType["batch"]) -> TensorType["batch"]:
    return x + y

func(rand(3), rand(3))  # works
  • Whether static type checkers (mypy, pyright) fully recognize TensorType annotations without additional configuration
  • Current adoption rate and community support level relative to the newer jaxtyping recommendation
  • Whether the package remains actively maintained beyond the most recent release date
Same gist for agents: .md · .json

What it is and what it does

torchtyping lets you annotate PyTorch tensors with their expected shape, dtype, layout, and dimension names directly in function signatures. Instead of writing comments like `# x has shape (batch, hidden_state)`, you write `x: TensorType["batch", "hidden_state"]`, making tensor contracts explicit and machine-readable. When typeguard is installed and enabled, these annotations are checked at runtime to catch shape mismatches and dtype errors early.

The package integrates with typeguard for optional runtime validation and pytest for test-time checking, so you can enforce tensor contracts without runtime overhead in production. It supports flexible shape specifications (exact sizes, named dimensions, variable batch dimensions with `...`), multiple dtype checks, and extensible custom validation rules. However, the author now recommends jaxtyping for new projects, citing better static type checker compatibility.

Use it for

  • Document tensor shapes in neural network functions to prevent shape mismatch bugs during model development.
  • Validate batch dimensions and channel sizes at runtime during training to catch data pipeline errors early.
  • Enforce consistent dimension naming across a codebase to improve code clarity and reduce shape-related debugging.
  • Test tensor contracts in pytest with automatic typeguard patching to catch shape violations in unit tests.
  • Combine with typeguard's import hook to automatically check all tensor operations in a module without manual decorators.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you are actively developing PyTorch models and want runtime shape validation.

The low install friction and permissive license make adoption straightforward. However, be aware that the package is aging and the author recommends jaxtyping for new projects due to better static type checker support. If you need static type checking or are starting a new project, consider jaxtyping instead; if you have an existing codebase using torchtyping or prefer runtime-only validation, it remains functional.

Install

torchtyping on PyPI

Before you install

Low friction installation with only torch and typeguard as runtime dependencies. Maintenance status is aging—last release was in 2024—but the repository remains active and unarchived with 1484 stars.

Requires typeguard <3.0.0 if using runtime checking; Python >=3.7 and PyTorch >=1.7.0.

License in practice

Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install torchtyping typeguard

from torch import rand
from torchtyping import TensorType, patch_typeguard
from typeguard import typechecked

patch_typeguard()

@typechecked
def func(x: TensorType["batch"], y: TensorType["batch"]) -> TensorType["batch"]:
    return x + y

func(rand(3), rand(3))  # works

Verify before relying

  • Whether static type checkers (mypy, pyright) fully recognize TensorType annotations without additional configuration
  • Current adoption rate and community support level relative to the newer jaxtyping recommendation
  • Whether the package remains actively maintained beyond the most recent release date

Package facts

LicenseApache-2.0 permissive
Python supportSupports the current Python release >=3.7.0
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
torchtypeguard
MaintenanceAging 743 days since the last release
Last repo commit
First released
Downloads186,194 / month, #9,992 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 3 - AlphaFramework :: PytestIntended Audience :: DevelopersIntended Audience :: Financial and Insurance IndustryIntended Audience :: Information TechnologyIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: Information AnalysisTopic :: Scientific/Engineering :: Mathematics

Evidence: torchtyping-0.1.5-py3-none-any.whl

Tags

Capabilities
pytorch tensor type annotationsshape dtype checking tensorsruntime tensor validationnamed tensor type hintspytorch type safetytensor dimension checkingpytorch static type checking
Topics
pytorchtype-hintstensor-validation

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “pytorch tensor type annotations”

  • torchtypingAdds type annotations for PyTorch tensor shape, dtype, layout, and…
  • jaxtypingProvides type annotations and runtime type-checking for array shape…
  • torch-complexProvides a Python class wrapping real and imaginary PyTorch tensors…

Give your agent the search over MCP, or paste the wish link into any chat.

More Artificial Intelligence packages

litellm With conditions
PyPI · Artificial Intelligence · released Aug 2026

LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.

Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.

MITcompiled wheel
682.8Mdownloads / mo
huggingface-hub Worth it
PyPI · Artificial Intelligence · released Aug 2026

Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.

Install it if you work with Hugging Face Hub models or datasets.

Apache-2.0pure Python · 3.10.0+
442.4Mdownloads / mo
langchain Worth it
PyPI · Python Modules · released Aug 2026

LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.

MITpure Python
315.4Mdownloads / mo
hf-xet With conditions
PyPI · Artificial Intelligence · released Aug 2026

hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.

Apache-2.0compiled wheel · 3.8+
258.4Mdownloads / mo
tokenizers Worth it
PyPI · Artificial Intelligence · released Apr 2026

Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.

Apache-2.0compiled wheel · 3.10+
222.9Mdownloads / mo
transformers Worth it
PyPI · Artificial Intelligence · released Aug 2026

Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.

Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.

permissive licensepure Python · 3.10.0+
186.6Mdownloads / mo

See also jaxtyping · lovely-tensors · typeguard · spmd-types · torch-complex · safetensors · nptyping · torch · rotary-embedding-torch · pytorch