pytorch-lightning

Organizes PyTorch training loops with built-in distributed training, callbacks, and checkpointing.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/loteiron/ZeusAgent --skill pytorch-lightning-loteiron
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: pytorch-lightning
Source: https://github.com/loteiron/ZeusAgent/tree/main/optional-skills/mlops/pytorch-lightning
Command: npx skills add https://github.com/loteiron/ZeusAgent --skill pytorch-lightning-loteiron

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires lightning, torch, transformers, and includes references (resource) components.

What problem does it solve? Writing raw PyTorch training loops requires repetitive boilerplate for device management, distributed synchronization, mixed precision, checkpointing, and logging, which introduces bugs and slows experimentation. ## Core Features & Use Cases - Structured Training Loops: Organize model code into LightningModule with training_step, validation_step, and configure_optimizers while the Trainer handles devices, precision, and logging. - Distributed Training: Switch between DDP, FSDP, and DeepSpeed strategies across multi-GPU and multi-node clusters with a single parameter change. - Callbacks and Tuning: Use ModelCheckpoint, EarlyStopping, and LearningRateMonitor callbacks, plus integrations with Ray Tune, Optuna, and WandB sweeps for hyperparameter search. - Use Case: Convert an existing PyTorch MNIST classifier into a LightningModule, then scale it from one GPU to eight GPUs with DDP and automatic best-model checkpointing without rewriting the loop. ## Quick Start Convert my PyTorch training script into a PyTorch Lightning module and train it on two GPUs with early stopping and checkpointing.

Frequently Asked Questions about pytorch-lightning

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert PyTorch code to PyTorch Lightning?▼

Move your model into a LightningModule subclass, put the forward loss computation in training_step, and return the optimizer from configure_optimizers. Then create a Trainer and call trainer.fit with your DataLoader, removing all manual device and loop code.

PyTorch Lightning vs Hugging Face Accelerate: which should I use?▼

PyTorch Lightning provides a structured framework with built-in callbacks, logging, and checkpointing for standardized training loops. Accelerate makes minimal changes to existing PyTorch code and offers more flexibility, suiting projects that need custom loop control.

Does PyTorch Lightning support multi-GPU distributed training?▼

Yes, Lightning supports DDP, FSDP, and DeepSpeed strategies by setting the strategy parameter on the Trainer. It handles process spawning, data distribution, and gradient synchronization automatically across GPUs and multiple nodes.

Why is my PyTorch Lightning training running out of memory?▼

Out-of-memory errors usually come from large batch sizes or FP32 precision. Reduce batch size, set accumulate_grad_batches to simulate larger batches, or use precision='bf16' to cut memory usage roughly in half.

How do I tune hyperparameters with PyTorch Lightning?▼

Use the built-in Tuner for learning rate and batch size finding, or integrate Ray Tune, Optuna, or WandB sweeps. These frameworks report validation metrics from the Trainer and support pruning and Bayesian search strategies.