[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-71168":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},71168,"torchtitan","pytorch\u002Ftorchtitan","pytorch","A PyTorch native platform for training generative AI models","",null,"Python",5428,853,60,222,0,12,35,99,36,112.19,"BSD 3-Clause \"New\" or \"Revised\" License",false,"main",[],"2026-06-12 04:00:59","\u003Cdiv align=\"center\">\n\n# torchtitan\n\n#### A PyTorch native platform for training generative AI models\n\n[![8 GPU Feature Tests](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\u002Factions\u002Fworkflows\u002Fintegration_test_8gpu_features.yaml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\u002Factions\u002Fworkflows\u002Fintegration_test_8gpu_features.yaml?query=branch%3Amain)\n[![8 GPU Model Tests](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\u002Factions\u002Fworkflows\u002Fintegration_test_8gpu_models.yaml\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\u002Factions\u002Fworkflows\u002Fintegration_test_8gpu_models.yaml?query=branch%3Amain)\n[![arXiv](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FarXiv-2410.06511-b31b1b.svg)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2410.06511)\n[![ICLR](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FICLR-2025-violet.svg)](https:\u002F\u002Ficlr.cc\u002Fvirtual\u002F2025\u002Fposter\u002F29620)\n[![forum](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpytorch-forum-DE3412.svg)](https:\u002F\u002Fdiscuss.pytorch.org\u002Fc\u002Fdistributed\u002Ftorchtitan\u002F44)\n[![license](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-BSD_3--Clause-lightgrey.svg)](.\u002FLICENSE)\n[![pip](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Ftorchtitan?color=blue)](https:\u002F\u002Fpypi.org\u002Fproject\u002Ftorchtitan\u002F)\n[![conda](https:\u002F\u002Fimg.shields.io\u002Fconda\u002Fvn\u002Fconda-forge\u002Ftorchtitan?color=green)](https:\u002F\u002Fanaconda.org\u002Fconda-forge\u002Ftorchtitan)\n\n\n\u003C\u002Fdiv>\n\n`torchtitan` is under extensive development. To use the latest features of `torchtitan`, we recommend using the most recent PyTorch nightly.\n\n\n## Latest News\n- [2025\u002F11] AMD released an [optimized fork](https:\u002F\u002Fgithub.com\u002FAMD-AGI\u002Ftorchtitan-amd\u002Ftree\u002Fmain) of `torchtitan` for AMD GPUs.\n- [2025\u002F10] We released `torchtitan` [v0.2.0](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\u002Freleases).\n- [2025\u002F10] SkyPilot now supports `torchtitan`! See the tutorial [here](https:\u002F\u002Fdocs.skypilot.co\u002Fen\u002Flatest\u002Fexamples\u002Ftraining\u002Ftorchtitan.html).\n- [2025\u002F07] We published [instructions](\u002Ftorchtitan\u002Fmodels\u002FREADME.md) on how to add a model to `torchtitan`.\n- [2025\u002F04] Our paper was accepted by [ICLR 2025](https:\u002F\u002Ficlr.cc\u002Fvirtual\u002F2025\u002Fposter\u002F29620).\n- [2024\u002F12] GPU MODE [lecture](https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=VYWRjcUqW6w) on torchtitan.\n- [2024\u002F07] [Presentation](https:\u002F\u002Fpytorch2024.sched.com\u002Fevent\u002F1fHn3) at PyTorch Conference 2024.\n\n\n## Overview\n\n`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](docs\u002Fextension.md), one can easily create custom extensions tailored to specific needs.\n\nOur mission is to accelerate innovation in the field of generative AI by empowering researchers and developers to explore new modeling architectures and infrastructure techniques.\n\nThe Guiding Principles when building `torchtitan`\n* Designed to be easy to understand, use and extend for different training purposes.\n* Minimal changes to the model code when applying multi-dimensional parallelism.\n* Bias towards a clean, minimal codebase while providing basic reusable \u002F swappable components.\n\n`torchtitan` has been showcasing PyTorch's latest distributed training features, via support for pretraining Llama 3.1 LLMs of various sizes.\n\n## Contributing\n\nWe look forward to your contributions!\n\n* To accelerate contributions to and innovations around torchtitan, we host an [`experiments`](torchtitan\u002Fexperiments) folder. New ideas should start there. To contribute, follow the [`experiments guidelines`](torchtitan\u002Fexperiments\u002FREADME.md).\n* For fixes and contributions to core, follow these [`guidelines`](CONTRIBUTING.md).\n\n## Llama 3.1 training\n\n### Key features available\n\n1. Multi-dimensional composable parallelisms\n   - [FSDP2](docs\u002Ffsdp.md) with per-parameter sharding\n   - [Tensor Parallel](https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Fdistributed.tensor.parallel.html) (including [async TP](https:\u002F\u002Fdiscuss.pytorch.org\u002Ft\u002Fdistributed-w-torchtitan-introducing-async-tensor-parallelism-in-pytorch\u002F209487))\n   - [Pipeline Parallel](https:\u002F\u002Fdiscuss.pytorch.org\u002Ft\u002Fdistributed-w-torchtitan-training-with-zero-bubble-pipeline-parallelism\u002F214420)\n   - [Context Parallel](https:\u002F\u002Fdiscuss.pytorch.org\u002Ft\u002Fdistributed-w-torchtitan-breaking-barriers-training-long-context-llms-with-1m-sequence-length-in-pytorch-using-context-parallel\u002F215082)\n2. [Meta device](https:\u002F\u002Fpytorch.org\u002Fdocs\u002Fstable\u002Fmeta.html) initialization\n3. Per-op selective and full activation checkpointing\n4. [Distributed checkpointing](https:\u002F\u002Fdiscuss.pytorch.org\u002Ft\u002Fdistributed-w-torchtitan-optimizing-checkpointing-efficiency-with-pytorch-dcp\u002F211250) (including async checkpointing)\n   - [Interoperable checkpoints](docs\u002Fcheckpoint.md) which can be loaded directly into [`torchtune`](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtune) for fine-tuning\n5. `torch.compile` support\n6. [Float8](https:\u002F\u002Fdiscuss.pytorch.org\u002Ft\u002Fdistributed-w-torchtitan-enabling-float8-all-gather-in-fsdp2\u002F209323) support ([how-to](torchtitan\u002Fcomponents\u002Fquantization\u002Ffloat8.md))\n7. [MXFP8 training for dense and MoE models](torchtitan\u002Fcomponents\u002Fquantization\u002Fmxfp8.md) on Blackwell GPUs.\n8. Supervised Fine-Tuning (SFT) with chat-formatted datasets\n9. DDP and HSDP\n10. [TorchFT](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchft) integration\n11. Checkpointable data-loading, with the C4 dataset pre-configured (144M entries) and support for [custom datasets](docs\u002Fdatasets.md)\n12. Gradient accumulation, enabled by giving an additional `--training.global_batch_size` argument on the CLI\n13. Flexible learning rate scheduler (warmup-stable-decay)\n14. [BF16 optimizer states](docs\u002Fbf16_optimizer_states.md) for reduced memory usage\n15. Loss, GPU memory, throughput (tokens\u002Fsec), TFLOPs, and MFU displayed and logged via [Tensorboard or Weights & Biases](\u002Fdocs\u002Fmetrics.md)\n16. [Debugging tools](docs\u002Fdebugging.md) including CPU\u002FGPU profiling, memory profiling, Flight Recorder, etc.\n17. All options easily configured via [Python config registry](torchtitan\u002Fmodels\u002Fllama3\u002Fconfig_registry.py) with `--module` and `--config` CLI flags\n18. Structured logging: per-rank trace of key training phases; (see [`torchtitan\u002Fobservability\u002Fstructured_logger\u002FREADME.md`](torchtitan\u002Fobservability\u002Fstructured_logger\u002FREADME.md))\n19. [Helper scripts](scripts\u002F) to\n    - download tokenizers from Hugging Face\n    - convert original Llama 3 checkpoints into the expected DCP format\n    - estimate FSDP\u002FHSDP memory usage without materializing the model\n    - run distributed inference with Tensor Parallel\n\nWe report [performance](benchmarks\u002Fllama3_h100_202412_torchtitan.md) on up to 512 GPUs, and verify [loss converging](docs\u002Fconverging.md) correctness of various techniques.\n\n### Dive into the code\n\nYou may want to see how the model is defined or how parallelism techniques are applied. For a guided tour, see these files first:\n* [torchtitan\u002Ftrain.py](torchtitan\u002Ftrain.py) - the main training loop and high-level setup code\n* [torchtitan\u002Fmodels\u002Fllama3\u002Fmodel.py](torchtitan\u002Fmodels\u002Fllama3\u002Fmodel.py) - the Llama 3.1 model definition\n* [torchtitan\u002Fmodels\u002Fllama3\u002Fparallelize.py](torchtitan\u002Fmodels\u002Fllama3\u002Fparallelize.py) - helpers for applying Data Parallel, Tensor Parallel, activation checkpointing, and `torch.compile` to the model\n* [torchtitan\u002Fdistributed\u002Fpipeline_parallel.py](torchtitan\u002Fdistributed\u002Fpipeline_parallel.py) - helpers for applying Pipeline Parallel to the model\n* [torchtitan\u002Fcomponents\u002Fcheckpoint.py](torchtitan\u002Fcomponents\u002Fcheckpoint.py) - utils for saving\u002Floading distributed checkpoints\n* [torchtitan\u002Fcomponents\u002Fquantization\u002Ffloat8.py](torchtitan\u002Fcomponents\u002Fquantization\u002Ffloat8.py) - utils for applying Float8 techniques\n\n\n## Installation\n\nOne can directly run the source code, or install `torchtitan` from a nightly build, or a stable release.\n\n### From source\n\nThis method requires the nightly build of PyTorch, or the latest PyTorch built [from source](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch?tab=readme-ov-file#from-source).\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\ncd torchtitan\npip install -r requirements.txt\npip install --pre torchdata --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcpu\n```\n\n> **Note:** The nightly build of `torchdata` is required when using a PyTorch nightly. Install it from the nightly index as shown above.\n\n### Nightly builds\n\nThis method requires the nightly build of PyTorch. You can replace `cu130` with another version of cuda or an AMD GPU (e.g. `rocm6.3`).\n\n```sh\npip3 install --pre torch --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu130 --force-reinstall\npip install --pre torchtitan --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fnightly\u002Fcu130\n```\n\n### Stable releases\nOne can install the latest [stable release](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Ftorchtitan\u002Freleases) of `torchtitan` via `pip` or `conda`.\n```sh\npip install torchtitan\n```\n```sh\nconda install conda-forge::torchtitan\n```\nNote that each stable release pins the nightly versions of `torch` and `torchao`. Please see [release.md](docs\u002Frelease.md) for more details.\n\n### Downloading a tokenizer\n\n`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](https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FLlama-3.1-8B) repository to ensure you have access to the Llama model weights.\n\nOnce you have confirmed access, you can run the following command to download the Llama 3.1 tokenizer to your local machine.\n\n```bash\n# Get your HF token from https:\u002F\u002Fhuggingface.co\u002Fsettings\u002Ftokens\n\n# Llama 3.1 tokenizer\npython scripts\u002Fdownload_hf_assets.py --repo_id meta-llama\u002FLlama-3.1-8B --assets tokenizer --hf_token=...\n```\n\n### Start a training run\nLlama 3 8B model locally on 8 GPUs\n\n```bash\nMODULE=llama3 CONFIG=llama3_8b .\u002Frun_train.sh\n```\n\n### Multi-Node Training\nFor training on ParallelCluster\u002FSlurm type configurations, you can use the `multinode_trainer.slurm` file to submit your sbatch job.\n\nTo get started adjust the number of nodes and GPUs\n```\n#SBATCH --ntasks=2\n#SBATCH --nodes=2\n```\n\nThen start a run where `nnodes` is your total node count, matching the sbatch node count above.\n\n```\nsrun torchrun --nnodes 2\n```\n\nIf 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.\n\n\n## Citation\n\nWe provide a detailed look into the parallelisms and optimizations available in `torchtitan`, along with summary advice on when to use various techniques.\n\n[TorchTitan: One-stop PyTorch native solution for production ready LLM pre-training](https:\u002F\u002Fopenreview.net\u002Fforum?id=SFN6Wm7YBI)\n```\n@inproceedings{\n   liang2025torchtitan,\n   title={TorchTitan: One-stop PyTorch native solution for production ready {LLM} pretraining},\n   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},\n   booktitle={The Thirteenth International Conference on Learning Representations},\n   year={2025},\n   url={https:\u002F\u002Fopenreview.net\u002Fforum?id=SFN6Wm7YBI}\n}\n```\n\n\n## License\n\nSource code is made available under a [BSD 3 license](.\u002FLICENSE), 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.\n","torchtitan 是一个基于 PyTorch 的原生平台，专为生成式 AI 模型的快速实验和大规模训练设计。该项目的核心功能包括支持多维度并行化技术，同时保持模型代码的最小改动，以简化开发流程。此外，它还提供了扩展点，允许用户根据具体需求定制扩展功能。torchtitan 适用于需要高效训练大型生成式 AI 模型的研究者与开发者，尤其是在探索新模型架构或优化现有基础设施时。",2,"2026-06-11 03:36:22","high_star"]