
Pytorch Lightning
If you're tired of writing the same GPU handling, distributed training, and logging boilerplate in PyTorch, this wraps it all in a clean LightningModule structure. You define training_step and configure_optimizers, then Trainer handles device placement, DDP/FSDP/DeepSpeed, checkpointing, and TensorBoard logging. The same code runs on your laptop or 8 GPUs without changes. It's opinionated about code organization, which is either helpful structure or annoying constraint depending on your project. Works well for standard training loops, though you'll fight it if you need unusual control flow. The callback system is genuinely useful for early stopping and learning rate monitoring without cluttering your main code.
- skills.sh installs
- 1K
- GitHub stars
- 14.4K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add orchestra-research/ai-research-skills --skill pytorch-lightning --agent claude-codeInstalls into .claude/skills of the current project.
Files
PyTorch Lightning - High-Level Training Framework
Quick start
PyTorch Lightning organizes PyTorch code to eliminate boilerplate while maintaining flexibility.
Installation:
pip install lightning
Convert PyTorch to Lightning (3 steps):
import lightning as L
import torch
from torch import nn
from torch.utils.data import DataLoader, Dataset
# Step 1: Define LightningModule (organize your PyTorch code)
class LitModel(L.LightningModule):
def __init__(self, hidden_size=128):
super().__init__()
self.model = nn.Sequential(
nn.Linear(28 * 28, hidden_size),
nn.ReLU(),
nn.Linear(hidden_size, 10)
)
def training_step(self, batch, batch_idx):
x, y = batch
y_hat = self.model(x)
loss = nn.functional.cross_entropy(y_hat, y)
self.log('train_loss', loss) # Auto-logged to TensorBoard
return loss
def configure_optimizers(self):
return torch.optim.Adam(self.parameters(), lr=1e-3)
# Step 2: Create data
train_loader = DataLoader(train_dataset, batch_size=32)
Sponsors
Details
- Repository
- github.com/orchestra-research/ai-research-skills
- Categories
- AI & Agent Building, Data Science & ML, Automation & Workflows
- First seen
- Jun 3, 2026
More from orchestra-research/ai-research-skills
All 95- Axolotl1K
- Hqq Quantization1K
- Sentence Transformers1K
- Clip1K
- Huggingface Tokenizers1K
- Long Context1K
- Nanogpt1K
- Pytorch Fsdp21K
- Awq Quantization1K
- Modal Serverless Gpu1K
- Moe Training1K
- Sglang1K
- Chroma1K
- Instructor1K
- Speculative Decoding1K
- Llama Factory1K
- Model Merging1K
- Nemo Curator1K
- Transformer Lens Interpretability1K
- Distributed Llm Pretraining Torchtitan1K
- Openrlhf Training1K
- Evaluating Code Models1K
- Gptq1K
- Sentencepiece1K