Skip to main content

torchtitan

A PyTorch native platform for training generative AI models

8 GPU Feature Tests 8 GPU Model Tests arXiv ICLR forum license pip conda

torchtitan is under extensive development. To use the latest features of torchtitan, we recommend using the most recent PyTorch nightly.

Latest News

  • [2026/08] TitanRL is a hackable RL stack for scaling and debugging. It reuses TorchTitan model definitions and kernels across training and vLLM generation and supports batch-invariant mode.
  • [2025/11] AMD released an optimized fork of torchtitan for AMD GPUs.
  • [2025/10] We released torchtitan v0.2.0.
  • [2025/10] SkyPilot now supports torchtitan! See the tutorial here.
  • [2025/07] We published instructions on how to add a model to torchtitan.
  • [2025/04] Our paper was accepted by ICLR 2025.
  • [2024/12] GPU MODE lecture on torchtitan.
  • [2024/07] Presentation at PyTorch Conference 2024.

Overview

torchtitan is a PyTorch native platform designed for rapid experimentation and large-scale training of generative AI models. As a minimal clean-room implementation of PyTorch native scaling techniques, torchtitan provides a flexible foundation for developers to build upon. With torchtitan extension points, one can easily create custom extensions tailored to specific needs.

Our mission is to accelerate innovation in the field of generative AI by empowering researchers and developers to explore new modeling architectures and infrastructure techniques.

The Guiding Principles when building torchtitan

  • Designed to be easy to understand, use and extend for different training purposes.
  • Minimal changes to the model code when applying multi-dimensional parallelism.
  • Bias towards a clean, minimal codebase while providing basic reusable / swappable components.

torchtitan has been showcasing PyTorch's latest distributed training features, via support for pretraining Llama 3.1 LLMs of various sizes.

Contributing

We look forward to your contributions!

  • To accelerate contributions to and innovations around torchtitan, we host an experiments folder. New ideas should start there. To contribute, follow the experiments guidelines.
  • For fixes and contributions to core, follow these guidelines.

Llama 3.1 training

Key features available

  1. Multi-dimensional composable parallelisms
  2. Meta device initialization
  3. Per-op selective and full activation checkpointing
  4. Distributed checkpointing (including async checkpointing)
  5. torch.compile support
  6. Float8 support (how-to)
  7. MXFP8 training for dense and MoE models on Blackwell GPUs.
  8. Supervised Fine-Tuning (SFT) with chat-formatted datasets
  9. DDP and HSDP
  10. TorchFT integration
  11. Checkpointable data-loading, with the C4 dataset pre-configured (144M entries) and support for custom datasets
  12. Gradient accumulation, enabled by giving an additional --training.global_batch_size argument on the CLI
  13. Flexible learning rate scheduler (warmup-stable-decay)
  14. BF16 optimizer states for reduced memory usage
  15. Loss, GPU memory, throughput (tokens/sec), TFLOPs, and MFU displayed and logged via Tensorboard or Weights & Biases
  16. Debugging tools including CPU/GPU profiling, memory profiling, Flight Recorder, etc.
  17. All options easily configured in Python with --module and --config CLI flags
  18. Structured logging: per-rank trace of key training phases; (see torchtitan/observability/structured_logger/README.md)
  19. Helper scripts to
    • download tokenizers from Hugging Face
    • convert original Llama 3 checkpoints into the expected DCP format
    • estimate FSDP/HSDP memory usage without materializing the model
    • run distributed inference with Tensor Parallel

We report performance on up to 512 GPUs, and verify loss converging correctness of various techniques.

Dive into the code

You may want to see how the model is defined or how parallelism techniques are applied. For a guided tour, see these files first:

Installation

One can directly run the source code, or install torchtitan from a nightly build, or a stable release.

From source

This method requires the nightly build of PyTorch, or the latest PyTorch built from source.

git clone https://github.com/pytorch/torchtitan
cd torchtitan
pip install -r requirements.txt
pip install --pre torchdata --index-url https://download.pytorch.org/whl/nightly/cpu

