PyTorch

PyTorch is an open-source deep learning framework developed by Meta AI (originally Facebook AI Research). It is the dominant library for neural network research and increasingly for production deployment. PyTorch implements automatic-differentiation over tensors (multi-dimensional arrays), enabling efficient backpropagation across GPU hardware.


Key Features

FeatureDescription
Dynamic computation graphGraph is built at runtime (eager mode); flexible Python control flow
Tensor operationsN-dimensional array operations executed on GPU via CUDA
Autograd enginetorch.Tensor.backward() triggers backpropagation
nn.ModuleBase class for all neural-network components (layers, models)
OptimisersSGD, Adam, etc. implement gradient-descent variants

Relationship to Micrograd

micrograd is a pedagogical scalar version of what PyTorch does at tensor scale. The mathematics is identical:

  • Value in micrograd → torch.Tensor in PyTorch
  • _backward closure → PyTorch’s autograd function
  • Manual .grad accumulation → tensor.grad attribute

Karpathy explicitly positions micrograd as “the engine at the heart of PyTorch or JAX” — but at scalar granularity for clarity.


Usage in Knowledge Base

PyTorch is the implementation framework for:


Sources