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-code

Installs 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
1orchestra-research avataraxolotlorchestra-research/ai-research-skillsExpert guidance for fine-tuning LLMs with Axolotl - YAML configs, 100+ models, LoRA/QLoRA, DPO/KTO/ORPO/GRPO, multimodal support1Kskills.sh installs
2orchestra-research avatarhqq-quantizationorchestra-research/ai-research-skillsHalf-Quadratic Quantization for LLMs without calibration data. Use when quantizing models to 4/3/2-bit precision without needing calibration datasets, for fast 1Kskills.sh installs
3orchestra-research avatarhuggingface-tokenizersorchestra-research/ai-research-skillsFast tokenizers optimized for research and production. Rust-based implementation tokenizes 1GB in <20 seconds. Supports BPE, WordPiece, and Unigram algorithms. 1Kskills.sh installs
4orchestra-research avatarlong-contextorchestra-research/ai-research-skillsExtend context windows of transformer models using RoPE, YaRN, ALiBi, and position interpolation techniques. Use when processing long documents (32k-128k+ token1Kskills.sh installs
5orchestra-research avatarnanogptorchestra-research/ai-research-skillsEducational GPT implementation in ~300 lines. Reproduces GPT-2 (124M) on OpenWebText. Clean, hackable code for learning transformers. By Andrej Karpathy. Perfec1Kskills.sh installs
6orchestra-research avatarpytorch-fsdp2orchestra-research/ai-research-skillsAdds PyTorch FSDP2 (fully_shard) to training scripts with correct init, sharding, mixed precision/offload config, and distributed checkpointing. Use when models1Kskills.sh installs