Repolode
Lightning-AI

Lightning-AI/pytorch-lightning

A PyTorch-based deep learning framework that automates training loops, multi-GPU scaling and engineering boilerplate while keeping full control of model code.

Stars
31,445
Forks
3,849
Open issues
1,210
Last commit
8 days ago

What is it?

PyTorch Lightning is a framework for pretraining and finetuning PyTorch models. You define the model logic in a LightningModule, and the Trainer handles backpropagation, mixed precision, device placement, and distributed training across CPUs, GPUs, TPUs, and multiple nodes. The same code can run on different hardware by changing a few Trainer arguments.

The project also includes Lightning Fabric, a lower-level layer for users who want to keep their own training loop while still getting device handling and distributed strategies such as DDP, FSDP, and DeepSpeed. Built-in features include checkpointing, early stopping, logger integrations with tools like TensorBoard, Weights & Biases, and MLflow, and export to TorchScript and ONNX.

The repository provides a quick start example, a set of task-based examples covering classification, segmentation, detection, LLM finetuning, and diffusion, and documentation for both packages.

Key features

  • 01Trainer scales the same code from one CPU or GPU to multi-node clusters.
  • 02Supports TPUs, mixed precision, and distributed strategies such as DDP, FSDP, and DeepSpeed.
  • 03Lightning Fabric offers expert control over a custom training loop.
  • 04Built-in checkpointing, early stopping, and logging integrations.
  • 05Exports models to TorchScript and ONNX.

Use cases

  • Training or finetuning deep learning models in PyTorch without writing boilerplate training code.
  • Moving an existing PyTorch training script to multi-GPU or TPU hardware.
  • Building a custom training loop on top of distributed and mixed-precision primitives.
  • Running reproducible experiments with integrated experiment tracking.

Quick start

  1. 1

    Install Lightning with pip

    pip install lightning
  2. 2

    Install torchvision for the example

    pip install torchvision
  3. 3

    Save the toy example as main.py and run it

    python main.py

In collections

Topics

FAQ

What is pytorch-lightning?
A PyTorch-based deep learning framework that automates training loops, multi-GPU scaling and engineering boilerplate while keeping full control of model code. PyTorch Lightning is a framework for pretraining and finetuning PyTorch models. You define the model logic in a LightningModule, and the Trainer handles backpropagation, mixed precision, device placement, and distributed training across CPUs, GPUs, TPUs, and multiple nodes. The same code can run on different hardware by changing a few Trainer arguments.
Is pytorch-lightning free to use? What license does it have?
pytorch-lightning is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is pytorch-lightning still maintained?
Actively maintained. The last commit to pytorch-lightning was on Oct 30, 2026.
What can I use pytorch-lightning for?
Training or finetuning deep learning models in PyTorch without writing boilerplate training code. Moving an existing PyTorch training script to multi-GPU or TPU hardware. Building a custom training loop on top of distributed and mixed-precision primitives. Running reproducible experiments with integrated experiment tracking.
How do I install pytorch-lightning?
Install Lightning with pip: pip install lightning Install torchvision for the example: pip install torchvision Save the toy example as main.py and run it: python main.py
Where can I get pytorch-lightning?
The source code and installation instructions are on GitHub: https://github.com/Lightning-AI/pytorch-lightning

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects