Metadata-Version: 2.4
Name: torchtitan-neuron
Version: 0.2.2+neuron.2
Summary: A PyTorch native platform for training generative AI models
Author: AWS Neuron Team
License: BSD 3-Clause License
        
        (c) Meta Platforms, Inc. and affiliates.
        
        Redistribution and use in source and binary forms, with or without modification,
        are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice,this list
        of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice, this
        list of conditions and the following disclaimer in the documentation
        and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its contributors may
        be used to endorse or promote products derived from this software without specific
        prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY
        EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
        SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
        INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
        TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
        BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
        ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
        DAMAGE.
        
Project-URL: GitHub, https://github.com/aws-neuron/torchtitan-neuron
Project-URL: Documentation, https://github.com/aws-neuron/torchtitan-neuron/tree/main/docs
Project-URL: Issues, https://github.com/aws-neuron/torchtitan-neuron/issues
Project-URL: Upstream, https://github.com/pytorch/torchtitan
Keywords: pytorch,training,llm
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torchdata>=0.8.0
Requires-Dist: datasets>=3.6.0
Requires-Dist: tokenizers>=0.15.0
Requires-Dist: safetensors
Requires-Dist: tyro
Requires-Dist: tensorboard
Requires-Dist: wandb
Requires-Dist: einops
Requires-Dist: pillow
Requires-Dist: spmd_types==0.2.1
Provides-Extra: dev
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: expecttest; extra == "dev"
Requires-Dist: pyrefly==0.45.1; extra == "dev"
Dynamic: license-file

# TorchTitan Neuron

TorchTitan Neuron is the AWS Neuron's extension of [pytorch/torchtitan](https://github.com/pytorch/torchtitan). It adds AWS Trainium support through [TorchNeuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/torch/about-pytorch-neuron.html), the native PyTorch backend for Neuron. The Neuron-specific recipes, NKI kernel integrations, and docs are in [`torchtitan_neuron/`](torchtitan_neuron/README.md).

## Support matrix

| Component | Supported version |
|---|---|
| Neuron SDK | 2.34.0 (TorchNeuron public beta) |
| PyTorch / `torch-neuronx` | 2.14.0 / 2.14.3.1.* |
| Python | 3.12, 3.13, 3.14 (Linux x86_64) |
| Instances | Trn2, Trn3 |
| Precision | BF16; MXFP8 on Trn3 |
| Execution | Eager, and `torch.compile` with `--compile.backend neuron` (static shapes only) |
| Models | Llama3, Qwen3, DeepSeek-V3, GPT-OSS |
| Parallelism | FSDP2, SimpleFSDP, TP, CP, EP, PP, DDP, activation checkpointing |

## Quick start

Before you start, install and verify `torch-neuronx` on a Trn2 or Trn3 instance by following [Quickstart: Install and verify torch-neuronx](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/torch/get-started/quickstart-torch-neuron.html). Then install this fork:

```bash
git clone https://github.com/aws-neuron/torchtitan-neuron.git
cd torchtitan-neuron
git checkout release_2.34.0
pip install -r requirements.txt
pip install -e .
```

Run a short verification on one `trn2.48xlarge` (64 logical NeuronCores, TP4 × FSDP16) using the bundled test tokenizer and dataset:

```bash
NGPU=64 MODULE=torchtitan_neuron.models.qwen3 CONFIG=qwen3_8b_tp4_fsdp16_sac \
  ./run_train.sh --training.steps 10 --metrics.log_freq 1 \
  --dataloader.dataset c4_test --hf_assets_path=./tests/assets/tokenizer
```

## Documentation

- [What is TorchTitan Neuron?](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/training/torchtitan/about-torchtitan-neuron.html)
- [Set up TorchTitan Neuron](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/training/torchtitan/get-started/setup-torchtitan-neuron.html)
- [TorchTitan Neuron tutorials](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/training/torchtitan/tutorials/index.html)
- [Release notes](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/release-notes/components/torchtitan-neuron.html)

### Repository guides

Start with the [Neuron package overview](torchtitan_neuron/README.md) for the
package boundary, layout, included components, and recipe selection.

| Topic | Guide |
| --- | --- |
| Dense Qwen3 and Llama3 training | [Dense model tutorials](torchtitan_neuron/docs/dense-tutorials.md) |
| Qwen3, DeepSeek-V3, and GPT-OSS MoE training | [MoE model tutorials](torchtitan_neuron/docs/moe-tutorials.md) |
| Qwen3 NKI mixture-of-experts recipes | [Qwen3 NKI MoE](torchtitan_neuron/docs/qwen3_nki_moe.md) |
| MXFP8 training on Trn3 | [Neuron MXFP8](torchtitan_neuron/docs/neuron_mxfp8.md) |
| Full Qwen3-235B-A22B training | [Four-node Trainium3 UltraServer guide](torchtitan_neuron/docs/qwen3_235b_full_ep128.md) |
| Qwen3 inference with `torch.compile` | [Qwen3 inference](torchtitan_neuron/docs/qwen3_inference.md) |
| Neuron extension test suite | [Testing `torchtitan_neuron`](torchtitan_neuron/tests/README.md) |

## Issues

Report problems with running on Neuron or Trainium in this repository's [issues](https://github.com/aws-neuron/torchtitan-neuron/issues). Report problems that also occur on upstream torchtitan to [pytorch/torchtitan](https://github.com/pytorch/torchtitan/issues).

## Package layout

The Neuron-specific recipes, NKI kernel integrations, and docs are in
[`torchtitan_neuron/`](torchtitan_neuron/README.md):

```text
torchtitan_neuron/
|-- models/       Neuron modules and Trainer configuration registries
|-- experiments/  GraphTrainer configuration registries
|-- components/   Neuron-specific reusable components
|-- docs/         AWS Neuron documentation
`-- tests/        Neuron kernel, Trainer, and GraphTrainer tests
```

## 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](https://openreview.net/forum?id=SFN6Wm7YBI)
```
@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](./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.
