torchtitan

Pretrain LLMs at scale using PyTorch 4D parallelism with FSDP2, TP, PP, and CP.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill torchtitan-vivekgoquest
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: torchtitan
Source: https://github.com/vivekgoquest/hermes-agent-stable/tree/main/optional-skills/mlops/torchtitan
Command: npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill torchtitan-vivekgoquest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch>=2.6.0, torchtitan>=0.2.0, torchao>=0.5.0, and includes references (resource) components.

What problem does it solve? Pretraining large language models from scratch requires coordinating complex distributed training across hundreds of GPUs, and misconfiguring parallelism strategies, checkpointing, or Float8 quantization wastes expensive compute time. ## Core Features & Use Cases - 4D Parallelism Configuration: Compose FSDP2, Tensor Parallel, Pipeline Parallel, and Context Parallel strategies for models from 8B to 405B+ parameters. - Float8 Training on H100s: Enable rowwise or tensorwise Float8 scaling via torchao for 30-50% throughput speedups with layer filtering. - Checkpoint Management: Use PyTorch Distributed Checkpoint for fault-tolerant saves, seed checkpoints for pipeline parallelism, and HuggingFace/torchtune conversion. - Use Case: Pretrain Llama 3.1 70B across 32 SLURM-managed nodes by selecting a registered config, setting FSDP and TP degrees, submitting the job, and resuming automatically from checkpoints. ## Quick Start Use the torchtitan skill to pretrain a Llama 3.1 8B model on 8 GPUs with the llama3_8b config and TensorBoard monitoring.

Frequently Asked Questions about torchtitan

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I pretrain a Llama model with TorchTitan?▼

Download the tokenizer with download_hf_assets.py, then launch training by selecting a config from the Python config registry, for example MODULE=llama3 CONFIG=llama3_8b ./run_train.sh. Override individual fields on the command line such as --optimizer.lr or --training.steps.

TorchTitan vs Megatron-LM vs DeepSpeed for LLM pretraining?▼

TorchTitan is PyTorch-native with composable 4D parallelism and no third-party dependencies. Megatron-LM targets maximum performance on NVIDIA-only deployments, while DeepSpeed offers a broader ZeRO optimization ecosystem and inference support.

Does TorchTitan support Float8 training on H100 GPUs?▼

Yes, Float8 training is supported via torchao with tensorwise or rowwise scaling recipes, providing 30-50% speedups on H100s. It requires torch.compile and works best on large GEMMs; small layers can be skipped with filter_fqns.

How do I run multi-node TorchTitan training with SLURM?▼

Create a SLURM script that calls srun torchrun with --nnodes, --nproc_per_node, and c10d rendezvous settings, then submit with sbatch. Configure parallelism degrees such as data_parallel_shard_degree and tensor_parallel_degree for your GPU count.

Why does TorchTitan run out of memory on large models?▼

OOM occurs when activation memory exceeds GPU capacity. Enable full activation checkpointing, reduce local_batch_size, or use gradient accumulation via global_batch_size to lower per-step memory usage.

How do I convert TorchTitan checkpoints to HuggingFace format?▼

Use the offline conversion scripts convert_to_hf.py and convert_from_hf.py with model name and flavor arguments, or enable last_save_in_hf and initial_load_in_hf in the checkpoint config for direct save and load during training.