← Back to Leaderboard
PLightning-AI

Lightning-AI/pytorch-lightning

PyTorch training with a managed Trainer and Fabric for custom distributed loops

AI FrameworkQuickstart ↓
Engineering Health (Methodology)
A+ · 95/100
Maintenance Activity
● Updated yesterday
Latest Release
2.6.6
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption23/25
Release Cadence17/20
License Clarity20/20
GPU
Total Stars
★ 31,488
24h Growth
+0
7d Growth
+31
Forks
3,885

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

Lightning-AI/pytorch-lightning Star History (2020-01-12 - 2026-12-03) ALL-TIME STAR HISTORY (2020-01 – 2026-12) +28.5k in 2517d · avg +11/day 33.1k 16.5k 0 2020-01-12: ★ 2,9912020-06-13: ★ 5,4602020-11-14: ★ 9,0112021-04-17: ★ 12,0752021-09-18: ★ 14,3942022-02-19: ★ 16,4202022-07-23: ★ 18,5202022-12-24: ★ 20,1232023-05-27: ★ 22,4772023-10-28: ★ 24,1622024-03-30: ★ 25,9022024-08-31: ★ 27,2412025-02-01: ★ 28,3162025-07-05: ★ 29,2952025-12-06: ★ 30,2252026-05-09: ★ 30,9412026-12-03: ★ 31,488 ★ 31.5k 2020-01 2023-06 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

PyTorch Lightning offers two levels of control over the same Python/PyTorch stack. With LightningModule, forward defines the model's prediction path, training_step computes the loss for a batch, and configure_optimizers supplies the optimizer. Trainer.fit drives the training lifecycle from the module and data loaders. Callbacks and loggers let teams add checkpointing, stopping criteria, and experiment tracking without putting those concerns in model code.

Fabric leaves the training loop with the caller. launch() starts the execution environment, setup() prepares the model and optimizer, setup_dataloaders() prepares the input pipeline, and fabric.backward(loss) handles backpropagation under the selected strategy and precision. The root requirements.txt includes requirements/fabric/base.txt and requirements/pytorch/base.txt; pyproject.toml lists setuptools, wheel, and packaging as build requirements, not runtime services.

Key Capabilities & Differentiators

Lightning is primarily a pretraining and fine-tuning framework, not an LLM inference engine. Its execution modes span CPU, CUDA GPUs, Apple Silicon via MPS, and TPU. Fabric exposes DDP, FSDP, and DeepSpeed as strategy choices and 16-mixed as a precision setting. The eight-device, 32-node example shows how to express a 256-GPU job; it does not establish throughput, scaling efficiency, or compatibility across all accelerator and strategy combinations.

Examples span ResNet image classification, BERT text classification, and Llama 3.1 8B fine-tuning. Trainer can monitor val_loss through EarlyStopping and ModelCheckpoint and route metrics to integrations such as TensorBoard, Weights & Biases, or MLflow. TorchScript and ONNX export provide handoff options for compatible models; neither supplies a request-serving stack. LitServe is a separate project for that role.

Trade-offs & Limitations

Trainer pays off when multiple projects can share a training lifecycle, consistent metrics, and checkpoint policies. The cost is that custom update schedules and unusual execution order must fit its hooks or use a lower-level interface. Fabric is a better fit when the loop itself is part of the research: it removes much of the device and distributed setup while keeping update order explicit. Plain PyTorch offers the most direct control, but leaves the team to integrate and maintain those pieces.

Changing Trainer or Fabric settings can preserve core model code, but it does not make distributed jobs operationally equivalent. Validate memory use, data-loader throughput, and checkpoint recovery for each target configuration; model size, input shape, per-device batch size, and precision all affect the result. Apache-2.0 permits commercial use, but external packages, datasets, and weights have their own terms.

Hardware & Deployment Guide

