PyTorch Lightning structures PyTorch training code so loops, distributed setups, precision, and logging need less boilerplate. The same model code can scale from a single CPU to multi-node GPU or TPU runs.
Overview
PyTorch Lightning is a deep learning framework layered on PyTorch for pretraining and fine-tuning models. Developers define a LightningModule with model, training, and optimizer logic; a Trainer then handles repetitive engineering such as device placement, distributed strategies, mixed precision, checkpointing, and experiment logging.
The project ships two related packages: the high-level PyTorch Lightning API with Trainer-centric workflows, and Lightning Fabric for lower-level control over loops and scaling when teams want to assemble custom trainers. Both aim to keep research code readable while automating hardware and distributed-training details.
Built-in support covers multi-GPU and multi-node training, TPU runs, 16-bit precision, early stopping, callbacks, and exports to TorchScript or ONNX. Integrations include common experiment trackers and dozens of other machine learning tools. Example workflows span classification, segmentation, detection, summarization, diffusion, and LLM fine-tuning.
You install the package with pip or conda and run training scripts on your own machines or cloud GPUs. Lightning Cloud is a separate hosted option for managed GPU training, but the framework itself runs wherever PyTorch is installed.
Key features
- LightningModule and Trainer abstractions
- Multi-GPU and multi-node without code changes
- TPU and mixed-precision training options
- Checkpointing and early stopping callbacks
- Experiment logger integrations
- TorchScript and ONNX export helpers
- Lightning Fabric for custom loops
- Example recipes across ML tasks
Use cases
- Fine-tuning large language models
- Multi-GPU image classification training
- Diffusion and generative model pretraining
- Reinforcement learning experiment loops
- Reproducible research training pipelines