pytorch-lightning
PyTorch Lightning is the lightweight PyTorch wrapper for ML researchers. Scale your models. Write less boilerplate.
What it is and what it does
PyTorch Lightning is a structured wrapper around PyTorch that enforces separation of research code (the LightningModule), engineering code (handled by the Trainer), and auxiliary concerns like logging and callbacks. It lets you write a model once and then scale it to multiple GPUs, TPUs, or CPUs by changing only Trainer configuration—no changes to your model code required. The package handles distributed training setup, mixed-precision training, checkpointing, early stopping, and integration with experiment loggers (TensorBoard, Weights & Biases, MLflow, and others) automatically.
The design philosophy is to eliminate boilerplate: you define training_step, validation_step, and configure_optimizers in your LightningModule, organize data into DataLoaders or a LightningDataModule, and let the Trainer orchestrate the rest. It's built on top of torch, tqdm, PyYAML, fsspec, torchmetrics, packaging, typing-extensions, and lightning-utilities, all of which are standard dependencies in the PyTorch ecosystem. The package is actively maintained, has no known vulnerabilities, and supports Python 3.10 through 3.13.
Use it for:
- Train a model on a single GPU, then scale to 8 GPUs or 256 GPUs across multiple nodes without modifying model code.
- Manage experiment tracking and logging across multiple runs with built-in logger integrations.
- Implement early stopping and model checkpointing with minimal boilerplate code.
- Export trained models to TorchScript or ONNX for production inference.
- Run the same training code on TPUs, GPUs, or CPUs by changing only the Trainer accelerator parameter.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyTorch Lightning wraps PyTorch training code to separate research logic from engineering boilerplate, enabling distributed training across GPUs, TPUs, and CPUs without code changes.
Yes. PyTorch Lightning is a mature, actively maintained framework (31287 stars, recent release) with zero known vulnerabilities, permissive licensing, and low install friction. It's worth installing if you want to reduce training boilerplate and gain automatic support for distributed training, mixed precision, and experiment management without learning a new deep-learning abstraction. If you're writing simple single-GPU scripts, the overhead may not justify it; for research or production workflows involving scaling, logging, or checkpointing, it's a clear win.
Install
pytorch-lightning on PyPI
pip
pip install pytorch-lightninguv
uv add pytorch-lightningpoetry
poetry add pytorch-lightningInstalling pytorch-lightning
Before you install
Low friction install with a pure-Python wheel. Active maintenance with a recent release (79 days ago) and strong repository signals (31287 stars, last commit 2026-08-09). Depends on torch and eight other runtime packages, all standard in the ML ecosystem.
License in practice
Apache-2.0 permissive license allows commercial use, modification, and distribution with minimal restrictions—suitable for both research and production deployments.
Quickstart
pip install pytorch-lightning
import pytorch_lightning as pl
from torch.utils.data import DataLoader
class LitModel(pl.LightningModule):
def training_step(self, batch, batch_idx):
# your training logic
return loss
trainer = pl.Trainer()
trainer.fit(model, DataLoader(train_data), DataLoader(val_data))
Requires Python >=3.10 and torch as a runtime dependency.
Verify before relying
- Whether the 40+ advanced features mentioned in the description are all stable or some remain experimental.
- Performance overhead compared to raw PyTorch for simple single-GPU training workflows.
- Compatibility guarantees across the PyTorch versions tested (1.12, 1.13, 2.0, 2.1).
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — torch, tqdm, PyYAML, fsspec, torchmetrics, packaging, typing-extensions, lightning-utilities |
| Maintenance | actively maintained — 79 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 11,232,102/month — #1,406 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytorch_lightning-2.6.5-py3-none-any.whl
Keywords: deep learning, pytorch, AI
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
lightningLightning is a framework that organizes PyTorch…
permissive · top 5,000 on PyPI
nv-one-logger-pytorch-lightning-integrationAdds training telemetry collection to Lightning…
permissive · top 15,000 on PyPI
trainerTrainer is a PyTorch model training framework…
permissive · top 15,000 on PyPI
coqui-tts-trainerA PyTorch model trainer framework that handles…
permissive · top 15,000 on PyPI
litdataLitData optimizes and streams large datasets…
permissive · top 15,000 on PyPI
agentlightningAgent Lightning optimizes AI agents using…
unclear · top 15,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI
accelerateAccelerate abstracts away distributed training…
permissive · top 1,000 on PyPI
torchrunxtorchrunx distributes PyTorch training…
copyleft · top 15,000 on PyPI
torchinfoGenerates detailed summaries of PyTorch neural…
permissive · top 15,000 on PyPI