PyTorch

A Python-first tensor library with GPU acceleration and a dynamic, define-by-run autograd engine for building and training deep neural networks.

Library
PyPI
v2.14.1
104,007 stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
96 /100 Excellent
Development Activity 100
Maintenance 96
Community 88
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
92 /100 Excellent
Architecture 92
Code Quality 93
Innovation 95
Learning Curve 88

PyTorch is an open-source machine learning framework that provides GPU-accelerated tensor computation alongside a tape-based automatic differentiation system for building neural networks. Unlike frameworks built around static computation graphs, PyTorch executes operations eagerly as Python code runs, so control flow, debugging, and stack traces behave the way they would in ordinary Python, while torch.compile (TorchDynamo plus the TorchInductor backend) can still JIT-compile hot paths down to fused CUDA/Triton kernels for production performance.

The project spans a Python-first API (torch.nn, torch.optim, torch.autograd) backed by a C++ core (ATen, c10) that dispatches operators to CPU, CUDA, ROCm, and Intel XPU backends, plus a distributed package for multi-GPU and multi-node training. It is maintained by the PyTorch Foundation under the Linux Foundation, with contributions from Meta, NVIDIA, AMD, Intel, and thousands of individual contributors, and underpins a large share of published deep learning research and production model-serving stacks.

What You Get

  • GPU-accelerated tensor library (torch.Tensor) with NumPy-like semantics, indexing, and broadcasting across CPU/CUDA/ROCm/XPU/MPS devices
  • Tape-based automatic differentiation (torch.autograd) that builds the backward graph dynamically from the exact code path executed
  • torch.nn module library covering layers, losses, and initialization for building and composing neural networks
  • torch.compile (TorchDynamo + TorchInductor) for JIT-compiling eager models into fused, hardware-specific kernels
  • torch.distributed primitives (DDP, FSDP, RPC) for scaling training across GPUs and nodes
  • TorchScript and torch.export for serializing models to run outside a Python process

Common Use Cases

  • Training and fine-tuning deep neural networks (CNNs, transformers, diffusion models) on GPU clusters
  • Research prototyping where dynamic control flow and immediate debugging matter more than static-graph optimization
  • Serving trained models in production via TorchScript, AOTInductor, or ONNX export
  • Building custom autograd-differentiable numerical pipelines (physics simulation, optimization, scientific computing) on top of torch.Tensor

Under The Hood

Architecture PyTorch is organized as a layered stack: a Python-first API (torch/) sits above a C++ core split between c10 (the cross-platform low-level foundation — allocators, device abstraction, the operator dispatcher) and ATen (the tensor/operator library, in aten/), with torch/csrc bridging the two through pybind11 bindings and the autograd engine. Operator calls flow through the dispatcher, which routes each call by device and dtype key to a concrete backend kernel (CPU, CUDA, ROCm, MPS, XPU), so the same Python-level torch.add compiles to entirely different code paths per device without user-visible branching. Layered on top of eager execution, torch._dynamo captures Python bytecode into FX graphs and torch._inductor lowers them to fused Triton or C++/OpenMP kernels, giving the project two coexisting execution models (eager and compiled) that share the same operator surface. This is a genuinely large, multi-team architecture — changing a core abstraction like the dispatcher or ATen’s operator schema has cascading effects across autograd, distributed, and the compiler stack, which the project manages with extensive code ownership boundaries (CODEOWNERS) and a dedicated torchgen code-generation layer that produces bindings from operator schemas rather than hand-writing them.

Tech Stack The core is C++20 built via CMake and scikit-build-core, with a Python 3.10+ layer on top; the Python package builds a native extension module (torch._C) exposed through pybind11. GPU support integrates NVIDIA CUDA/cuDNN/NCCL, AMD ROCm, and Intel oneAPI/XPU toolchains, with Intel MKL for CPU linear algebra. torch.compile’s Inductor backend generates and JIT-compiles Triton kernels for GPU and vectorized C++/OpenMP for CPU. Build-time dependencies include NumPy, PyYAML, and typing-extensions; the project ships prebuilt wheels via pip and conda, and Dockerfiles for containerized builds. Distributed training layers on NCCL/Gloo backends for collective communication across multi-node GPU clusters.

