lightning
The Deep Learning framework to train, deploy, and ship AI products Lightning fast.
What it is and what it does
Lightning is a training framework built on top of PyTorch that eliminates boilerplate infrastructure code. Instead of manually managing backpropagation, mixed precision, distributed training, and device placement across projects, you define your model as a LightningModule with training_step and configure_optimizers methods, then pass it to a Trainer that handles the rest. The framework scales from single CPU to thousands of GPUs across multiple nodes without changing your core model code.
It sits between plain PyTorch (which requires you to write all infrastructure) and higher-level frameworks that hide model details. You retain full control over model logic while Lightning automates the engineering: logging, checkpointing, gradient accumulation, distributed synchronization, and hardware acceleration. It supports pretraining and finetuning workflows across diverse tasks—image classification, segmentation, text, audio, LLM finetuning, and time-series forecasting.
Use it for:
- Scale a single-GPU PyTorch model to multi-node training without rewriting training loops.
- Pretrain or finetune large models (LLMs, diffusion models) with automatic mixed precision and distributed strategies.
- Manage experiment tracking, checkpointing, and logging across multiple training runs.
- Train on TPUs or other accelerators by changing one Trainer parameter instead of rewriting device logic.
- Build reproducible research code that separates model definition from training infrastructure.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Lightning is a framework that organizes PyTorch code to automate distributed training infrastructure—handling backpropagation, mixed precision, multi-GPU, and multi-node setups—while keeping your model logic unchanged.
Yes, if you train PyTorch models at any scale beyond single-GPU prototypes. Lightning eliminates repetitive distributed training boilerplate while keeping model code readable and portable. One known vulnerability (PYSEC-2026-3624) should be reviewed before production use, but the active maintenance status and permissive license make it a solid choice for research and production workflows.
Install
lightning on PyPI
pip
pip install lightninguv
uv add lightningpoetry
poetry add lightningInstalling lightning
Before you install
Low friction: pure Python wheel with 9 runtime dependencies including torch and torchmetrics. Actively maintained with recent releases; last commit 2026-08-09 and 31287 repository stars indicate ongoing development.
License in practice
Apache-2.0 is permissive, allowing commercial use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
pip install lightning
import lightning as L
import torch.nn as nn
class LitModel(L.LightningModule):
def __init__(self):
super().__init__()
self.layer = nn.Linear(10, 1)
def training_step(self, batch, batch_idx):
return self.layer(batch[0]).mean()
def configure_optimizers(self):
return torch.optim.Adam(self.parameters())
trainer = L.Trainer()
trainer.fit(model, train_dataloader)
Requires Python >=3.10 and torch as a runtime dependency; GPU training requires CUDA-compatible hardware and drivers.
Verify before relying
- Scope and severity of PYSEC-2026-3624 vulnerability and whether it affects typical training workflows.
- Whether the framework's abstraction overhead is acceptable for custom training loops requiring fine-grained control.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 9 — PyYAML, fsspec, lightning-utilities, packaging, torch, torchmetrics, tqdm, typing-extensions, pytorch-lightning |
| Maintenance | actively maintained — 79 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,376,248/month — #1,919 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | 1 — PYSEC-2026-3624 |
Evidence: 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
lightning-sdkPython SDK to create, manage, and automate…
permissive · top 15,000 on PyPI
litdataLitData optimizes and streams large datasets…
permissive · top 15,000 on PyPI
pytorch-lightningPyTorch Lightning wraps PyTorch training code…
permissive · top 5,000 on PyPI
nv-one-logger-pytorch-lightning-integrationAdds training telemetry collection to Lightning…
permissive · top 15,000 on PyPI
fairscaleFairScale extends PyTorch with distributed…
permissive · top 15,000 on PyPI
litserveLitServe lets you build custom inference…
permissive · top 15,000 on PyPI
pytorch-forecastingPyTorch Forecasting provides neural network…
permissive · top 15,000 on PyPI
pytorch-ignitePyTorch Ignite provides a high-level training…
permissive · top 15,000 on PyPI
trainerTrainer is a PyTorch model training framework…
permissive · top 15,000 on PyPI
agentlightningAgent Lightning optimizes AI agents using…
unclear · top 15,000 on PyPI