[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FC226J61BT97GVFWX02SE0":3,"skill-same:01M6FC226J61BT97GVFWX02SE0":99},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":42,"linkOnly":43,"markdownContent":44,"markdownBody":45,"frontMatter":46,"refName":58,"commitSha":59,"skillDirectory":60,"forksCount":61,"repositoryHtmlUrl":62,"repositoryHomepageUrl":6,"ownerHtmlUrl":63,"ownerBlogUrl":64,"ownerDescription":65,"updatedAt":66,"install":67,"resources":80},"01M6FC226J61BT97GVFWX02SE0","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.","Dicklesworthstone\u002Fpi_agent_rust","Dicklesworthstone","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F35050222?v=4","01M6CG26AR942CSVMN1M5E3DSE","Jeff Emanuel","01M6CG26EPP71PSHW1VDS71121",1992,"MIT","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],"training","llms","training llms megatron","megatron","when","sequence","production-ready","advanced","Expert Parallelism","Model Parallelism","Megatron-Core","H100","apex","strategies","efficiency","expert","ready","context","model","pipeline","NVIDIA","Distributed Training","framework","2026-11-10 10:12:30",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":47,"author":52,"license":15,"version":53,"description":7,"dependencies":54},[29,48,39,49,50,28,30,40,51],"Large-Scale Training","Tensor Parallelism","Pipeline Parallelism","Production","Orchestra Research","1.0.0",[55,56,31,57],"megatron-core","torch","transformer-engine","main","90b50ed0778745a80fd5bfb13b1843d45b9e82f7","tests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core",233,"https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust","https:\u002F\u002Fgithub.com\u002FDicklesworthstone","https:\u002F\u002Fwww.jeffreyemanuel.com\u002F","Building in NY","2026-11-15 01:54:15",{"source":8,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add Dicklesworthstone\u002Fpi_agent_rust --skill training-llms-megatron",{"tool":73,"command":74},"bunx","bunx skills add Dicklesworthstone\u002Fpi_agent_rust --skill training-llms-megatron",{"tool":76,"command":77},"pnpm","pnpm dlx skills add Dicklesworthstone\u002Fpi_agent_rust --skill training-llms-megatron","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002FSKILL.md",true,[81,87,91,95],{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fbenchmarks.md","REFERENCE","参考文档",7363,"https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Fbenchmarks.md",{"path":88,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fparallelism-guide.md",9591,"https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Fparallelism-guide.md",{"path":92,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fproduction-examples.md",10903,"https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Fproduction-examples.md",{"path":96,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Ftraining-recipes.md",11588,"https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fai-research\u002Fdistributed-training-megatron-core\u002Freferences\u002Ftraining-recipes.md",[100,134,170,193,219,246],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":105,"sourceHtmlUrl":106,"categories":107,"keywords":113,"publishedAt":133},"01M6FCR7G5A005P364Z6ZWCJDP","theme-factory","Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors\u002Ffonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Ftheme-factory\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fcreative-design\u002Ftheme-factory\u002FSKILL.md",[108],{"categoryNo":109,"categoryName":110,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",[114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132],"theme factory","factory","theme","docs","toolkit","generate","artifacts","SET","fly","slides","landing","html","styling","artifact","pages","themes","with","you","fonts","2026-11-11 15:11:14",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":138,"sourceHtmlUrl":139,"categories":140,"keywords":144,"publishedAt":42},"01M6FEGPPK0ZTKCCM0R3E3KS33","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[141],{"categoryNo":142,"categoryName":143,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000009","前端开发",[145,146,120,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,125,163,164,165,166,167,168,169],"web artifacts builder","web","artifacts builder","builder","frontend","css","components","react","component","routing","state management","state","shadcn","file","ui","Tools","Tailwind","use","single-file","simple","ui components","multi","for","jsx","suite",{"skillNo":171,"name":172,"nameZh":6,"description":173,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":174,"sourceHtmlUrl":175,"categories":176,"keywords":181,"publishedAt":42},"01M6FEE9VTK1W4GY21AKREJXRG","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[177,180],{"categoryNo":178,"categoryName":179,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":142,"categoryName":143,"taxonomyType":111,"taxonomyTypeDesc":112},[182,183,184,149,185,186,146,187,118,188,159,189,190,191,192,130,167],"testing","webapp testing","webapp","screenshots","playwright","debugging","browser","logs","applications","behavior","local",{"skillNo":194,"name":195,"nameZh":6,"description":196,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":197,"sourceHtmlUrl":198,"categories":199,"keywords":200,"publishedAt":42},"01M6FE20F7ZTQBFWKF4MPJ2SBX","neuropixels-analysis","Neuropixels neural recording analysis. Load SpikeGLX\u002FOpenEphys data, preprocess, motion correction, Kilosort4 spike sorting, quality metrics, Allen\u002FIBL curation, AI-assisted visual analysis, for Neuropixels 1.0\u002F2.0 extracellular electrophysiology. Use when working with neural recordings, spike sorting, extracellular electrophysiology, or when the user mentions Neuropixels, SpikeGLX, Open Ephys, Kilosort, quality metrics, or unit curation.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fneuropixels-analysis\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fscientific\u002Fneuropixels-analysis\u002FSKILL.md",[],[201,202,203,204,205,206,207,208,162,209,210,211,212,213,214,215,130,216,217,218,167,23],"analysis","neuropixels analysis","spike","metrics","data","open","quality","user","recordings","Neural","motion","visual","quality metrics","unit","sorting","curation","recording","load",{"skillNo":220,"name":221,"nameZh":6,"description":222,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":223,"sourceHtmlUrl":224,"categories":225,"keywords":229,"publishedAt":42},"01M6FDP0PDK6F1GGX395C7625Z","skill-creator","Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fskill-creator\u002FSKILL.md",[226],{"categoryNo":227,"categoryName":228,"taxonomyType":111,"taxonomyTypeDesc":112},"01JBSEEDCAT000000000000023","Skill与智能体开发",[230,231,232,233,234,235,236,237,238,239,240,241,242,243,130,167,244,23,245],"skill creator","creator","workflows","create","update","capabilities","knowledge","tool","integrations","specialized","guide","new skill","existing skill","users","Existing","new",{"skillNo":247,"name":248,"nameZh":6,"description":249,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":250,"sourceHtmlUrl":251,"categories":252,"keywords":254,"publishedAt":42},"01M6FDM8Y7VK7NYG9SM7QPA3PW","notebooklm","Use this skill to query your Google NotebookLM notebooks directly from Claude Code for source-grounded, citation-backed answers from Gemini. Browser automation, library management, persistent auth. Drastically reduced hallucinations through document-only responses.","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FDicklesworthstone\u002Fpi_agent_rust\u002Fblob\u002Fmain\u002Ftests\u002Fext_conformance\u002Fartifacts\u002Ftemplates-davila7\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fnotebooklm\u002FSKILL.md",[253],{"categoryNo":227,"categoryName":228,"taxonomyType":111,"taxonomyTypeDesc":112},[248,255,256,257,258,259,260,188,261,262,162,263,264,265,266,167,267],"google","browser automation","gemini","automation","auth","code","library","management","only","document","query","Citation","source"]