kalarislabs/research-agent-skills/distributed-llm-pretraining-torchtitan
Claude Code and agent skill by kalarislabs/research-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Provides PyTorch-native distributed LLM pretraining using torchtitan with 4D parallelism (FSDP2, TP, PP, CP). Use when pretraining Llama 3.1, DeepSeek V3, or custom models at scale from 8 to 512+ GPUs with Float8, torch.compile, and distributed checkpointing.
Install
npx vskill@latest install kalarislabs/research-agent-skills/distributed-llm-pretraining-torchtitanSKILL.md
TorchTitan - PyTorch Native Distributed LLM Pretraining
Quick start
TorchTitan is PyTorch's official platform for large-scale LLM pretraining with composable 4D parallelism (FSDP2, TP, PP, CP), achieving 65%+ speedups over baselines on H100 GPUs.
Installation:
Download tokenizer:
Start training on 8 GPUs:
Common workflows
Workflow 1: Pretrain Llama 3.1 8B on single node
Copy this checklist:
Step 1: Download tokenizer
Step 2: Configure training
Edit or create a TOML config file:
Step 3: Launch training
Step 4: Monitor and checkpoint
TensorBoard logs are saved to ./outputs/tb/:
Workflow 2: Multi-node training with SLURM
Step 1: Configure parallelism for scale
For 70B model on 256 GPUs (32 nodes):
Step 2: Set up SLURM script
Step 3: Submit job
Step 4: Resume from checkpoint
Training auto-resumes if checkpoint exists in configured folder.
Workflow 3: Enable Float8 training for H100s
Float8 provides 30-50% speedup on H100 GPUs.
Step 1: Install torchao
Step 2: Configure Float8
Add to your TOML config:
Step 3: Launch with compile
Workflow 4: 4D parallelism for 405B models
Step 1: Create seed checkpoint
Required for consistent initialization across PP stages:
Step 2: Configure 4D parallelism
Step 3: Launch on 512 GPUs
When to use vs alternatives
Use TorchTitan when:
- Pretraining LLMs from scratch (8B to 405B+)
- Need PyTorch-native solution without third-party dependencies
- Require composable 4D parallelism (FSDP2, TP, PP, CP)
- Training on H100s with Float8 support
- Want interoperable checkpoints with torchtune/HuggingFace
Use alternatives instead:
- Megatron-LM: Maximum performance for NVIDIA-only deployments
- DeepSpeed: Broader ZeRO optimization ecosystem, inference support
- Axolotl/TRL: Fine-tuning rather than pretraining
- LitGPT: Educational, smaller-scale training
Common issues
Issue: Out of memory on large models
Enable activation checkpointing and reduce batch size:
Or use gradient accumulation:
Issue: TP causes high memory with async collectives
Set environment variable:
Issue: Float8 training not faster
Float8 only benefits large GEMMs. Filter small layers:
Issue: Checkpoint loading fails after parallelism change
Use DCP's resharding capability:
Issue: Pipeline parallelism initialization
Create seed checkpoint first (see Workflow 4, Step 1).
Supported models
| Model | Sizes | Status | |
|---|---|---|---|
| Llama 3.1 | 8B, 70B, 405B | Production | |
| Llama 4 | Various | Experimental | |
| DeepSeek V3 | 16B, 236B, 671B (MoE) | Experimental | |
| GPT-OSS | 20B, 120B (MoE) | Experimental | |
| Qwen 3 | Various | Experimental | |
| Flux | Diffusion | Experimental |
Performance benchmarks (H100)
| Model | GPUs | Parallelism | TPS/GPU | Techniques | |
|---|---|---|---|---|---|
| Llama 8B | 8 | FSDP | 5,762 | Baseline | |
| Llama 8B | 8 | FSDP+compile+FP8 | 8,532 | +48% | |
| Llama 70B | 256 | FSDP+TP+AsyncTP | 876 | 2D parallel | |
| Llama 405B | 512 | FSDP+TP+PP | 128 | 3D parallel |
Advanced topics
FSDP2 configuration: See references/fsdp.md for detailed FSDP2 vs FSDP1 comparison and ZeRO equivalents.
Float8 training: See references/float8.md for tensorwise vs rowwise scaling recipes.
Checkpointing: See references/checkpoint.md for HuggingFace conversion and async checkpointing.
Adding custom models: See references/custom-models.md for TrainSpec protocol.
Resources
- GitHub: https://github.com/pytorch/torchtitan
- Paper: https://arxiv.org/abs/2410.06511
- ICLR 2025: https://iclr.cc/virtual/2025/poster/29620
- PyTorch Forum: https://discuss.pytorch.org/c/distributed/torchtitan/44
Agent operating procedure
- Check the environment. Check GPU type, memory and driver/CUDA versions (
nvidia-smi), framework versions, and dataset location and size. - Pin down the inputs. Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.
- Run a small version first. Do a smoke run: tiny model or subset, few steps, and confirm loss decreases and checkpoints save.
- Execute the full task using the instructions and references above.
- Validate the result. Track metrics on held-out data, compare against a baseline, and record seeds, configs and hardware.
- Report. State what was run (versions, commands, parameters), what was checked, and what is still uncertain.
| If this happens | Do this | |
|---|---|---|
| CUDA out-of-memory | Reduce batch size, enable gradient accumulation/checkpointing or mixed precision, or shard the model. | |
| Loss is NaN or diverges | Lower the learning rate, check data for invalid values, and enable gradient clipping. | |
| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (help(), --help, official docs), adapt, and tell the user. Never invent an API. | |
| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |
Integrity rules
- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.
- Never claim training results without logs; estimate compute cost before launching large jobs.
- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.
- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.
Related skills
torchforge-rl-training: Provides guidance for PyTorch-native agentic RL using torchforge, Meta's library separating infra from algorithms.pytorch-fsdp2: Adds PyTorch FSDP2 (fully_shard) to training scripts with correct init, sharding, mixed precision/offload config, and distributed checkpoin…dask: Distributed computing for larger-than-RAM pandas/NumPy workflows.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/distributed-llm-pretraining-torchtitan/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 8
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kalarislabs/research-agent-skills/distributed-llm-pretraining-torchtitan)