Lightning open source

Open-source libraries for training and serving AI models at scale. Powering generative AI since 2015.

Lightning
# pip install lightningimport lightning as Lmodel = LitAutoEncoder()  # any LightningModuletrainer = L.Trainer(accelerator="gpu", devices=8, strategy="fsdp")trainer.fit(model, train_loader)

Python frameworks to trainand deploy models, Lightning fast

Six open-source libraries for the whole model lifecycle, from data loading and training to evaluation and serving.

  • Pretrain and finetune AI models of any size on one or many GPUs. Includes Lightning Fabric for expert-level control.

    Read the docs →
PyTorch Lightning
import lightning as Limport torch, torch.nn as nn, torch.nn.functional as Fclass LitAutoEncoder(L.LightningModule):    def __init__(self):        super().__init__()        self.encoder = nn.Sequential(nn.Linear(28 * 28, 64), nn.ReLU(), nn.Linear(64, 3))        self.decoder = nn.Sequential(nn.Linear(3, 64), nn.ReLU(), nn.Linear(64, 28 * 28))    def training_step(self, batch, batch_idx):        x, _ = batch        x = x.view(x.size(0), -1)        loss = F.mse_loss(self.decoder(self.encoder(x)), x)        self.log("train_loss", loss)        return loss    def configure_optimizers(self):        return torch.optim.Adam(self.parameters(), lr=1e-3)trainer = L.Trainer(accelerator="gpu", devices=8)trainer.fit(LitAutoEncoder(), train_loader)

Powering generativeAI since 2015

  1. 2015PyTorch Lightning is born
  2. 2019World's first Trainer
  3. 20192048 GPU model
  4. 2019GPU → TPU with no code changes
  5. 2020Lightning accelerators
  6. 2021TorchMetrics
  7. 2022Fabric, to scale foundation models
  8. 2023LitGPT, open LLM recipes
  9. 2024Thunder, LitData and LitServe

Design philosophy

The principles behind every Lightning library.

Foundation-model first

Lightning libraries are designed to enable the flexibility and control needed to scale billion to trillion parameter models.

Minimal APIs

We design minimal abstractions that require almost no learning curve. We don't want you to learn a new framework.

Ultimate control and flexibility

Let Lightning handle all the details when you want to focus on science, and keep full control when you want to handle the engineering.

Interoperable by design

Lightning APIs enable team-wide collaboration by enforcing best practices and standardizing codebases.

Train your firstmodel today.

Interested in building with Lightning?

Tell us what you need and we’ll reach out.

  • See a demo on workloads like yours
  • Get GPU pricing and capacity
  • Review security and compliance

Trusted by 500,000+ devs and AI teams

NVIDIACursorCiscoRunwaySupercellstability.aiBlack Forest Labs

You can also email us at sales@lightning.ai