Note: The nightly build of torchdata is required when using a PyTorch nightly. Install it from the nightly index as shown above.

Note: You can run directly from the source tree. If you need to import torchtitan as a package from elsewhere, install it in editable mode without re-resolving dependencies: pip install -e . --no-deps.

Nightly builds

This method requires the nightly build of PyTorch. You can replace cu130 with another version of cuda or an AMD GPU (e.g. rocm6.3).

pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu130 --force-reinstall
pip install --pre torchtitan --index-url https://download.pytorch.org/whl/nightly/cu130

Stable releases

One can install the latest stable release of torchtitan via pip or conda.

pip install torchtitan
conda install conda-forge::torchtitan

Note that each stable release pins the nightly versions of torch and torchao. Please see release.md for more details.

Downloading a tokenizer

torchtitan currently supports training Llama 3.1 (8B, 70B, 405B) out of the box. To get started training these models, we need to download the tokenizer. Follow the instructions on the official meta-llama repository to ensure you have access to the Llama model weights.

Once you have confirmed access, you can run the following command to download the Llama 3.1 tokenizer to your local machine.

# Get your HF token from https://huggingface.co/settings/tokens

# Llama 3.1 tokenizer
python scripts/download_hf_assets.py --repo_id meta-llama/Llama-3.1-8B --assets tokenizer --hf_token=...

Start a training run

Llama 3 8B model locally on 8 GPUs

MODULE=llama3 CONFIG=llama3_8b ./run_train.sh

Multi-Node Training

For training on ParallelCluster/Slurm type configurations, you can use the multinode_trainer.slurm file to submit your sbatch job.

To get started adjust the number of nodes and GPUs

#SBATCH --ntasks=2
#SBATCH --nodes=2

Then start a run where nnodes is your total node count, matching the sbatch node count above.

srun torchrun --nnodes 2

If your gpu count per node is not 8, adjust --nproc_per_node in the torchrun command and #SBATCH --gpus-per-task in the SBATCH command section.

Citation

We provide a detailed look into the parallelisms and optimizations available in torchtitan, along with summary advice on when to use various techniques.

TorchTitan: One-stop PyTorch native solution for production ready LLM pre-training

@inproceedings{
   liang2025torchtitan,
   title={TorchTitan: One-stop PyTorch native solution for production ready {LLM} pretraining},
   author={Wanchao Liang and Tianyu Liu and Less Wright and Will Constable and Andrew Gu and Chien-Chin Huang and Iris Zhang and Wei Feng and Howard Huang and Junjie Wang and Sanket Purandare and Gokul Nadathur and Stratos Idreos},
   booktitle={The Thirteenth International Conference on Learning Representations},
   year={2025},
   url={https://openreview.net/forum?id=SFN6Wm7YBI}
}

License

Source code is made available under a BSD 3 license, however you may have other legal obligations that govern your use of other content linked in this repository, such as the license or terms of service for third-party data and models.

Release files for torchtitan 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchtitan 0.3.0
File Size Uploaded
torchtitan-0.3.0.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for torchtitan 0.3.0
File Interpreter ABI Platform
torchtitan-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.3 MB

Release files / torchtitan-0.3.0.tar.gz

Download URL torchtitan-0.3.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
6351b2dc6cdd8bdad15cd2ce5d9520e391a75b584770d2ebd925cc3321cd1b47
BLAKE2b-256 checksum
How to use checksums
62b7c12d162b0f0f1c96052c70e456aad19038b46c4ddcb585bbd64e0bdf310d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release files / torchtitan-0.3.0-py3-none-any.whl

Download URL torchtitan-0.3.0-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
5563ccf9a295b24e00a36087149e9c2d0686cecbd3972c31e67227029293af42
BLAKE2b-256 checksum
How to use checksums
6d0f42a9599a63200352f21cbd3ef21ae8696028e431e6ab82e0b737dc834097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page