pytorch-lightning
PyTorch Lightning eliminates boilerplate by structuring PyTorch models into LightningModules with built-in support for multi-device training, callbacks, and experiment tracking. Configure Trainers for distributed strategies like DDP and FSDP, organize data pipelines with LightningDataModules, and integrate logging via TensorBoard, Weights & Biases, or MLflow.
PyTorch Lightning organizes PyTorch code into LightningModules to streamline neural network training across multiple GPUs/TPUs.
AI-generated summary based on this skill's SKILL.md
Install
K-Dense-AI/scientific-agent-skills/pytorch-lightning · repository language: Python
git clone https://github.com/K-Dense-AI/scientific-agent-skills
cp -r scientific-agent-skills/skills/pytorch-lightning ~/.claude/skills/pytorch-lightningnpx skillfed install K-Dense-AI/scientific-agent-skills/pytorch-lightningFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How to use lightning module for neural networks?
PyTorch Lightning's LightningModule wraps your PyTorch model to eliminate boilerplate. Subclass LightningModule, define your model in __init__, implement training_step, validation_step, and test_step methods, then pass it to a Trainer. Lightning handles device placement, distributed training, and logging automatically while maintaining full model flexibility.
What is multi-gpu training with pytorch lightning?
PyTorch Lightning enables multi-GPU training by configuring the Trainer with distributed strategies like DDP (DistributedDataParallel) or FSDP (Fully Sharded Data Parallel). Specify devices='auto' or devices=[0,1,2] and strategy='ddp' or 'fsdp' in Trainer initialization. Lightning handles synchronization, gradient aggregation, and device communication across GPUs and TPUs.
How does pytorch lightning organize pytorch code?
PyTorch Lightning organizes code through LightningModules (model logic), LightningDataModules (data pipelines), and Trainers (training loops). This separation decouples research code from engineering concerns. Your model focuses on forward passes and step definitions; data handling stays in DataModules; and Trainer manages device placement, checkpointing, callbacks, and distributed strategies.
What are lightning callbacks and logging options?
PyTorch Lightning callbacks automate training workflows like early stopping, checkpointing, and learning rate scheduling. Built-in callbacks include EarlyStopping and ModelCheckpoint. For logging, Lightning integrates TensorBoard, Weights & Biases, MLflow, and Neptune. Configure logging via self.log() in your LightningModule and attach callbacks to Trainer for experiment tracking and reproducibility.
How to set up a lightning datamodule?
PyTorch Lightning's LightningDataModule standardizes data pipeline organization. Subclass LightningDataModule and implement setup(), train_dataloader(), val_dataloader(), and test_dataloader() methods. This encapsulates data loading, preprocessing, and splitting. Pass your DataModule to Trainer.fit(), which automatically handles batching, shuffling, and distributed data sampling across devices.
What distributed training strategies does pytorch lightning support?
PyTorch Lightning supports DDP (DistributedDataParallel), FSDP (Fully Sharded Data Parallel), DeepSpeed, and single-device training. It also supports TPU training on Google Cloud. Configure via Trainer(strategy='ddp', devices='auto') or specify explicit device counts. Lightning abstracts strategy complexity, allowing seamless scaling from single GPU to multi-node clusters without code changes.
SKILL.md
rendered from the published skill — quoted content, verbatim
PyTorch Lightning
Overview
PyTorch Lightning is a deep learning framework that organizes PyTorch code to eliminate boilerplate while maintaining full flexibility. Automate training workflows, multi-device orchestration, and implement best practices for neural network training and scaling across multiple GPUs/TPUs.
Current upstream: lightning 2.6.4 (PyPI, May 2026). Docs: lightning.ai/docs/pytorch/stable. Use import lightning as L (the pytorch-lightning
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 11 files
skills/pytorch-lightning/SKILL.md
skills/pytorch-lightning/references/best_practices.md
skills/pytorch-lightning/references/callbacks.md
skills/pytorch-lightning/references/data_module.md
skills/pytorch-lightning/references/distributed_training.md
skills/pytorch-lightning/references/lightning_module.md
skills/pytorch-lightning/references/logging.md
skills/pytorch-lightning/references/trainer.md
skills/pytorch-lightning/scripts/quick_trainer_setup.py
skills/pytorch-lightning/scripts/template_datamodule.py
skills/pytorch-lightning/scripts/template_lightning_module.py