TorchNeuron provides a native PyTorch backend for AWS Trainium
Decision Brief
TorchNeuron is a native PyTorch backend plugin for AWS Trainium, in public beta since October 20, 2026, installable via pip install torch-neuronx. It supports eager execution, torch.compile, and native distributed interfaces (DTensor, FSDP2), replacing the PyTorch XLA-based Optimum Neuron. Hugging Face recommends Neuron users use Transformers, Diffusers, Accelerate, PEFT, and TRL directly rather than going through Optimum Neuron. For inference, users just pass device_map=neuron and Transformers loads the model onto Neuron devices; 89% of the top 100 text-generation architectures are supported out of the box, versus 46% with Optimum Neuron v0.4.5. In Diffusers, pipelines such as FLUX.1-dev, FLUX.2, and Qwen-Image support tensor parallelism. For training with TRL's SFTTrainer, setting tp_size and fsdp_size in DistributedConfig's model_init_kwargs lets the Trainer shard weights across a TP×FSDP grid, with no --fsdp flag or Accelerate config needed. The example trains on 8 Trainium2 chips (32 NeuronCores) and saves standard Transformers checkpoints that can be uploaded to the Hub and loaded on other hardware. Note: Neuron does not yet support Dynamo automatic dynamic shapes, HF_DEACTIVATE_ASYNC_LOAD=1 must be disabled, and batches are padded to multiples of 128 tokens.
Sources
- Hugging Face:Blog
Open-source models, datasets, libraries, and practical ML engineering for builders.
- Hugging Face:Blog
留言
登入后即可留言,和其他 builder 交换实测心得。
还没有留言,抢头香。