# Train Qwen3 on AWS Trainium with torchtitan

DevFeed: [Train Qwen3 on AWS Trainium with torchtitan](<https://devfeed.tech/articles/train-qwen3-on-aws-trainium-with-torchtitan-93901.md>)

Original publisher: [Read original article](<https://aws.amazon.com/blogs/machine-learning/train-qwen3-on-aws-trainium-with-torchtitan/>)

Author: Josh Longenecker

Published: 2026-10-21T20:00:22Z

Content type: tutorial

Language: en

Sources: [Artificial Intelligence](<https://devfeed.tech/sources/artificial-intelligence.md>)

Topics: [AWS Trainium](<https://devfeed.tech/topics/aws-trainium.md>), [neuron](<https://devfeed.tech/topics/neuron.md>), [Mixture of Experts (MoE)](<https://devfeed.tech/topics/mixture-of-experts-moe.md>), [AI Infrastructure](<https://devfeed.tech/topics/ai-infrastructure.md>), [AWS AI chips](<https://devfeed.tech/topics/aws-ai-chips.md>), [hugging face](<https://devfeed.tech/topics/hugging-face.md>)

Tags: [advanced-300](<https://devfeed.tech/tags/advanced-300.md>), [all](<https://devfeed.tech/tags/all.md>), [aws](<https://devfeed.tech/tags/aws.md>), [aws-trainium](<https://devfeed.tech/tags/aws-trainium.md>), [backend](<https://devfeed.tech/tags/backend.md>), [config](<https://devfeed.tech/tags/config.md>), [experts](<https://devfeed.tech/tags/experts.md>), [hugging-face](<https://devfeed.tech/tags/hugging-face.md>), [kernels](<https://devfeed.tech/tags/kernels.md>), [loading](<https://devfeed.tech/tags/loading.md>), [mixture-of-experts](<https://devfeed.tech/tags/mixture-of-experts.md>), [modeling](<https://devfeed.tech/tags/modeling.md>), [native](<https://devfeed.tech/tags/native.md>), [qwen3](<https://devfeed.tech/tags/qwen3.md>), [safetensors](<https://devfeed.tech/tags/safetensors.md>), [structure](<https://devfeed.tech/tags/structure.md>), [technical-how-to](<https://devfeed.tech/tags/technical-how-to.md>), [train](<https://devfeed.tech/tags/train.md>), [trainium](<https://devfeed.tech/tags/trainium.md>), [transformers](<https://devfeed.tech/tags/transformers.md>), [v5](<https://devfeed.tech/tags/v5.md>), [with](<https://devfeed.tech/tags/with.md>)

## AI overview

On a single AWS Trainium trn2.48xlarge, torchtitan can train Qwen3 through three paths using the same torchrun launcher and config structure: Transformers v5 via AutoModelForCausalLM, torchtitan's native Qwen3 model selected with config.model_spec, or NKI kernels for mixture-of-experts layers. The Transformers path can load published Hugging Face weights and save standard safetensors; the article reports a first-step loss of 6.54 from published weights versus 12.43 from random initialization for Qwen3-4B-Instruct-2507. The NKI example uses 64 data-parallel ranks without expert parallelism, and reduces Qwen3-30B-A3B to four layers and 64 experts to fit the instance. Custom NKI operators can be attached through torchtitan's override registry, but the rotary-kernel example demonstrates registration and autograd integration, not a performance gain. Pin the walkthrough's versions because the Transformers integration and Trainium overrides can change between torchtitan releases.

## Source excerpt

Train Qwen3 on AWS Trainium with torchtitan three ways on a single trn2.48xlarge: the Hugging Face Transformers v5 modeling backend, torchtitan's native Qwen3, and NKI mixture-of-experts kernels. The same torchrun launcher and config structure work unchanged across all three paths, including loading and saving published Hugging Face safetensors.