[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6EB2GC1PR8M22AX4YECRTNH":3,"skill-same:01M6EB2GC1PR8M22AX4YECRTNH":94},{"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":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":54,"commitSha":55,"skillDirectory":56,"forksCount":57,"repositoryHtmlUrl":58,"repositoryHomepageUrl":6,"ownerHtmlUrl":59,"ownerBlogUrl":6,"ownerDescription":60,"updatedAt":61,"install":62,"resources":75},"01M6EB2GC1PR8M22AX4YECRTNH","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.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"llms","training llms megatron","megatron","training","use","large language models","Model Parallelism","Megatron-Core","H100","distributed","deepseek","expert","ready","model","pipeline","NVIDIA","Large-Scale Training","Pipeline Parallelism","Distributed Training","core","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: luo-kai\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":44,"author":47,"license":15,"version":48,"description":7,"dependencies":49},[26,35,34,45,36,25,27,37,46],"Tensor Parallelism","Production","luo-kai","1.0.0",[50,51,52,53],"megatron-core","torch","apex","transformer-engine","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core",1,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill training-llms-megatron",{"tool":68,"command":69},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill training-llms-megatron",{"tool":71,"command":72},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill training-llms-megatron","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core\u002FSKILL.md",true,[76,82,86,90],{"path":77,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fbenchmarks.md","REFERENCE","参考文档",7363,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core\u002Freferences\u002Fbenchmarks.md",{"path":83,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fparallelism-guide.md",9591,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core\u002Freferences\u002Fparallelism-guide.md",{"path":87,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fproduction-examples.md",10903,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core\u002Freferences\u002Fproduction-examples.md",{"path":91,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Ftraining-recipes.md",11588,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F18-ai-agents-and-automation (by Luo Kai)\u002F16-other-agents\u002Fmegatron-core\u002Freferences\u002Ftraining-recipes.md",[95,121,138,168,200,237],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":39},"01M6F2SKTE208174C7S7JJCZC7","write-contracts","Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[102,103,104,105,106,107,108,109,32,110,111,112,113,114,115,116,117,118,119,120],"write","contracts","write contracts","storage","secure","create","generate","collection","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":39},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[128,129,130,131,132,133,134,135,136,137],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":149,"publishedAt":39},"01M6F2K968G1FZEZFPW2E6B222","solo-build","Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says \"build it\", \"start building\", \"execute plan\", \"implement tasks\", \"ship it\", or references a track ID. Do NOT use for planning (use \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[144],{"categoryNo":145,"categoryName":146,"taxonomyType":147,"taxonomyTypeDesc":148},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[150,151,152,153,154,155,156,157,129,158,159,160,102,161,162,163,164,165,166,167],"build","solo","solo build","MCP","workflow","commit","tasks","code","Bash","plan","read","auto","references","context7","query","scaffolding","ship it","project",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":180,"publishedAt":39},"01M6F2GKN39SGHSPWYB3662YC8","react-email","Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[174,177],{"categoryNo":175,"categoryName":176,"taxonomyType":147,"taxonomyTypeDesc":148},"01JBSEEDCAT000000000000005","邮件与沟通",{"categoryNo":178,"categoryName":179,"taxonomyType":147,"taxonomyTypeDesc":148},"01JBSEEDCAT000000000000009","前端开发",[181,182,183,184,185,186,187,188,189,190,191,192,193,23,194,195,196,197,198,199],"react","email","react email","github","editor","components","react components","component","welcome","https","notifications","password","node","html","resend","visual","emails","rendering","with",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":218,"publishedAt":39},"01M6F2FBVGVDFSG8SSFJGXA40C","APITester Agent-Driven API Testing","Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[206,209,212,213],{"categoryNo":207,"categoryName":208,"taxonomyType":147,"taxonomyTypeDesc":148},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":210,"categoryName":211,"taxonomyType":147,"taxonomyTypeDesc":148},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":145,"categoryName":146,"taxonomyType":147,"taxonomyTypeDesc":148},{"categoryNo":214,"categoryName":215,"taxonomyType":216,"taxonomyTypeDesc":217},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236],"testing","api","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","endpoints","document","get","define","tests","english","api-tester",{"skillNo":238,"name":239,"nameZh":6,"description":240,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":241,"categories":242,"keywords":243,"publishedAt":39},"01M6F273Y3NGAPVJZ608BC0G9G","hubspot-implementation-plan","Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[159,244,245,246,247,248,249,108,250,251,252,253,254,23,255,256,199,257],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]