npx skills add ...
npx skills add firecrawl/ai-research-skills --skill training-llms-megatron
Trains large language models (2B-462B parameters) using NVIDIA Megatron-Core with advanced parallelism strategies. Use when training models >1B parameters, need maximum GPU efficiency (47% MFU on H100), or require tensor/pipeline/sequence/context/expert parallelism. Production-ready framework used for Nemotron, LLaMA, DeepSeek.
npx skills add firecrawl/ai-research-skills --skill training-llms-megatron
Megatron-Core trains LLMs from 2B to 462B parameters with up to 47% Model FLOP Utilization on H100 GPUs through advanced parallelism strategies.
Installation:
Simple distributed training:
Copy this checklist:
Step 1: Choose parallelism configuration
Model size determines parallelism strategy:
| Model Size | GPUs | Tensor Parallel | Pipeline Parallel | Data Parallel | Context Parallel |
|---|---|---|---|---|---|
| 7B | 8 | 1 | 1 | 8 | 1 |
| 13B | 8 | 2 | 1 | 4 | 1 |
| 70B | 64 | 4 | 4 | 4 | 1 |
| 405B | 128 | 8 | 8 | 2 | 2 |
Step 2: Configure training hyperparameters
Step 3: Launch distributed training
Step 4: Monitor performance metrics
Key metrics to track:
For sparse MoE models like Mixtral.
Step 1: Configure expert parallelism
Step 2: Set MoE hyperparameters
Step 3: Launch training with EP
Expert parallelism distributes different experts across GPUs, reducing memory while maintaining capacity.
Achieve 47% MFU on H100.
Step 1: Enable optimizations
Step 2: Use FP8 precision (H100 only)
Result: 1.5-2x speedup on H100 vs BF16.
Step 3: Optimize micro-batch size
Find largest micro-batch that fits in memory:
Typical values:
Step 4: Tune parallelism degrees
Rules of thumb:
Example 405B on 128 H100s:
Use Megatron-Core when:
Use alternatives instead:
Issue: Low GPU utilization (<30% MFU)
Causes:
Fixes:
Issue: Out of memory
Reduce memory with:
Or use CPU/NVMe offloading:
Issue: Training slower than expected
Check:
Issue: Diverging loss
Stabilize training:
Parallelism strategies: See references/parallelism-guide.md for detailed comparison of TP/PP/DP/CP/EP with performance analysis and when to use each.
Performance benchmarks: See references/benchmarks.md for MFU numbers across different model sizes and GPU configurations.
Production configurations: See references/production-examples.md for real-world setups from LLaMA 3 405B, Nemotron-4 340B, and DeepSeek-V3 671B.
Training recipes: See references/training-recipes.md for complete hyperparameter configurations for GPT/LLaMA/Mixtral architectures.