Skip to content
STIRUP

TECHNOLOGY INTELLIGENCE

Understand what's next.

TorchNeuron Enables Model Execution on AWS Trainium

TorchNeuron, the native PyTorch backend for AWS Trainium, allows Transformers models to run on this hardware with minimal modifications, providing compatibility checks and execution scripts.

Share
AI-generated conceptual illustration accompanying: TorchNeuron Enables Model Execution on AWS Trainium
AI-generated editorial illustration of the article topic; not a photograph, product screenshot or measured result.

TorchNeuron and Model Execution on AWS Trainium

Does your model run on AWS Trainium? Look it up with TorchNeuron, the native PyTorch backend for AWS Trainium, as introduced by David Corvoysier in a recent update on GitHub (Hugging Face). TorchNeuron enables Transformers to execute its own modeling code on Trainium, just as it does on other devices, meaning any Transformers model on the Hub may run on this hardware. The tool provides users with information on whether a model runs unmodified on Trainium and includes a script to run it directly. This capability allows developers to assess model compatibility and execute training or inference tasks without significant modifications. The update highlights the growing integration of PyTorch with AWS Trainium, offering a pathway for users to leverage specialized hardware for machine learning workloads.

Model Lookup and Testing on Hugging Face Spaces

On Hugging Face Spaces, users can look up models to determine if they run on AWS Trainium by navigating to the Trending or Downloads view and typing part of a model's name. The Selected view displays a curated list of models based on download counts and trending scores. Each model entry provides details such as the number of Trainium cores it is sharded over, the wall time of the run (including compilation), and the peak device memory used. This information allows users to assess model performance and compatibility with Trainium hardware without requiring prior testing or inference. The data is sourced directly from model runs and is presented as part of the model's profile on the platform.

Limitations and Scope of Model Testing

At the time of writing, only Transformers models are tested, and our selection is limited to text-generation and image-text-to-text models . Furthermore, only models that fit on 4 Trainium2 devices are tested, which means 16 cores at most . Mixture-of-experts models without a tensor-parallel plan use expert parallelism only . These limitations define the scope of model testing on AWS Trainium and highlight the need for users to verify compatibility based on their specific model architecture and resource requirements. The findings presented here are specific to the models and configurations tested and should not be generalized beyond the evidence provided. Users are encouraged to consult the latest documentation and testing results for updated information.

Execution and Compilation Details

Execution and compilation details for models running on AWS Trainium involve specific setup and commands. For instance, on a Trainium2 (trn2) instance, using the AWS Neuron Deep Learning Container, users can install required packages and run a script with python3 run.py, as noted in Hugging Face. This script handles torch.distributed ranks internally when the model is sharded. Additionally, the Space provides a command to sync the correct compiler version with the appropriate cache directory, as described in Hugging Face. Each test loads the model on a trn2 instance, sharded over the smallest number of Trainium cores that can hold its weights, as stated in Hugging Face. These steps ensure that the model runs efficiently and that the text output is fluent English, as verified by a small judge model.

Data and Querying the Model Support Dataset

The dataset underlying the Space is publicly available as the aws-neuron/torch-neuronx-model-support repository on Hugging Face, containing one Parquet file for each combination of neuronx-cc and library versions. Each row in the dataset captures a model's result, any error encountered during execution, and the versions of the entire stack and the run.py script used. Users can query the dataset directly using Python and the pandas library, as demonstrated by the example code provided. This allows for targeted exploration of model compatibility with AWS Trainium, including details such as the number of neuron_cores used and the outcome of each run. The dataset card provides precise definitions for each field, ensuring clarity in interpretation.

Sources and reporting notes

Based on published source material. No independent hands-on testing is claimed.

Read more