AI Cloud Architect

Train Qwen3 on AWS Trainium with torchtitan

AWSHow-to by Josh Longenecker and Alex HoffmanAWS Artificial Intelligence Blog

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.

Read the original (opens the source's page in a new tab)

AI: Summary

What it is

A walkthrough for training Qwen3 on one trn2.48xlarge using torchtitan in three ways: Hugging Face Transformers v5 backend, torchtitan's native Qwen3, and NKI mixture-of-experts kernels, plus attaching a custom NKI kernel via an override.

Who it is for

Engineers training or fine-tuning Qwen3 on AWS Trainium who need to load and save Hugging Face safetensors checkpoints.

Key points

  • AWS reports a step 1 loss of 6.54 from published Qwen3-4B-Instruct-2507 weights versus 12.43 from random initialization.
  • The NKI MoE example reduces Qwen3-30B-A3B to 4 layers and 64 experts to fit one instance.
  • The custom RoPE kernel example is stated to demonstrate registration and autograd, not a performance gain; the numerical test showed a max difference of 0.0 in float32.

The same at other vendors

Timeline

Posts about AWS Trainium, oldest first.

  1. How-toAccelerating decode-heavy LLM inference with speculative decoding on AWS Trainium and vLLM · AWS · How-to
  2. Update to an existing featureAWS Neuron SDK 2.29.0 now available with NKI and Neuron Explorer out of Beta, a new CPU Simulator, and an expanded NKI Library · AWS · Release note
  3. New featureAWS Neuron SDK now available with Neuron Agentic Development for NKI kernel development on Trainium · AWS · Announcement
  4. How-toStop hand-tuning kernels: How Neuron Agentic Development accelerates AWS Trainium optimizations · AWS · How-to
  5. How-toHow Deepgram optimized voice AI at scale with AWS Trainium · AWS · How-to
  6. PreviewAWS announces TorchNeuron: Native PyTorch Support for AWS Trainium (Public Beta) · AWS · Announcement
  7. How-toBeyond the KV cache: Training and serving i14’s Laplace 3B linear attention model on AWS Trainium2 with native PyTorch · AWS · How-to
  8. This postTrain Qwen3 on AWS Trainium with torchtitan
  9. How-toDeploy frontier AI models on AWS Trainium with SGLang-Neuron · AWS · How-to
Show all 10 posts
  1. Customer storySplash Music transforms music generation using AWS Trainium and Amazon SageMaker HyperPod · AWS · Customer story
  2. How-toAccelerating decode-heavy LLM inference with speculative decoding on AWS Trainium and vLLM · AWS · How-to
  3. Update to an existing featureAWS Neuron SDK 2.29.0 now available with NKI and Neuron Explorer out of Beta, a new CPU Simulator, and an expanded NKI Library · AWS · Release note
  4. New featureAWS Neuron SDK now available with Neuron Agentic Development for NKI kernel development on Trainium · AWS · Announcement
  5. How-toStop hand-tuning kernels: How Neuron Agentic Development accelerates AWS Trainium optimizations · AWS · How-to
  6. How-toHow Deepgram optimized voice AI at scale with AWS Trainium · AWS · How-to
  7. PreviewAWS announces TorchNeuron: Native PyTorch Support for AWS Trainium (Public Beta) · AWS · Announcement
  8. How-toBeyond the KV cache: Training and serving i14’s Laplace 3B linear attention model on AWS Trainium2 with native PyTorch · AWS · How-to
  9. This postTrain Qwen3 on AWS Trainium with torchtitan
  10. How-toDeploy frontier AI models on AWS Trainium with SGLang-Neuron · AWS · How-to

Go deeper