Install with pip install lightning or conda install lightning -c conda-forge. Start with a compatible Python/PyTorch environment and select the device backend for the target hardware: CPU for a smoke test, CUDA for NVIDIA GPU jobs, or the corresponding MPS or TPU setup. Lightning runs on self-managed hardware or cloud instances; Lightning Cloud is optional. Before increasing node count, validate one complete training and checkpoint-restore cycle, then check network behavior, data access, and checkpoint visibility across nodes.

Release 2.6.6 restricts checkpoint instantiators to a trusted allowlist as part of a code-execution fix; use a patched release and keep untrusted checkpoints out of the load path. Fabric 2.6.5 changed S3/GCS checkpoint uploads in _atomic_save to use fs.pipe(), so test save and restore against the storage backend you actually use. The removal of Neptune logging in 2.6.4 also makes logger compatibility worth checking even on a patch upgrade.

Training lifecycle: LightningModule defines the step and optimizer hooks; Trainer.fit drives execution.
Custom loops: Fabric exposes launch, setup, setup_dataloaders, and backward without taking control of the optimizer schedule.
Distributed scale: DDP, FSDP, and DeepSpeed are exposed as strategies; devices=8, num_nodes=32 illustrates a 256-GPU configuration, not a benchmark.
Experiment controls: Early stopping and checkpoint callbacks can monitor val_loss; logger integrations include TensorBoard, Weights & Biases, Comet, and MLflow.
Serving boundary: TorchScript and ONNX export are distinct from request serving; LitServe is a separate project.
Upgrade considerations: 2.6.6 tightened checkpoint loading, while 2.6.4 removed the Neptune logger integration.
Best For

Teams standardizing PyTorch pretraining and fine-tuning across hardware, or researchers who need distributed execution without giving up their custom loops.

Skip If

Your main need is online LLM serving, or your PyTorch loop is simple enough that a framework lifecycle would add more complexity than it removes.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

GPU
pip install lightning

Comparison vs. Top LLMs & Inference Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
pytorch-lightning ★31.5k+31PythonApache-2.0PyTorch training with a managed Trainer and Fabric for custom distributed loops
keras64.5k+24PythonApache-2.0Multi-backend Python SDK for building, training, and running deep learning model
ludwig11.8k+6PythonApache-2.0YAML-first framework for fine-tuning, training, and serving LLMs and multimodal
scikit-learn68.5k+126PythonBSD-3-ClauseIn-process Python library for machine learning and data mining

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/Lightning-AI/pytorch-lightning.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

Lightning-AI/pytorch-lightning Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about pytorch-lightning

How much of an existing PyTorch project needs to change?

Keep the model and tensor operations in PyTorch. With Trainer, put the loss computation in training_step, return the optimizer from configure_optimizers, and pass your data loaders to Trainer.fit. If the order or timing of updates is central to your algorithm, keep the loop and use Fabric to set up the model, optimizer, and data loaders and to run backpropagation.

How should I estimate GPU memory and runtime overhead?

There is no universal VRAM requirement. Measure peak memory and step time with your actual model, inputs, per-device batch size, and precision. When comparing DDP with a sharded strategy such as FSDP, measure throughput as well as memory: a configuration that fits may not be the fastest. To isolate orchestration overhead, benchmark Lightning against a plain PyTorch loop with equivalent work and settings.

Can we use Lightning commercially and self-host it?

Yes. The repository is Apache-2.0 and can run on your own hardware or cloud without Lightning Cloud. Preserve the applicable license and notices when distributing it, and check the terms for third-party packages, datasets, and model weights separately. Self-hosting also leaves checkpoint access and provenance under your control.

When should I choose Trainer, Fabric, or plain PyTorch?

Choose Trainer when you want a common training lifecycle, callbacks, and logging across projects. Choose Fabric when your loop is already explicit and you want help with devices, precision, and distributed execution without adopting Trainer hooks. Stay with plain PyTorch when the loop is small or direct control over execution outweighs the cost of maintaining that infrastructure.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining Lightning-AI/pytorch-lightning? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature Lightning-AI/pytorch-lightning on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare