Skip to content

[Tracking] TRL on AWS Trainium (Neuron) #7658

Open
5 of 8 issues completed
Open

Description

@qgallouedec

This tracks TRL support on AWS Trainium with TorchNeuron, the native PyTorch backend (device neuron, torch.compile(backend="neuron")). transformers and accelerate already handle the device (huggingface/transformers#44302 sets it up in TrainingArguments, huggingface/transformers#47035 makes neuron the default compile backend, and accelerate has MULTI_NEURON).

Setup used for everything below: a trn2 instance exposing 1 Trainium2 device (4 logical NeuronCores, 96 GB). torch 2.14.0, torch-neuronx 2.14.3, neuronx-cc 2.28, Python 3.14, transformers 5.19.0, accelerate 1.15.0, peft 0.21.2. Each trainer ran 3 steps on a tiny model with each option below; SFT and GRPO also ran on Qwen3-0.6B.

Status

TRL 1.14.2 TRL 1.15 main
Reward ✅ ✅ ✅
SFT, DPO, KTO, GRPO, RLOO, Distillation ✅ ❌ step 1 (#7659) ✅
+ LoRA, packing, GC off ✅ ❌ (#7659) ✅
+ eval, checkpoint save, GA, loss types (IPO, DFT), conversational and prompt-completion data not tested ❌ (#7659) ✅
torch_compile=True ❌ step 2 (#7660) ❌ ❌ step 2 (#7660)
torch_compile=True + automatic_dynamic_shapes=False ✅ ❌ (#7659) ✅
activation_offloading=True ❌ (#7662) ❌ (#7662) ✅
GRPO/RLOO cache_implementation="static" ❌ (#7664) ❌ (#7664) ✅ with a bf16 model
Model families (SFT): Qwen2, Qwen3, Llama 3.2, Mistral, Gemma 2, Qwen3-MoE, GPT-OSS ✅ (Llama, Gemma 2, Qwen3-MoE, GPT-OSS tested) ❌ (#7659) ✅ all 7
VLM (Qwen2-VL): SFT, SFT + LoRA, DPO, GRPO not tested ❌ (#7659) ✅
torch_compile + static shapes on other families ✅ Gemma 2, Qwen3-MoE, SmolLM2-135M (Llama arch); ❌ the tiny Llama 3.2 test model (neuronx-cc NCC_ITEN406, specific to its tiny dimensions)
Data parallel, 2 NeuronCores (cores 0,1) ✅ SFT ❌ (#7659) ✅ SFT, DPO, GRPO, SFT + LoRA
Data parallel, cores 2,3 and all 4 cores ✅ SFT
Data parallel, cores 1,2 ❌ collective init fails in the Neuron runtime (no_hier no_mesh); pairs must be (0,1)/(2,3)

Sub-issues

Not started

  • Neuron CI. TRL CI runs on aws-g6e-4xlarge/aws-g5-12xlarge-cache. We need a Trn2 runner group reachable from huggingface/trl; optimum-neuron uses aws-inf2-8xlarge and forge forge-use2. Until then, GPU CI covers the torch tile path by running the kernels on CPU tensors and comparing them to Triton (Run the fused LM head and distillation kernels on devices without Triton #7669).
  • vLLM on Neuron for GRPO/RLOO generation
  • An NKI kernel for the fused LM head, if profiling shows the torch tile path matters

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions