torchtitan

Pretrain large language models using PyTorch native 4D parallelism.

239k|48.8k|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/NousResearch/hermes-agent --skill torchtitan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: torchtitan
Source: https://github.com/NousResearch/hermes-agent/tree/main/optional-skills/mlops/torchtitan
Command: npx skills add https://github.com/NousResearch/hermes-agent --skill torchtitan

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 thousands of GPUs across multiple parallelism strategies, managing memory-efficient sharding, and integrating low-precision formats like Float8. This Skill provides structured workflows for configuring and launching TorchTitan training runs at scale.

Core Features & Use Cases

  • Composable 4D Parallelism: Combine FSDP2, Tensor Parallel, Pipeline Parallel, and Context Parallel for models from 8B to 405B+ parameters.
  • Float8 Training: Enable H100/Blackwell FP8 quantization with rowwise or tensorwise scaling for 30-50% throughput gains.
  • Distributed Checkpointing: Use PyTorch DCP with async writes, HuggingFace interop, and seed checkpoint creation for pipeline parallelism.
  • Use Case: A research team needs to pretrain a Llama 70B model on 256 H100 GPUs. Use this Skill to configure FSDP+TP parallelism, enable Float8 with torch.compile, and launch a SLURM multi-node training job with checkpoint resumption.

Quick Start

Use the torchtitan skill to configure and launch a Llama 3.1 8B pretraining run on 8 GPUs with FSDP2 and Float8 enabled.

Frequently Asked Questions about torchtitan

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

FAQPage Schema
How do I pretrain an LLM with PyTorch distributed parallelism?

Use TorchTitan with FSDP2 for sharding, Tensor Parallel for intra-node splitting, and Pipeline Parallel for cross-node stages. Launch via torchrun or SLURM with the run_train.sh script and a registered config name from the Python config registry.

What is the difference between FSDP2 and FSDP1 in TorchTitan?

FSDP2 uses DTensor-based sharding without the FlatParameter abstraction, achieving 7% lower peak memory and better composability. It supports meta-device initialization and communication-free sharded state dicts compared to FSDP1.

Does TorchTitan support Float8 training on H100 GPUs?

Yes, TorchTitan integrates torchao Float8LinearConverter with rowwise or tensorwise scaling recipes. Float8 requires torch.compile and benefits GEMMs with K,N dimensions greater than 4096, delivering 30-50% speedups on H100 hardware.

Why does pipeline parallelism require a seed checkpoint?

Pipeline parallelism splits model layers across stages, requiring identical weight initialization across all ranks. A seed checkpoint created on a single GPU ensures consistent initialization before sharding across the pipeline.

When should I use Megatron-LM instead of TorchTitan?

Use Megatron-LM when maximum throughput on NVIDIA-only deployments is the priority. TorchTitan is preferable for PyTorch-native workflows requiring composable parallelism, HuggingFace interoperability, and broader hardware support.