pytorch-lightning

Orchestrate PyTorch neural network training with Lightning Trainer and LightningModule.

Updated Apr 9, 2026
One-click install
npx skills add https://github.com/MarbleSodas/Mavis --skill pytorch-lightning-marblesodas
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-lightning
Source: https://github.com/MarbleSodas/Mavis/tree/main/optional-skills/mlops/pytorch-lightning
Command: npx skills add https://github.com/MarbleSodas/Mavis --skill pytorch-lightning-marblesodas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

PyTorch training loops often become cluttered and error-prone when you need to handle devices, logging, checkpointing, and distributed execution; this Skill streamlines those concerns so you can focus on model logic.

Core Features & Use Cases

  • High-level training orchestration: Use Lightning’s Trainer to standardize training, validation, checkpointing, logging, and precision handling while keeping your LightningModule focused on model behavior.
  • Scalable distributed training: Switch between single-device and multi-device execution with strategies like DDP, FSDP, and DeepSpeed while keeping the training code largely unchanged.
  • Extensible callbacks system: Add behavior like early stopping, model checkpointing, learning-rate monitoring, progress bar customization, and custom hooks without rewriting core training logic.
  • Use case: Train an image classification model on your laptop first, then move to multi-GPU distributed training (and optionally larger sharded strategies) for a faster experiment cycle.

Quick Start

Install the library with pip install lightning, then create a LightningModule and run training with the Trainer by calling trainer.fit(model, train_loader).

Frequently Asked Questions about pytorch-lightning

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

FAQPage Schema
How do I reduce boilerplate in my PyTorch training loop?

You can reduce PyTorch boilerplate by structuring model logic within a LightningModule and orchestrating the training loop with a Trainer, which standardizes validation, checkpointing, and logging automatically.

How do I switch my PyTorch training to multi-GPU distributed execution?

Multi-GPU distributed training is handled by configuring the Trainer with strategies like DDP, FSDP, or DeepSpeed, allowing you to scale execution across devices without altering core training code.

Can I add early stopping and model checkpointing without rewriting my training logic?

Yes, you can implement early stopping and checkpointing through the extensible callbacks system, which attaches custom hooks and behavior to the Trainer without modifying the underlying training logic.

Does PyTorch Lightning support mixed precision and learning-rate monitoring?

Mixed precision and learning-rate monitoring are supported natively by the Trainer, which manages precision handling and integrates with logging utilities to track training metrics.

What is the best way to scale an image classification model from a laptop to distributed training?

The best way to scale is to train the LightningModule on a laptop first, then switch the Trainer to a distributed strategy like DDP or FSDP for a faster, multi-GPU experiment cycle.

How do I start training a neural network after installing the lightning package?

After installing lightning, define your model as a LightningModule, prepare your data loaders, and execute training by calling the fit method on the Trainer with your model and data.