Code Quality The test suite is extensive, spanning thousands of files under test/ that cover autograd, distributed, dynamo/inductor, quantization, ONNX export, and per-backend numerics, built on a custom TestCase subclass (torch.testing._internal.common_utils) layered over Python’s unittest. Type checking runs through mypy with a strict-mode config (mypy-strict.ini) and custom plugins for version and sympy compatibility; style and static analysis are orchestrated through lintrunner across multiple linters (flake8, clang-format, and others). CI is exceptionally extensive — over a hundred GitHub Actions workflows validate builds and tests across OS, Python version, and hardware backend combinations, and CONTRIBUTING.md runs to well over a thousand lines documenting the build, test, and review process in detail.

What Makes It Unique PyTorch’s defining technical bet was define-by-run (dynamic) autograd at a time when the dominant frameworks used static computation graphs — the backward graph is built from whatever Python code path actually executed, so ordinary control flow (loops, conditionals, recursion) differentiates correctly with no special graph-construction API. torch.compile extends that bet rather than abandoning it: TorchDynamo captures bytecode into graphs without requiring code rewrites, and TorchInductor compiles those graphs to fused, hardware-specific kernels, so users get static-graph-level performance while keeping eager-mode debugging as the default experience. Higher-order function transforms (vmap, grad composition via functorch/AOTAutograd) and a multi-backend dispatcher that treats CPU, CUDA, ROCm, and XPU as first-class, interchangeable targets round out a design that many later ML frameworks have converged toward.

Used by 40 apps in this directory

Python
99%
MIT

Agent Lightning

AI Development

18,631

A Microsoft-built training framework that optimizes AI agents with reinforcement learning, automatic prompt optimization, or supervised fine-tuning — with near-zero code changes to your existing agent, in any framework.

View details
85
Repo Health
68
Technical
70
Dependency
Built with
Python 99%
Updated yesterday
Python
94%
Apache 2.0

ART

AI Development

10,792

Give your LLM agents on-the-job training—ART lets you apply GRPO reinforcement learning to any multi-step agentic workflow with minimal code changes.

View details
85
Repo Health
82
Technical
73
Dependency
Built with
Python 94%
Updated today
Python
83%
MIT

autoresearch

AI Agents · AI Development

97,610

Give an AI agent a real LLM training setup and let it experiment autonomously overnight — you wake up to a log of experiments and (hopefully) a better model.

View details
34
Repo Health
77
Technical
80
Dependency
Built with
Python 83%
Jupyter Notebook 17%
Updated 6 months ago
Python
89%
AGPL 3.0

clarity-upscaler

AI Design Tools · Design Tools

5,142

Free open-source AI image upscaler reaching 13K resolution using Stable Diffusion, ControlNet, and Tiled Diffusion — a self-hostable alternative to Magnific.

View details
36
Repo Health
49
Technical
68
Dependency
Built with
Python 89%
Updated 1 years ago
Python
100%
Apache 2.0

ClearML

Automation · Devops

6,903

Auto-magical MLOps platform that tracks experiments, versions data, orchestrates pipelines, and serves models with just two lines of code.

View details
93
Repo Health
79
Technical
68
Dependency
Built with
Python 100%
Updated 1 weeks ago
Rust
53%
Apache 2.0

cocoindex

AI Development · Data Engineering

11,659

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 53%
Python 47%
Updated today
Go
59%
Apache 2.0

Cog

AI Development · Developer Tools · Devops

9,489

An open-source CLI that packages machine learning models into standard, production-ready Docker containers — no Dockerfile wrangling, no CUDA version hell.

View details
85
Repo Health
88
Technical
69
Dependency
Built with
Go 59%
Rust 17%
HTML 13%
Updated 4 days ago
C
55%
Apache 2.0

Colibri

AI Development · Developer Tools

40,850

A pure-C, zero-dependency inference engine that runs GLM-5.2's 744-billion-parameter mixture-of-experts model on consumer hardware with roughly 25GB of RAM by streaming experts from disk like a JIT compiler stages hot code.

View details
83
Repo Health
86
Technical
77
Dependency
Built with
C 55%
Python 33%
Updated 2 days ago
Python
100%
GPL 3.0

ComfyUI

AI Design Tools · AI Development

136,669

The most powerful node-based AI workflow engine for creating images, video, 3D models, and audio with full control over every generation step.

View details
92
Repo Health
81
Technical
75
Dependency
Built with
Python 100%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers