[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79TMKEJBWVBXFV8TEJBWHNN":3,"skill-same:01M79TMKEJBWVBXFV8TEJBWHNN":78},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":13,"repositoryHtmlUrl":43,"repositoryHomepageUrl":6,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":45,"install":46,"resources":59},"01M79TMKEJBWVBXFV8TEJBWHNN","training-llms-megatron",null,"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\u002Fpipeline\u002Fsequence\u002Fcontext\u002Fexpert parallelism. Production-ready framework used for Nemotron, LLaMA, DeepSeek.","KrismithReddy12\u002Fclaude-code-templates","KrismithReddy12","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F182916557?v=4","01M79T8DNGJRHG48G3H3Q02MK8","01M79TA8ZWV2PP7R4ARWVYWZFE",0,"MIT","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: training-llms-megatron\ndescription: 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\u002Fpipeline\u002Fsequence\u002Fcontext\u002Fexpert parallelism. Production-ready framework used for Nemotron, LLaMA, DeepSeek.\nversion: 1.0.0\nauthor: Orchestra Research\nlicense: MIT\ntags: [Megatron-Core, Large-Scale Training, NVIDIA, Tensor Parallelism, Pipeline Parallelism, Model Parallelism, H100, Distributed Training, Production]\ndependencies: [megatron-core, torch, apex, transformer-engine]\n---\n\n# Megatron-Core - Large-Scale LLM Training\n\n## Quick start\n\nMegatron-Core trains LLMs from 2B to 462B parameters with up to 47% Model FLOP Utilization on H100 GPUs through advanced parallelism strategies.\n\n**Installation**:\n```bash\n# Docker (recommended)\ndocker run --gpus all -it --rm nvcr.io\u002Fnvidia\u002Fpytorch:25.04-py3\n\n# Or pip\npip install megatron-core\n```\n\n**Simple distributed training**:\n```bash\n# Train with 2 GPUs using data parallelism\ntorchrun --nproc_per_node=2 examples\u002Frun_simple_mcore_train_loop.py\n\n# Or LLaMA-3 8B training\n.\u002Fexamples\u002Fllama\u002Ftrain_llama3_8b_fp8.sh\n```\n\n## Common workflows\n\n### Workflow 1: Train LLaMA-style model with 3D parallelism\n\nCopy this checklist:\n\n```\nLLaMA Training Setup:\n- [ ] Step 1: Choose parallelism configuration\n- [ ] Step 2: Configure training hyperparameters\n- [ ] Step 3: Launch distributed training\n- [ ] Step 4: Monitor performance metrics\n```\n\n**Step 1: Choose parallelism configuration**\n\nModel size determines parallelism strategy:\n\n| Model Size | GPUs | Tensor Parallel | Pipeline Parallel | Data Parallel | Context Parallel |\n|------------|------|-----------------|-------------------|---------------|------------------|\n| 7B | 8 | 1 | 1 | 8 | 1 |\n| 13B | 8 | 2 | 1 | 4 | 1 |\n| 70B | 64 | 4 | 4 | 4 | 1 |\n| 405B | 128 | 8 | 8 | 2 | 2 |\n\n**Step 2: Configure training hyperparameters**\n\n```bash\n#!\u002Fbin\u002Fbash\n# train_llama_70b.sh\n\nGPUS_PER_NODE=8\nNNODES=8  # 64 GPUs total\nTP=4      # Tensor parallel\nPP=4      # Pipeline parallel\nCP=1      # Context parallel\n\n# LLaMA 70B configuration\nMODEL_SIZE=70  # Billion parameters\nHIDDEN_SIZE=8192\nNUM_LAYERS=80\nNUM_HEADS=64\nSEQ_LENGTH=4096\n\n# Training hyperparameters\nMICRO_BATCH=1\nGLOBAL_BATCH=1024\nLR=3e-4\n\ntorchrun \\\n  --nproc_per_node=$GPUS_PER_NODE \\\n  --nnodes=$NNODES \\\n  pretrain_gpt.py \\\n  --tensor-model-parallel-size $TP \\\n  --pipeline-model-parallel-size $PP \\\n  --context-parallel-size $CP \\\n  --sequence-parallel \\\n  --num-layers $NUM_LAYERS \\\n  --hidden-size $HIDDEN_SIZE \\\n  --num-attention-heads $NUM_HEADS \\\n  --seq-length $SEQ_LENGTH \\\n  --max-position-embeddings $SEQ_LENGTH \\\n  --micro-batch-size $MICRO_BATCH \\\n  --global-batch-size $GLOBAL_BATCH \\\n  --lr $LR \\\n  --train-iters 100000 \\\n  --lr-decay-style cosine \\\n  --lr-warmup-iters 2000 \\\n  --weight-decay 0.1 \\\n  --clip-grad 1.0 \\\n  --bf16 \\\n  --use-mcore-models \\\n  --transformer-impl transformer_engine \\\n  --data-path \u002Fpath\u002Fto\u002Fdata \\\n  --vocab-file \u002Fpath\u002Fto\u002Fvocab.json \\\n  --merge-file \u002Fpath\u002Fto\u002Fmerges.txt\n```\n\n**Step 3: Launch distributed training**\n\n```bash\n# Single node (8 GPUs)\nbash train_llama_70b.sh\n\n# Multi-node with SLURM\nsbatch --nodes=8 --gpus-per-node=8 train_llama_70b.sh\n```\n\n**Step 4: Monitor performance metrics**\n\nKey metrics to track:\n```\nModel FLOP Utilization (MFU): Target >40% on H100\nThroughput: Tokens\u002Fsec\u002FGPU\nMemory usage: \u003C80GB per GPU for 70B model\nLoss: Should decrease steadily\n```\n\n### Workflow 2: Configure Mixture of Experts (MoE) training\n\nFor sparse MoE models like Mixtral.\n\n```\nMoE Training:\n- [ ] Step 1: Configure expert parallelism\n- [ ] Step 2: Set MoE hyperparameters\n- [ ] Step 3: Launch training with EP\n```\n\n**Step 1: Configure expert parallelism**\n\n```bash\n# Mixtral 8x7B example\nTENSOR_PARALLEL=2\nPIPELINE_PARALLEL=1\nEXPERT_PARALLEL=4  # Split 8 experts across 4 GPUs\nDATA_PARALLEL=4\n\nTOTAL_GPUS=$((TENSOR_PARALLEL * PIPELINE_PARALLEL * EXPERT_PARALLEL * DATA_PARALLEL))\n# = 2 * 1 * 4 * 4 = 32 GPUs\n```\n\n**Step 2: Set MoE hyperparameters**\n\n```bash\ntorchrun \\\n  --nproc_per_node=8 \\\n  pretrain_gpt.py \\\n  --tensor-model-parallel-size 2 \\\n  --pipeline-model-parallel-size 1 \\\n  --expert-model-parallel-size 4 \\\n  --num-experts 8 \\\n  --moe-router-topk 2 \\\n  --moe-router-load-balancing-type aux_loss \\\n  --moe-aux-loss-coeff 0.01 \\\n  --hidden-size 4096 \\\n  --num-layers 32 \\\n  --num-attention-heads 32 \\\n  --seq-length 4096 \\\n  --max-position-embeddings 4096 \\\n  --bf16 \\\n  --use-mcore-models \\\n  --transformer-impl transformer_engine \\\n  --data-path \u002Fpath\u002Fto\u002Fdata \\\n  --vocab-file \u002Fpath\u002Fto\u002Fvocab.json \\\n  --merge-file \u002Fpath\u002Fto\u002Fmerges.txt\n```\n\n**Step 3: Launch training with EP**\n\nExpert parallelism distributes different experts across GPUs, reducing memory while maintaining capacity.\n\n```\nMemory without EP: 8 experts × 7B = 56GB per GPU\nMemory with EP=4: 2 experts × 7B = 14GB per GPU\nSavings: 75% memory reduction\n```\n\n### Workflow 3: Optimize for maximum throughput\n\nAchieve 47% MFU on H100.\n\n```\nPerformance Optimization:\n- [ ] Step 1: Enable Flash Attention\n- [ ] Step 2: Use FP8 precision (H100)\n- [ ] Step 3: Optimize micro-batch size\n- [ ] Step 4: Tune parallelism degrees\n```\n\n**Step 1: Enable optimizations**\n\n```bash\n--use-mcore-models  # Use Megatron Core models\n--transformer-impl transformer_engine  # Use Transformer Engine\n--sequence-parallel  # Reduce activation memory (use with TP)\n```\n\n**Step 2: Use FP8 precision (H100 only)**\n\n```bash\n--fp8-hybrid  # FP8 mixed precision training\n# Transformer Engine handles FP8 automatically\n```\n\nResult: 1.5-2x speedup on H100 vs BF16.\n\n**Step 3: Optimize micro-batch size**\n\nFind largest micro-batch that fits in memory:\n\n```bash\n# Start with 1, increase until OOM\nfor MBS in 1 2 4 8; do\n  echo \"Testing micro-batch-size=$MBS\"\n  torchrun ... --micro-batch-size $MBS\ndone\n```\n\nTypical values:\n- 7B model: 4-8\n- 70B model: 1-2\n- 405B model: 1\n\n**Step 4: Tune parallelism degrees**\n\nRules of thumb:\n```\nTensor Parallel: Use ≤8 (limited by NVLink within node)\nPipeline Parallel: Use for >70B models\nContext Parallel: Use for sequences >8K tokens\nData Parallel: Fill remaining GPUs\n```\n\nExample 405B on 128 H100s:\n```\nTP=8 (1 node)\nPP=8 (across nodes)\nCP=2 (long sequences)\nDP=1\nTotal = 8 × 8 × 2 × 1 = 128 GPUs\n```\n\n## When to use vs alternatives\n\n**Use Megatron-Core when:**\n- Training models >10B parameters\n- Need maximum efficiency (target >40% MFU)\n- Using NVIDIA GPUs (A100, H100)\n- Production training at scale\n- Want fine-grained parallelism control\n\n**Use alternatives instead:**\n- **PyTorch FSDP**: Models \u003C70B, simpler API, PyTorch native\n- **DeepSpeed**: Easier setup, good for \u003C100B models\n- **HuggingFace Accelerate**: Prototyping, simpler workflows\n- **LitGPT**: Educational, single-file implementations\n\n## Common issues\n\n**Issue: Low GPU utilization (\u003C30% MFU)**\n\nCauses:\n1. Micro-batch too small\n2. Too much parallelism overhead\n3. Not using Flash Attention\n\nFixes:\n```bash\n# Increase micro-batch\n--micro-batch-size 4  # Was 1\n\n# Enable optimizations\n--use-flash-attn\n--sequence-parallel\n\n# Reduce TP if >8\n--tensor-model-parallel-size 4  # Was 16\n```\n\n**Issue: Out of memory**\n\nReduce memory with:\n```bash\n--tensor-model-parallel-size 2  # Split model across GPUs\n--recompute-granularity full  # Gradient checkpointing\n--recompute-method block  # Checkpoint transformer blocks\n--recompute-num-layers 1  # Checkpoint every layer\n```\n\nOr use CPU\u002FNVMe offloading:\n```bash\n--cpu-optimizer  # Offload optimizer to CPU\n--cpu-optimizer-type ADAM  # CPU Adam variant\n```\n\n**Issue: Training slower than expected**\n\nCheck:\n1. **Network bottleneck**: Ensure InfiniBand\u002FNVLink enabled\n2. **Pipeline bubbles**: Use interleaved pipeline schedule\n   ```bash\n   --num-layers-per-virtual-pipeline-stage 2\n   ```\n3. **Data loading**: Use fast data loader\n   ```bash\n   --dataloader-type cyclic\n   ```\n\n**Issue: Diverging loss**\n\nStabilize training:\n```bash\n--lr-warmup-iters 2000  # Longer warmup\n--clip-grad 1.0  # Gradient clipping\n--init-method-std 0.006  # Smaller init\n--attention-dropout 0.0  # No dropout in attention\n--hidden-dropout 0.0  # No dropout in FFN\n```\n\n## Advanced topics\n\n**Parallelism strategies**: See [references\u002Fparallelism-guide.md](references\u002Fparallelism-guide.md) for detailed comparison of TP\u002FPP\u002FDP\u002FCP\u002FEP with performance analysis and when to use each.\n\n**Performance benchmarks**: See [references\u002Fbenchmarks.md](references\u002Fbenchmarks.md) for MFU numbers across different model sizes and GPU configurations.\n\n**Production configurations**: See [references\u002Fproduction-examples.md](references\u002Fproduction-examples.md) for real-world setups from LLaMA 3 405B, Nemotron-4 340B, and DeepSeek-V3 671B.\n\n**Training recipes**: See [references\u002Ftraining-recipes.md](references\u002Ftraining-recipes.md) for complete hyperparameter configurations for GPT\u002FLLaMA\u002FMixtral architectures.\n\n## Hardware requirements\n\n- **GPU**: NVIDIA Ampere+ (A100, H100, B200)\n  - Turing works but slower\n  - FP8 requires Hopper\u002FAda\u002FBlackwell\n- **Network**: InfiniBand or 400Gb+ Ethernet for multi-node\n- **Memory per GPU**:\n  - 7B model: 40GB+\n  - 70B model: 80GB (with TP=4)\n  - 405B model: 80GB (with TP=8, PP=8)\n- **Storage**: Fast NVMe for checkpoints (1TB+ for 70B+ models)\n\n## Resources\n\n- Docs: https:\u002F\u002Fdocs.nvidia.com\u002Fmegatron-core\u002F\n- GitHub: https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FMegatron-LM\n- Papers:\n  - \"Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism\" (2019)\n  - \"Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM\" (2021)\n- NeMo Framework: https:\u002F\u002Fdocs.nvidia.com\u002Fnemo-framework\u002F (built on Megatron-Core)\n\n\n","# Megatron-Core - Large-Scale LLM Training\n\n## Quick start\n\nMegatron-Core trains LLMs from 2B to 462B parameters with up to 47% Model FLOP Utilization on H100 GPUs through advanced parallelism strategies.\n\n**Installation**:\n```bash\n# Docker (recommended)\ndocker run --gpus all -it --rm nvcr.io\u002Fnvidia\u002Fpytorch:25.04-py3\n\n# Or pip\npip install megatron-core\n```\n\n**Simple distributed training**:\n```bash\n# Train with 2 GPUs using data parallelism\ntorchrun --nproc_per_node=2 examples\u002Frun_simple_mcore_train_loop.py\n\n# Or LLaMA-3 8B training\n.\u002Fexamples\u002Fllama\u002Ftrain_llama3_8b_fp8.sh\n```\n\n## Common workflows\n\n### Workflow 1: Train LLaMA-style model with 3D parallelism\n\nCopy this checklist:\n\n```\nLLaMA Training Setup:\n- [ ] Step 1: Choose parallelism configuration\n- [ ] Step 2: Configure training hyperparameters\n- [ ] Step 3: Launch distributed training\n- [ ] Step 4: Monitor performance metrics\n```\n\n**Step 1: Choose parallelism configuration**\n\nModel size determines parallelism strategy:\n\n| Model Size | GPUs | Tensor Parallel | Pipeline Parallel | Data Parallel | Context Parallel |\n|------------|------|-----------------|-------------------|---------------|------------------|\n| 7B | 8 | 1 | 1 | 8 | 1 |\n| 13B | 8 | 2 | 1 | 4 | 1 |\n| 70B | 64 | 4 | 4 | 4 | 1 |\n| 405B | 128 | 8 | 8 | 2 | 2 |\n\n**Step 2: Configure training hyperparameters**\n\n```bash\n#!\u002Fbin\u002Fbash\n# train_llama_70b.sh\n\nGPUS_PER_NODE=8\nNNODES=8  # 64 GPUs total\nTP=4      # Tensor parallel\nPP=4      # Pipeline parallel\nCP=1      # Context parallel\n\n# LLaMA 70B configuration\nMODEL_SIZE=70  # Billion parameters\nHIDDEN_SIZE=8192\nNUM_LAYERS=80\nNUM_HEADS=64\nSEQ_LENGTH=4096\n\n# Training hyperparameters\nMICRO_BATCH=1\nGLOBAL_BATCH=1024\nLR=3e-4\n\ntorchrun \\\n  --nproc_per_node=$GPUS_PER_NODE \\\n  --nnodes=$NNODES \\\n  pretrain_gpt.py \\\n  --tensor-model-parallel-size $TP \\\n  --pipeline-model-parallel-size $PP \\\n  --context-parallel-size $CP \\\n  --sequence-parallel \\\n  --num-layers $NUM_LAYERS \\\n  --hidden-size $HIDDEN_SIZE \\\n  --num-attention-heads $NUM_HEADS \\\n  --seq-length $SEQ_LENGTH \\\n  --max-position-embeddings $SEQ_LENGTH \\\n  --micro-batch-size $MICRO_BATCH \\\n  --global-batch-size $GLOBAL_BATCH \\\n  --lr $LR \\\n  --train-iters 100000 \\\n  --lr-decay-style cosine \\\n  --lr-warmup-iters 2000 \\\n  --weight-decay 0.1 \\\n  --clip-grad 1.0 \\\n  --bf16 \\\n  --use-mcore-models \\\n  --transformer-impl transformer_engine \\\n  --data-path \u002Fpath\u002Fto\u002Fdata \\\n  --vocab-file \u002Fpath\u002Fto\u002Fvocab.json \\\n  --merge-file \u002Fpath\u002Fto\u002Fmerges.txt\n```\n\n**Step 3: Launch distributed training**\n\n```bash\n# Single node (8 GPUs)\nbash train_llama_70b.sh\n\n# Multi-node with SLURM\nsbatch --nodes=8 --gpus-per-node=8 train_llama_70b.sh\n```\n\n**Step 4: Monitor performance metrics**\n\nKey metrics to track:\n```\nModel FLOP Utilization (MFU): Target >40% on H100\nThroughput: Tokens\u002Fsec\u002FGPU\nMemory usage: \u003C80GB per GPU for 70B model\nLoss: Should decrease steadily\n```\n\n### Workflow 2: Configure Mixture of Experts (MoE) training\n\nFor sparse MoE models like Mixtral.\n\n```\nMoE Training:\n- [ ] Step 1: Configure expert parallelism\n- [ ] Step 2: Set MoE hyperparameters\n- [ ] Step 3: Launch training with EP\n```\n\n**Step 1: Configure expert parallelism**\n\n```bash\n# Mixtral 8x7B example\nTENSOR_PARALLEL=2\nPIPELINE_PARALLEL=1\nEXPERT_PARALLEL=4  # Split 8 experts across 4 GPUs\nDATA_PARALLEL=4\n\nTOTAL_GPUS=$((TENSOR_PARALLEL * PIPELINE_PARALLEL * EXPERT_PARALLEL * DATA_PARALLEL))\n# = 2 * 1 * 4 * 4 = 32 GPUs\n```\n\n**Step 2: Set MoE hyperparameters**\n\n```bash\ntorchrun \\\n  --nproc_per_node=8 \\\n  pretrain_gpt.py \\\n  --tensor-model-parallel-size 2 \\\n  --pipeline-model-parallel-size 1 \\\n  --expert-model-parallel-size 4 \\\n  --num-experts 8 \\\n  --moe-router-topk 2 \\\n  --moe-router-load-balancing-type aux_loss \\\n  --moe-aux-loss-coeff 0.01 \\\n  --hidden-size 4096 \\\n  --num-layers 32 \\\n  --num-attention-heads 32 \\\n  --seq-length 4096 \\\n  --max-position-embeddings 4096 \\\n  --bf16 \\\n  --use-mcore-models \\\n  --transformer-impl transformer_engine \\\n  --data-path \u002Fpath\u002Fto\u002Fdata \\\n  --vocab-file \u002Fpath\u002Fto\u002Fvocab.json \\\n  --merge-file \u002Fpath\u002Fto\u002Fmerges.txt\n```\n\n**Step 3: Launch training with EP**\n\nExpert parallelism distributes different experts across GPUs, reducing memory while maintaining capacity.\n\n```\nMemory without EP: 8 experts × 7B = 56GB per GPU\nMemory with EP=4: 2 experts × 7B = 14GB per GPU\nSavings: 75% memory reduction\n```\n\n### Workflow 3: Optimize for maximum throughput\n\nAchieve 47% MFU on H100.\n\n```\nPerformance Optimization:\n- [ ] Step 1: Enable Flash Attention\n- [ ] Step 2: Use FP8 precision (H100)\n- [ ] Step 3: Optimize micro-batch size\n- [ ] Step 4: Tune parallelism degrees\n```\n\n**Step 1: Enable optimizations**\n\n```bash\n--use-mcore-models  # Use Megatron Core models\n--transformer-impl transformer_engine  # Use Transformer Engine\n--sequence-parallel  # Reduce activation memory (use with TP)\n```\n\n**Step 2: Use FP8 precision (H100 only)**\n\n```bash\n--fp8-hybrid  # FP8 mixed precision training\n# Transformer Engine handles FP8 automatically\n```\n\nResult: 1.5-2x speedup on H100 vs BF16.\n\n**Step 3: Optimize micro-batch size**\n\nFind largest micro-batch that fits in memory:\n\n```bash\n# Start with 1, increase until OOM\nfor MBS in 1 2 4 8; do\n  echo \"Testing micro-batch-size=$MBS\"\n  torchrun ... --micro-batch-size $MBS\ndone\n```\n\nTypical values:\n- 7B model: 4-8\n- 70B model: 1-2\n- 405B model: 1\n\n**Step 4: Tune parallelism degrees**\n\nRules of thumb:\n```\nTensor Parallel: Use ≤8 (limited by NVLink within node)\nPipeline Parallel: Use for >70B models\nContext Parallel: Use for sequences >8K tokens\nData Parallel: Fill remaining GPUs\n```\n\nExample 405B on 128 H100s:\n```\nTP=8 (1 node)\nPP=8 (across nodes)\nCP=2 (long sequences)\nDP=1\nTotal = 8 × 8 × 2 × 1 = 128 GPUs\n```\n\n## When to use vs alternatives\n\n**Use Megatron-Core when:**\n- Training models >10B parameters\n- Need maximum efficiency (target >40% MFU)\n- Using NVIDIA GPUs (A100, H100)\n- Production training at scale\n- Want fine-grained parallelism control\n\n**Use alternatives instead:**\n- **PyTorch FSDP**: Models \u003C70B, simpler API, PyTorch native\n- **DeepSpeed**: Easier setup, good for \u003C100B models\n- **HuggingFace Accelerate**: Prototyping, simpler workflows\n- **LitGPT**: Educational, single-file implementations\n\n## Common issues\n\n**Issue: Low GPU utilization (\u003C30% MFU)**\n\nCauses:\n1. Micro-batch too small\n2. Too much parallelism overhead\n3. Not using Flash Attention\n\nFixes:\n```bash\n# Increase micro-batch\n--micro-batch-size 4  # Was 1\n\n# Enable optimizations\n--use-flash-attn\n--sequence-parallel\n\n# Reduce TP if >8\n--tensor-model-parallel-size 4  # Was 16\n```\n\n**Issue: Out of memory**\n\nReduce memory with:\n```bash\n--tensor-model-parallel-size 2  # Split model across GPUs\n--recompute-granularity full  # Gradient checkpointing\n--recompute-method block  # Checkpoint transformer blocks\n--recompute-num-layers 1  # Checkpoint every layer\n```\n\nOr use CPU\u002FNVMe offloading:\n```bash\n--cpu-optimizer  # Offload optimizer to CPU\n--cpu-optimizer-type ADAM  # CPU Adam variant\n```\n\n**Issue: Training slower than expected**\n\nCheck:\n1. **Network bottleneck**: Ensure InfiniBand\u002FNVLink enabled\n2. **Pipeline bubbles**: Use interleaved pipeline schedule\n   ```bash\n   --num-layers-per-virtual-pipeline-stage 2\n   ```\n3. **Data loading**: Use fast data loader\n   ```bash\n   --dataloader-type cyclic\n   ```\n\n**Issue: Diverging loss**\n\nStabilize training:\n```bash\n--lr-warmup-iters 2000  # Longer warmup\n--clip-grad 1.0  # Gradient clipping\n--init-method-std 0.006  # Smaller init\n--attention-dropout 0.0  # No dropout in attention\n--hidden-dropout 0.0  # No dropout in FFN\n```\n\n## Advanced topics\n\n**Parallelism strategies**: See [references\u002Fparallelism-guide.md](references\u002Fparallelism-guide.md) for detailed comparison of TP\u002FPP\u002FDP\u002FCP\u002FEP with performance analysis and when to use each.\n\n**Performance benchmarks**: See [references\u002Fbenchmarks.md](references\u002Fbenchmarks.md) for MFU numbers across different model sizes and GPU configurations.\n\n**Production configurations**: See [references\u002Fproduction-examples.md](references\u002Fproduction-examples.md) for real-world setups from LLaMA 3 405B, Nemotron-4 340B, and DeepSeek-V3 671B.\n\n**Training recipes**: See [references\u002Ftraining-recipes.md](references\u002Ftraining-recipes.md) for complete hyperparameter configurations for GPT\u002FLLaMA\u002FMixtral architectures.\n\n## Hardware requirements\n\n- **GPU**: NVIDIA Ampere+ (A100, H100, B200)\n  - Turing works but slower\n  - FP8 requires Hopper\u002FAda\u002FBlackwell\n- **Network**: InfiniBand or 400Gb+ Ethernet for multi-node\n- **Memory per GPU**:\n  - 7B model: 40GB+\n  - 70B model: 80GB (with TP=4)\n  - 405B model: 80GB (with TP=8, PP=8)\n- **Storage**: Fast NVMe for checkpoints (1TB+ for 70B+ models)\n\n## Resources\n\n- Docs: https:\u002F\u002Fdocs.nvidia.com\u002Fmegatron-core\u002F\n- GitHub: https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FMegatron-LM\n- Papers:\n  - \"Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism\" (2019)\n  - \"Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM\" (2021)\n- NeMo Framework: https:\u002F\u002Fdocs.nvidia.com\u002Fnemo-framework\u002F (built on Megatron-Core)\n\n\n",{"name":5,"tags":23,"author":33,"license":14,"version":34,"description":7,"dependencies":35},[24,25,26,27,28,29,30,31,32],"Megatron-Core","Large-Scale Training","NVIDIA","Tensor Parallelism","Pipeline Parallelism","Model Parallelism","H100","Distributed Training","Production","Orchestra Research","1.0.0",[36,37,38,39],"megatron-core","torch","apex","transformer-engine","main","e3744adb7654df443f12927f3e001252b3a26b6d","cli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates","https:\u002F\u002Fgithub.com\u002FKrismithReddy12","2026-07-29 08:15:10",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add KrismithReddy12\u002Fclaude-code-templates --skill training-llms-megatron",{"tool":52,"command":53},"bunx","bunx skills add KrismithReddy12\u002Fclaude-code-templates --skill training-llms-megatron",{"tool":55,"command":56},"pnpm","pnpm dlx skills add KrismithReddy12\u002Fclaude-code-templates --skill training-llms-megatron","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002FSKILL.md",true,[60,66,70,74],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fbenchmarks.md","REFERENCE","参考文档",7363,"https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Fbenchmarks.md",{"path":67,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fparallelism-guide.md",9591,"https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Fparallelism-guide.md",{"path":71,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fproduction-examples.md",10903,"https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Fproduction-examples.md",{"path":75,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Ftraining-recipes.md",11588,"https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Ftraining-recipes.md",[79,86,95,102,109,116],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M79YMXJ07S2BQVB7JAM3657Q","zapier-make-patterns","No-code automation democratizes workflow building. Zapier and Make (formerly Integromat) let non-developers automate business processes without writing code. But no-code doesn't mean no-complexity - these platforms have their own patterns, pitfalls, and breaking points.  This skill covers when to use which platform, how to build reliable automations, and when to graduate to code-based solutions. Key insight: Zapier optimizes for simplicity and integrations (7000+ apps), Make optimizes for power","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Fzapier-make-patterns\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":90,"licenseFileUrl":91,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":18},"01M79YMVPMK3Y4JDP2KDJKQ2ZD","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":18},"01M79YMMQ4XXMPJHDQHY8FR7ME","workflow-automation","Workflow automation is the infrastructure that makes AI agents reliable. Without durable execution, a network hiccup during a 10-step payment flow means lost money and angry customers. With it, workflows resume exactly where they left off.  This skill covers the platforms (n8n, Temporal, Inngest) and patterns (sequential, parallel, orchestrator-worker) that turn brittle scripts into production-grade automation.  Key insight: The platforms make different tradeoffs. n8n optimizes for accessibility","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Fworkflow-automation\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":18},"01M79YMHQY3CP1XXMQ00TGQFAW","trigger-dev","Trigger.dev expert for background jobs, AI workflows, and reliable async execution with excellent developer experience and TypeScript-first design. Use when: trigger.dev, trigger dev, background task, ai background job, long running task.","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Ftrigger-dev\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":18},"01M79YME4Z3DRW0MT6BNYW1D7P","slack-automation","Automate Slack workspace operations including messaging, search, channel management, and reaction workflows through Composio's Slack toolkit.","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Fslack-automation\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":18},"01M79YMAX7NFYDFXFZH2TJS7SS","planning-with-files","Transforms workflow to use Manus-style persistent markdown files for planning, progress tracking, and knowledge storage. Use when starting complex tasks, multi-step projects, research tasks, or when the user mentions planning, organizing work, tracking progress, or wants structured output.","https:\u002F\u002Fgithub.com\u002FKrismithReddy12\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fworkflow-automation\u002Fplanning-with-files\u002FSKILL.md",[],[]]