[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6GEBXFCWZFPP5Q12DYKK1AP":3,"skill-same:01M6GEBXFCWZFPP5Q12DYKK1AP":82},{"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":60,"commitSha":61,"skillDirectory":62,"forksCount":63,"repositoryHtmlUrl":64,"repositoryHomepageUrl":6,"ownerHtmlUrl":65,"ownerBlogUrl":6,"ownerDescription":66,"updatedAt":67,"install":68,"resources":81},"01M6GEBXFCWZFPP5Q12DYKK1AP","distributed-llm-pretraining-torchtitan",null,"Provides PyTorch-native distributed LLM pretraining using torchtitan with 4D parallelism (FSDP2, TP, PP, CP). Use when pretraining Llama 3.1, DeepSeek V3, or custom models at scale from 8 to 512+ GPUs with Float8, torch.compile, and distributed checkpointing.","zapabob\u002FSkills","zapabob","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F130830376?v=4","01M6DBMYZAGRTFQDSQYW3W764P","峯岸 亮","01M6DBMZ3GKDSJ01NZ9XTZD7JD",2,"MIT","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Farchive\u002Fskill-md-reviewed\u002Fsha256\u002Fc6\u002Fc64d41c93a9cfb82f495cee97437fcb7ff7140c52264ebf6859281725c4f12f0\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"distributed","Pretraining","torchtitan","distributed llm pretraining torchtitan","parallel","pp","native","FSDP2","Model Architecture","use","context","macos","model","pipeline","Distributed Training","compile","training","pytorch","architecture","linux","2026-11-10 10:12:30",false,"---\r\nname: distributed-llm-pretraining-torchtitan\r\ndescription: Provides PyTorch-native distributed LLM pretraining using torchtitan with 4D parallelism (FSDP2, TP, PP, CP). Use when pretraining Llama 3.1, DeepSeek V3, or custom models at scale from 8 to 512+ GPUs with Float8, torch.compile, and distributed checkpointing.\r\nversion: 1.0.0\r\nauthor: Orchestra Research\r\nlicense: MIT\r\ndependencies: [torch>=2.6.0, torchtitan>=0.2.0, torchao>=0.5.0]\r\nplatforms: [linux, macos]\r\nmetadata:\r\n  hermes:\r\n    tags: [Model Architecture, Distributed Training, TorchTitan, FSDP2, Tensor Parallel, Pipeline Parallel, Context Parallel, Float8, Llama, Pretraining]\r\n\r\n---\r\n\r\n# TorchTitan - PyTorch Native Distributed LLM Pretraining\r\n\r\n## Quick start\r\n\r\nTorchTitan is PyTorch's official platform for large-scale LLM pretraining with composable 4D parallelism (FSDP2, TP, PP, CP), achieving 65%+ speedups over baselines on H100 GPUs.\r\n\r\n**Installation**:\r\n```bash\r\n# From PyPI (stable)\r\npip install torchtitan\r\n\r\n# From source (latest features, requires PyTorch nightly)\r\ngit clone https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\r\ncd torchtitan\r\npip install -r requirements.txt\r\n```\r\n\r\n**Download tokenizer**:\r\n```bash\r\n# Get HF token from https:\u002F\u002Fhuggingface.co\u002Fsettings\u002Ftokens\r\npython scripts\u002Fdownload_hf_assets.py --repo_id meta-llama\u002FLlama-3.1-8B --assets tokenizer --hf_token=...\r\n```\r\n\r\n**Start training on 8 GPUs**:\r\n```bash\r\nCONFIG_FILE=\".\u002Ftorchtitan\u002Fmodels\u002Fllama3\u002Ftrain_configs\u002Fllama3_8b.toml\" .\u002Frun_train.sh\r\n```\r\n\r\n## Common workflows\r\n\r\n### Workflow 1: Pretrain Llama 3.1 8B on single node\r\n\r\nCopy this checklist:\r\n\r\n```\r\nSingle Node Pretraining:\r\n- [ ] Step 1: Download tokenizer\r\n- [ ] Step 2: Configure training\r\n- [ ] Step 3: Launch training\r\n- [ ] Step 4: Monitor and checkpoint\r\n```\r\n\r\n**Step 1: Download tokenizer**\r\n\r\n```bash\r\npython scripts\u002Fdownload_hf_assets.py \\\r\n  --repo_id meta-llama\u002FLlama-3.1-8B \\\r\n  --assets tokenizer \\\r\n  --hf_token=YOUR_HF_TOKEN\r\n```\r\n\r\n**Step 2: Configure training**\r\n\r\nEdit or create a TOML config file:\r\n\r\n```toml\r\n# llama3_8b_custom.toml\r\n[job]\r\ndump_folder = \".\u002Foutputs\"\r\ndescription = \"Llama 3.1 8B training\"\r\n\r\n[model]\r\nname = \"llama3\"\r\nflavor = \"8B\"\r\nhf_assets_path = \".\u002Fassets\u002Fhf\u002FLlama-3.1-8B\"\r\n\r\n[optimizer]\r\nname = \"AdamW\"\r\nlr = 3e-4\r\n\r\n[lr_scheduler]\r\nwarmup_steps = 200\r\n\r\n[training]\r\nlocal_batch_size = 2\r\nseq_len = 8192\r\nmax_norm = 1.0\r\nsteps = 1000\r\ndataset = \"c4\"\r\n\r\n[parallelism]\r\ndata_parallel_shard_degree = -1  # Use all GPUs for FSDP\r\n\r\n[activation_checkpoint]\r\nmode = \"selective\"\r\nselective_ac_option = \"op\"\r\n\r\n[checkpoint]\r\nenable = true\r\nfolder = \"checkpoint\"\r\ninterval = 500\r\n```\r\n\r\n**Step 3: Launch training**\r\n\r\n```bash\r\n# 8 GPUs on single node\r\nCONFIG_FILE=\".\u002Fllama3_8b_custom.toml\" .\u002Frun_train.sh\r\n\r\n# Or explicitly with torchrun\r\ntorchrun --nproc_per_node=8 \\\r\n  -m torchtitan.train \\\r\n  --job.config_file .\u002Fllama3_8b_custom.toml\r\n```\r\n\r\n**Step 4: Monitor and checkpoint**\r\n\r\nTensorBoard logs are saved to `.\u002Foutputs\u002Ftb\u002F`:\r\n```bash\r\ntensorboard --logdir .\u002Foutputs\u002Ftb\r\n```\r\n\r\n### Workflow 2: Multi-node training with SLURM\r\n\r\n```\r\nMulti-Node Training:\r\n- [ ] Step 1: Configure parallelism for scale\r\n- [ ] Step 2: Set up SLURM script\r\n- [ ] Step 3: Submit job\r\n- [ ] Step 4: Resume from checkpoint\r\n```\r\n\r\n**Step 1: Configure parallelism for scale**\r\n\r\nFor 70B model on 256 GPUs (32 nodes):\r\n```toml\r\n[parallelism]\r\ndata_parallel_shard_degree = 32  # FSDP across 32 ranks\r\ntensor_parallel_degree = 8        # TP within node\r\npipeline_parallel_degree = 1      # No PP for 70B\r\ncontext_parallel_degree = 1       # Increase for long sequences\r\n```\r\n\r\n**Step 2: Set up SLURM script**\r\n\r\n```bash\r\n#!\u002Fbin\u002Fbash\r\n#SBATCH --job-name=llama70b\r\n#SBATCH --nodes=32\r\n#SBATCH --ntasks-per-node=8\r\n#SBATCH --gpus-per-node=8\r\n\r\nsrun torchrun \\\r\n  --nnodes=32 \\\r\n  --nproc_per_node=8 \\\r\n  --rdzv_backend=c10d \\\r\n  --rdzv_endpoint=$MASTER_ADDR:$MASTER_PORT \\\r\n  -m torchtitan.train \\\r\n  --job.config_file .\u002Fllama3_70b.toml\r\n```\r\n\r\n**Step 3: Submit job**\r\n\r\n```bash\r\nsbatch multinode_trainer.slurm\r\n```\r\n\r\n**Step 4: Resume from checkpoint**\r\n\r\nTraining auto-resumes if checkpoint exists in configured folder.\r\n\r\n### Workflow 3: Enable Float8 training for H100s\r\n\r\nFloat8 provides 30-50% speedup on H100 GPUs.\r\n\r\n```\r\nFloat8 Training:\r\n- [ ] Step 1: Install torchao\r\n- [ ] Step 2: Configure Float8\r\n- [ ] Step 3: Launch with compile\r\n```\r\n\r\n**Step 1: Install torchao**\r\n\r\n```bash\r\nUSE_CPP=0 pip install git+https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fao.git\r\n```\r\n\r\n**Step 2: Configure Float8**\r\n\r\nAdd to your TOML config:\r\n```toml\r\n[model]\r\nconverters = [\"quantize.linear.float8\"]\r\n\r\n[quantize.linear.float8]\r\nenable_fsdp_float8_all_gather = true\r\nprecompute_float8_dynamic_scale_for_fsdp = true\r\nfilter_fqns = [\"output\"]  # Exclude output layer\r\n\r\n[compile]\r\nenable = true\r\ncomponents = [\"model\", \"loss\"]\r\n```\r\n\r\n**Step 3: Launch with compile**\r\n\r\n```bash\r\nCONFIG_FILE=\".\u002Fllama3_8b.toml\" .\u002Frun_train.sh \\\r\n  --model.converters=\"quantize.linear.float8\" \\\r\n  --quantize.linear.float8.enable_fsdp_float8_all_gather \\\r\n  --compile.enable\r\n```\r\n\r\n### Workflow 4: 4D parallelism for 405B models\r\n\r\n```\r\n4D Parallelism (FSDP + TP + PP + CP):\r\n- [ ] Step 1: Create seed checkpoint\r\n- [ ] Step 2: Configure 4D parallelism\r\n- [ ] Step 3: Launch on 512 GPUs\r\n```\r\n\r\n**Step 1: Create seed checkpoint**\r\n\r\nRequired for consistent initialization across PP stages:\r\n```bash\r\nNGPU=1 CONFIG_FILE=.\u002Fllama3_405b.toml .\u002Frun_train.sh \\\r\n  --checkpoint.enable \\\r\n  --checkpoint.create_seed_checkpoint \\\r\n  --parallelism.data_parallel_shard_degree 1 \\\r\n  --parallelism.tensor_parallel_degree 1 \\\r\n  --parallelism.pipeline_parallel_degree 1\r\n```\r\n\r\n**Step 2: Configure 4D parallelism**\r\n\r\n```toml\r\n[parallelism]\r\ndata_parallel_shard_degree = 8   # FSDP\r\ntensor_parallel_degree = 8       # TP within node\r\npipeline_parallel_degree = 8     # PP across nodes\r\ncontext_parallel_degree = 1      # CP for long sequences\r\n\r\n[training]\r\nlocal_batch_size = 32\r\nseq_len = 8192\r\n```\r\n\r\n**Step 3: Launch on 512 GPUs**\r\n\r\n```bash\r\n# 64 nodes x 8 GPUs = 512 GPUs\r\nsrun torchrun --nnodes=64 --nproc_per_node=8 \\\r\n  -m torchtitan.train \\\r\n  --job.config_file .\u002Fllama3_405b.toml\r\n```\r\n\r\n## When to use vs alternatives\r\n\r\n**Use TorchTitan when:**\r\n- Pretraining LLMs from scratch (8B to 405B+)\r\n- Need PyTorch-native solution without third-party dependencies\r\n- Require composable 4D parallelism (FSDP2, TP, PP, CP)\r\n- Training on H100s with Float8 support\r\n- Want interoperable checkpoints with torchtune\u002FHuggingFace\r\n\r\n**Use alternatives instead:**\r\n- **Megatron-LM**: Maximum performance for NVIDIA-only deployments\r\n- **DeepSpeed**: Broader ZeRO optimization ecosystem, inference support\r\n- **Axolotl\u002FTRL**: Fine-tuning rather than pretraining\r\n- **LitGPT**: Educational, smaller-scale training\r\n\r\n## Common issues\r\n\r\n**Issue: Out of memory on large models**\r\n\r\nEnable activation checkpointing and reduce batch size:\r\n```toml\r\n[activation_checkpoint]\r\nmode = \"full\"  # Instead of \"selective\"\r\n\r\n[training]\r\nlocal_batch_size = 1\r\n```\r\n\r\nOr use gradient accumulation:\r\n```toml\r\n[training]\r\nlocal_batch_size = 1\r\nglobal_batch_size = 32  # Accumulates gradients\r\n```\r\n\r\n**Issue: TP causes high memory with async collectives**\r\n\r\nSet environment variable:\r\n```bash\r\nexport TORCH_NCCL_AVOID_RECORD_STREAMS=1\r\n```\r\n\r\n**Issue: Float8 training not faster**\r\n\r\nFloat8 only benefits large GEMMs. Filter small layers:\r\n```toml\r\n[quantize.linear.float8]\r\nfilter_fqns = [\"attention.wk\", \"attention.wv\", \"output\", \"auto_filter_small_kn\"]\r\n```\r\n\r\n**Issue: Checkpoint loading fails after parallelism change**\r\n\r\nUse DCP's resharding capability:\r\n```bash\r\n# Convert sharded checkpoint to single file\r\npython -m torch.distributed.checkpoint.format_utils \\\r\n  dcp_to_torch checkpoint\u002Fstep-1000 checkpoint.pt\r\n```\r\n\r\n**Issue: Pipeline parallelism initialization**\r\n\r\nCreate seed checkpoint first (see Workflow 4, Step 1).\r\n\r\n## Supported models\r\n\r\n| Model | Sizes | Status |\r\n|-------|-------|--------|\r\n| Llama 3.1 | 8B, 70B, 405B | Production |\r\n| Llama 4 | Various | Experimental |\r\n| DeepSeek V3 | 16B, 236B, 671B (MoE) | Experimental |\r\n| GPT-OSS | 20B, 120B (MoE) | Experimental |\r\n| Qwen 3 | Various | Experimental |\r\n| Flux | Diffusion | Experimental |\r\n\r\n## Performance benchmarks (H100)\r\n\r\n| Model | GPUs | Parallelism | TPS\u002FGPU | Techniques |\r\n|-------|------|-------------|---------|------------|\r\n| Llama 8B | 8 | FSDP | 5,762 | Baseline |\r\n| Llama 8B | 8 | FSDP+compile+FP8 | 8,532 | +48% |\r\n| Llama 70B | 256 | FSDP+TP+AsyncTP | 876 | 2D parallel |\r\n| Llama 405B | 512 | FSDP+TP+PP | 128 | 3D parallel |\r\n\r\n## Advanced topics\r\n\r\n**FSDP2 configuration**: See [references\u002Ffsdp.md](references\u002Ffsdp.md) for detailed FSDP2 vs FSDP1 comparison and ZeRO equivalents.\r\n\r\n**Float8 training**: See [references\u002Ffloat8.md](references\u002Ffloat8.md) for tensorwise vs rowwise scaling recipes.\r\n\r\n**Checkpointing**: See [references\u002Fcheckpoint.md](references\u002Fcheckpoint.md) for HuggingFace conversion and async checkpointing.\r\n\r\n**Adding custom models**: See [references\u002Fcustom-models.md](references\u002Fcustom-models.md) for TrainSpec protocol.\r\n\r\n## Resources\r\n\r\n- GitHub: https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\r\n- Paper: https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.06511\r\n- ICLR 2025: https:\u002F\u002Ficlr.cc\u002Fvirtual\u002F2025\u002Fposter\u002F29620\r\n- PyTorch Forum: https:\u002F\u002Fdiscuss.pytorch.org\u002Fc\u002Fdistributed\u002Ftorchtitan\u002F44\r\n","# TorchTitan - PyTorch Native Distributed LLM Pretraining\r\n\r\n## Quick start\r\n\r\nTorchTitan is PyTorch's official platform for large-scale LLM pretraining with composable 4D parallelism (FSDP2, TP, PP, CP), achieving 65%+ speedups over baselines on H100 GPUs.\r\n\r\n**Installation**:\r\n```bash\r\n# From PyPI (stable)\r\npip install torchtitan\r\n\r\n# From source (latest features, requires PyTorch nightly)\r\ngit clone https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\r\ncd torchtitan\r\npip install -r requirements.txt\r\n```\r\n\r\n**Download tokenizer**:\r\n```bash\r\n# Get HF token from https:\u002F\u002Fhuggingface.co\u002Fsettings\u002Ftokens\r\npython scripts\u002Fdownload_hf_assets.py --repo_id meta-llama\u002FLlama-3.1-8B --assets tokenizer --hf_token=...\r\n```\r\n\r\n**Start training on 8 GPUs**:\r\n```bash\r\nCONFIG_FILE=\".\u002Ftorchtitan\u002Fmodels\u002Fllama3\u002Ftrain_configs\u002Fllama3_8b.toml\" .\u002Frun_train.sh\r\n```\r\n\r\n## Common workflows\r\n\r\n### Workflow 1: Pretrain Llama 3.1 8B on single node\r\n\r\nCopy this checklist:\r\n\r\n```\r\nSingle Node Pretraining:\r\n- [ ] Step 1: Download tokenizer\r\n- [ ] Step 2: Configure training\r\n- [ ] Step 3: Launch training\r\n- [ ] Step 4: Monitor and checkpoint\r\n```\r\n\r\n**Step 1: Download tokenizer**\r\n\r\n```bash\r\npython scripts\u002Fdownload_hf_assets.py \\\r\n  --repo_id meta-llama\u002FLlama-3.1-8B \\\r\n  --assets tokenizer \\\r\n  --hf_token=YOUR_HF_TOKEN\r\n```\r\n\r\n**Step 2: Configure training**\r\n\r\nEdit or create a TOML config file:\r\n\r\n```toml\r\n# llama3_8b_custom.toml\r\n[job]\r\ndump_folder = \".\u002Foutputs\"\r\ndescription = \"Llama 3.1 8B training\"\r\n\r\n[model]\r\nname = \"llama3\"\r\nflavor = \"8B\"\r\nhf_assets_path = \".\u002Fassets\u002Fhf\u002FLlama-3.1-8B\"\r\n\r\n[optimizer]\r\nname = \"AdamW\"\r\nlr = 3e-4\r\n\r\n[lr_scheduler]\r\nwarmup_steps = 200\r\n\r\n[training]\r\nlocal_batch_size = 2\r\nseq_len = 8192\r\nmax_norm = 1.0\r\nsteps = 1000\r\ndataset = \"c4\"\r\n\r\n[parallelism]\r\ndata_parallel_shard_degree = -1  # Use all GPUs for FSDP\r\n\r\n[activation_checkpoint]\r\nmode = \"selective\"\r\nselective_ac_option = \"op\"\r\n\r\n[checkpoint]\r\nenable = true\r\nfolder = \"checkpoint\"\r\ninterval = 500\r\n```\r\n\r\n**Step 3: Launch training**\r\n\r\n```bash\r\n# 8 GPUs on single node\r\nCONFIG_FILE=\".\u002Fllama3_8b_custom.toml\" .\u002Frun_train.sh\r\n\r\n# Or explicitly with torchrun\r\ntorchrun --nproc_per_node=8 \\\r\n  -m torchtitan.train \\\r\n  --job.config_file .\u002Fllama3_8b_custom.toml\r\n```\r\n\r\n**Step 4: Monitor and checkpoint**\r\n\r\nTensorBoard logs are saved to `.\u002Foutputs\u002Ftb\u002F`:\r\n```bash\r\ntensorboard --logdir .\u002Foutputs\u002Ftb\r\n```\r\n\r\n### Workflow 2: Multi-node training with SLURM\r\n\r\n```\r\nMulti-Node Training:\r\n- [ ] Step 1: Configure parallelism for scale\r\n- [ ] Step 2: Set up SLURM script\r\n- [ ] Step 3: Submit job\r\n- [ ] Step 4: Resume from checkpoint\r\n```\r\n\r\n**Step 1: Configure parallelism for scale**\r\n\r\nFor 70B model on 256 GPUs (32 nodes):\r\n```toml\r\n[parallelism]\r\ndata_parallel_shard_degree = 32  # FSDP across 32 ranks\r\ntensor_parallel_degree = 8        # TP within node\r\npipeline_parallel_degree = 1      # No PP for 70B\r\ncontext_parallel_degree = 1       # Increase for long sequences\r\n```\r\n\r\n**Step 2: Set up SLURM script**\r\n\r\n```bash\r\n#!\u002Fbin\u002Fbash\r\n#SBATCH --job-name=llama70b\r\n#SBATCH --nodes=32\r\n#SBATCH --ntasks-per-node=8\r\n#SBATCH --gpus-per-node=8\r\n\r\nsrun torchrun \\\r\n  --nnodes=32 \\\r\n  --nproc_per_node=8 \\\r\n  --rdzv_backend=c10d \\\r\n  --rdzv_endpoint=$MASTER_ADDR:$MASTER_PORT \\\r\n  -m torchtitan.train \\\r\n  --job.config_file .\u002Fllama3_70b.toml\r\n```\r\n\r\n**Step 3: Submit job**\r\n\r\n```bash\r\nsbatch multinode_trainer.slurm\r\n```\r\n\r\n**Step 4: Resume from checkpoint**\r\n\r\nTraining auto-resumes if checkpoint exists in configured folder.\r\n\r\n### Workflow 3: Enable Float8 training for H100s\r\n\r\nFloat8 provides 30-50% speedup on H100 GPUs.\r\n\r\n```\r\nFloat8 Training:\r\n- [ ] Step 1: Install torchao\r\n- [ ] Step 2: Configure Float8\r\n- [ ] Step 3: Launch with compile\r\n```\r\n\r\n**Step 1: Install torchao**\r\n\r\n```bash\r\nUSE_CPP=0 pip install git+https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fao.git\r\n```\r\n\r\n**Step 2: Configure Float8**\r\n\r\nAdd to your TOML config:\r\n```toml\r\n[model]\r\nconverters = [\"quantize.linear.float8\"]\r\n\r\n[quantize.linear.float8]\r\nenable_fsdp_float8_all_gather = true\r\nprecompute_float8_dynamic_scale_for_fsdp = true\r\nfilter_fqns = [\"output\"]  # Exclude output layer\r\n\r\n[compile]\r\nenable = true\r\ncomponents = [\"model\", \"loss\"]\r\n```\r\n\r\n**Step 3: Launch with compile**\r\n\r\n```bash\r\nCONFIG_FILE=\".\u002Fllama3_8b.toml\" .\u002Frun_train.sh \\\r\n  --model.converters=\"quantize.linear.float8\" \\\r\n  --quantize.linear.float8.enable_fsdp_float8_all_gather \\\r\n  --compile.enable\r\n```\r\n\r\n### Workflow 4: 4D parallelism for 405B models\r\n\r\n```\r\n4D Parallelism (FSDP + TP + PP + CP):\r\n- [ ] Step 1: Create seed checkpoint\r\n- [ ] Step 2: Configure 4D parallelism\r\n- [ ] Step 3: Launch on 512 GPUs\r\n```\r\n\r\n**Step 1: Create seed checkpoint**\r\n\r\nRequired for consistent initialization across PP stages:\r\n```bash\r\nNGPU=1 CONFIG_FILE=.\u002Fllama3_405b.toml .\u002Frun_train.sh \\\r\n  --checkpoint.enable \\\r\n  --checkpoint.create_seed_checkpoint \\\r\n  --parallelism.data_parallel_shard_degree 1 \\\r\n  --parallelism.tensor_parallel_degree 1 \\\r\n  --parallelism.pipeline_parallel_degree 1\r\n```\r\n\r\n**Step 2: Configure 4D parallelism**\r\n\r\n```toml\r\n[parallelism]\r\ndata_parallel_shard_degree = 8   # FSDP\r\ntensor_parallel_degree = 8       # TP within node\r\npipeline_parallel_degree = 8     # PP across nodes\r\ncontext_parallel_degree = 1      # CP for long sequences\r\n\r\n[training]\r\nlocal_batch_size = 32\r\nseq_len = 8192\r\n```\r\n\r\n**Step 3: Launch on 512 GPUs**\r\n\r\n```bash\r\n# 64 nodes x 8 GPUs = 512 GPUs\r\nsrun torchrun --nnodes=64 --nproc_per_node=8 \\\r\n  -m torchtitan.train \\\r\n  --job.config_file .\u002Fllama3_405b.toml\r\n```\r\n\r\n## When to use vs alternatives\r\n\r\n**Use TorchTitan when:**\r\n- Pretraining LLMs from scratch (8B to 405B+)\r\n- Need PyTorch-native solution without third-party dependencies\r\n- Require composable 4D parallelism (FSDP2, TP, PP, CP)\r\n- Training on H100s with Float8 support\r\n- Want interoperable checkpoints with torchtune\u002FHuggingFace\r\n\r\n**Use alternatives instead:**\r\n- **Megatron-LM**: Maximum performance for NVIDIA-only deployments\r\n- **DeepSpeed**: Broader ZeRO optimization ecosystem, inference support\r\n- **Axolotl\u002FTRL**: Fine-tuning rather than pretraining\r\n- **LitGPT**: Educational, smaller-scale training\r\n\r\n## Common issues\r\n\r\n**Issue: Out of memory on large models**\r\n\r\nEnable activation checkpointing and reduce batch size:\r\n```toml\r\n[activation_checkpoint]\r\nmode = \"full\"  # Instead of \"selective\"\r\n\r\n[training]\r\nlocal_batch_size = 1\r\n```\r\n\r\nOr use gradient accumulation:\r\n```toml\r\n[training]\r\nlocal_batch_size = 1\r\nglobal_batch_size = 32  # Accumulates gradients\r\n```\r\n\r\n**Issue: TP causes high memory with async collectives**\r\n\r\nSet environment variable:\r\n```bash\r\nexport TORCH_NCCL_AVOID_RECORD_STREAMS=1\r\n```\r\n\r\n**Issue: Float8 training not faster**\r\n\r\nFloat8 only benefits large GEMMs. Filter small layers:\r\n```toml\r\n[quantize.linear.float8]\r\nfilter_fqns = [\"attention.wk\", \"attention.wv\", \"output\", \"auto_filter_small_kn\"]\r\n```\r\n\r\n**Issue: Checkpoint loading fails after parallelism change**\r\n\r\nUse DCP's resharding capability:\r\n```bash\r\n# Convert sharded checkpoint to single file\r\npython -m torch.distributed.checkpoint.format_utils \\\r\n  dcp_to_torch checkpoint\u002Fstep-1000 checkpoint.pt\r\n```\r\n\r\n**Issue: Pipeline parallelism initialization**\r\n\r\nCreate seed checkpoint first (see Workflow 4, Step 1).\r\n\r\n## Supported models\r\n\r\n| Model | Sizes | Status |\r\n|-------|-------|--------|\r\n| Llama 3.1 | 8B, 70B, 405B | Production |\r\n| Llama 4 | Various | Experimental |\r\n| DeepSeek V3 | 16B, 236B, 671B (MoE) | Experimental |\r\n| GPT-OSS | 20B, 120B (MoE) | Experimental |\r\n| Qwen 3 | Various | Experimental |\r\n| Flux | Diffusion | Experimental |\r\n\r\n## Performance benchmarks (H100)\r\n\r\n| Model | GPUs | Parallelism | TPS\u002FGPU | Techniques |\r\n|-------|------|-------------|---------|------------|\r\n| Llama 8B | 8 | FSDP | 5,762 | Baseline |\r\n| Llama 8B | 8 | FSDP+compile+FP8 | 8,532 | +48% |\r\n| Llama 70B | 256 | FSDP+TP+AsyncTP | 876 | 2D parallel |\r\n| Llama 405B | 512 | FSDP+TP+PP | 128 | 3D parallel |\r\n\r\n## Advanced topics\r\n\r\n**FSDP2 configuration**: See [references\u002Ffsdp.md](references\u002Ffsdp.md) for detailed FSDP2 vs FSDP1 comparison and ZeRO equivalents.\r\n\r\n**Float8 training**: See [references\u002Ffloat8.md](references\u002Ffloat8.md) for tensorwise vs rowwise scaling recipes.\r\n\r\n**Checkpointing**: See [references\u002Fcheckpoint.md](references\u002Fcheckpoint.md) for HuggingFace conversion and async checkpointing.\r\n\r\n**Adding custom models**: See [references\u002Fcustom-models.md](references\u002Fcustom-models.md) for TrainSpec protocol.\r\n\r\n## Resources\r\n\r\n- GitHub: https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\r\n- Paper: https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.06511\r\n- ICLR 2025: https:\u002F\u002Ficlr.cc\u002Fvirtual\u002F2025\u002Fposter\u002F29620\r\n- PyTorch Forum: https:\u002F\u002Fdiscuss.pytorch.org\u002Fc\u002Fdistributed\u002Ftorchtitan\u002F44\r\n",{"name":5,"author":44,"license":15,"version":45,"metadata":46,"platforms":55,"description":7,"dependencies":56},"Orchestra Research","1.0.0",{"hermes":47},{"tags":48},[27,33,49,26,50,51,52,53,54,20],"TorchTitan","Tensor Parallel","Pipeline Parallel","Context Parallel","Float8","Llama",[38,30],[57,58,59],"torch>=2.6.0","torchtitan>=0.2.0","torchao>=0.5.0","main","0d1434f89f4bc6b07e9d272accd8c1013768820f","archive\u002Fskill-md-reviewed\u002Fsha256\u002Fc6\u002Fc64d41c93a9cfb82f495cee97437fcb7ff7140c52264ebf6859281725c4f12f0",0,"https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills","https:\u002F\u002Fgithub.com\u002Fzapabob","The Open University of JAPAN　2019-now\r\n\r\nTokyo University of Science　2007-2010","2026-10-26 16:29:01",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add zapabob\u002FSkills --skill distributed-llm-pretraining-torchtitan",{"tool":74,"command":75},"bunx","bunx skills add zapabob\u002FSkills --skill distributed-llm-pretraining-torchtitan",{"tool":77,"command":78},"pnpm","pnpm dlx skills add zapabob\u002FSkills --skill distributed-llm-pretraining-torchtitan","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Farchive\u002Fskill-md-reviewed\u002Fsha256\u002Fc6\u002Fc64d41c93a9cfb82f495cee97437fcb7ff7140c52264ebf6859281725c4f12f0\u002FSKILL.md",true,[],[83,106,130,152,175,191],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":39},"01M6GJTE1GESGGF9K028Y7753E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Fregistry\u002Fskills\u002Fxurl\u002Fvariants\u002Fhermes-agent\u002FSKILL.md",[],[85,90,30,91,92,38,93,94,95,96,97,98,99,100,101,102,60,103,104,105],"openclaw","cli","github","windows","official","search","https","social-media","api","Media","hermes","hermes agent","twitter","social","via","post",{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":39},"01M6GJT8S1PXQ8WPXT1HSNBWH2","writing-plans","Write implementation plans: bite-sized tasks, paths, code.","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Fregistry\u002Fskills\u002Fwriting-plans\u002Fvariants\u002Fhermes-agent\u002FSKILL.md",[],[113,114,115,116,30,117,38,118,93,119,120,121,122,123,124,125,126,127,128,129],"writing","writing plans","plans","design","review","workflow","documentation","tasks","development","code","planning","code-review","subagent","write","superpowers","paths","test-driven-development",{"skillNo":131,"name":132,"nameZh":6,"description":133,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":39},"01M6GJST0H5X7WHBJ3BZK0DVKH","whisper","OpenAI's general-purpose speech recognition model. Supports 99 languages, transcription, translation to English, and language identification. Six model sizes from tiny (39M params) to large (1550M params). Use for speech-to-text, podcast transcription, or multilingual audio processing. Best for robust, multilingual ASR.","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Fregistry\u002Fskills\u002Fwhisper\u002Fvariants\u002Fhermes-agent-optional\u002FSKILL.md",[],[132,30,38,137,138,139,140,141,142,143,31,144,28,145,146,147,148,149,150,151],"openai","speech","multimodal","Transformers","ASR","Audio","text","speech recognition","general","multilingual","translation","english","identification","processing","Audio Processing",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":158,"publishedAt":39},"01M6GJSMRQ8EETZTYMG72P70EA","weights-and-biases","W&B: log ML experiments, sweeps, model registry, dashboards.","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Fregistry\u002Fskills\u002Fweights-and-biases\u002Fvariants\u002Fhermes-agent\u002FSKILL.md",[],[159,30,160,161,93,36,162,163,164,165,166,31,167,168,169,170,171,172,173,174],"weights and biases","tensorflow","experiments","visualization","registry","real-time","tuning","dashboards","experiment","log","time","Experiment Tracking","Model Registry","Hyperparameter Tuning","WandB","Real-Time Visualization",{"skillNo":176,"name":177,"nameZh":6,"description":178,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":179,"categories":180,"keywords":181,"publishedAt":39},"01M6GJS19KDPRY112JTR326S06","watchers","Poll RSS, JSON APIs, and GitHub with watermark dedup.","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Fregistry\u002Fskills\u002Fwatchers\u002Fvariants\u002Fhermes-agent-optional\u002FSKILL.md",[],[177,30,182,92,38,183,184,185,186,187,188,100,101,189,190],"terminal","automation","http","monitoring","cron","json","rss","devops","with",{"skillNo":192,"name":193,"nameZh":6,"description":194,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":195,"categories":196,"keywords":197,"publishedAt":39},"01M6GJRHJD2A6Q830SWF9W48BC","serving-llms-vllm","vLLM: high-throughput LLM serving, OpenAI API, quantization.","https:\u002F\u002Fgithub.com\u002Fzapabob\u002FSkills\u002Fblob\u002Fmain\u002Fregistry\u002Fskills\u002Fvllm\u002Fvariants\u002Fhermes-agent\u002FSKILL.md",[],[198,199,200,38,201,137,202,203,204,140,205,98,206,207,208,209,210,211,212,213],"llms","vLLM","serving llms vllm","research","openai api","tensor","Inference Serving","Production","llm serving","High Throughput","PagedAttention","Continuous Batching","Quantization","Tensor Parallelism","high-throughput","throughput"]