您的模型在 AWS Trainium 上运行吗?查找一下
Hugging Face Blog 发布了这条动态,详情请查看官方发布。

来自 Hugging Face Blog 的官方动态,版本与适用范围以发布方说明为准。
Hugging Face Blog · 查看官方发布中文机器翻译 · 原文附后
正文 · 来源原文
在上一篇文章中,我们介绍了 TorchNeuron,它是 AWS Trainium(torch-neuronx 包)的原生 PyTorch 后端。有了它,Transformers 在 Trainium 上运行自己的建模代码,就像在任何其他设备上一样,因此 Hub 上的任何 Transformers 模型都可以运行。哪些实际上是这样做的?
torch-neuronx 模型支持 Space 回答了 Hub 上最受欢迎模型的问题。它告诉您模型是否未经修改就可以在 Trainium 上运行,并为您提供自行运行该模型的脚本。
该空间将在“选定”视图中打开:我们自己选择的模型是根据下载量和趋势分数从 Hub 上的顶级模型中挑选出来的。每行给出结果、模型分片的 Trainium 核心数量、运行的挂起时间(包括编译)以及峰值设备内存。
要查找给定模型,请切换到“趋势”或“下载”视图并键入其名称的一部分。这些视图遵循中心自己的排名,一次一项任务,无论模型是否经过测试。当某个模型被故意遗漏时,空间会告诉您原因(大多数时候它没有优先考虑,有时它确实不兼容)。您还可以选择 Neuron 编译器 (neuronx-cc) 和 Transformer 的版本进行查看。
在撰写本文时,仅测试了 Transformers 模型,我们的选择仅限于文本生成和图像-文本到文本模型。我们计划扩展到扩散器、句子转换器和其他转换器任务。
选择一个模型以查看如何运行它。空间列出了测试模型的神经元堆栈、要在其上安装的软件包以及运行的 run.py 脚本。该脚本遵循 TorchNeuron 公告的配方:它使用 from_pretrained 加载模型,在需要时进行分片,然后使用静态缓存和 torch.compile(backend="neuron") 进行生成。
在具有该堆栈的 Trainium2 (trn2) 实例上(例如在 AWS Neuron 深度学习容器中),安装软件包,然后运行:
不需要 torchrun:当模型分片时,脚本会启动自己的 torch.distributed 排名。
第一次运行从编译模型的图表开始。要跳过该步骤,请从公共 NEFF 缓存存储桶中复制测试期间构建的同一编译器的图。 Space 为您提供命令以及正确的编译器版本:
每个测试都将模型加载到 trn2 实例上,并在能够承受其重量的最小数量的 Trainium 核心上进行分片。大多数模型都采用张量并行性进行分片。没有张量并行计划的专家混合模型仅使用专家并行性。然后测试生成 32 个令牌并检查它们。在单核上,将令牌与相同检查点的 CPU 运行的令牌进行比较。当模型被分片时,一个小的判断模型会检查文本是否是流利的英语。
在撰写本文时,仅测试了适合 4 个 Trainium2 设备的模型,这意味着最多 16 个内核。 PASS 没有说明吞吐量或更长的代数。
Space 显示的所有内容均来自公共 aws-neuron/torch-neuronx-model-support 数据集,每对 Neuronx-cc 和库版本都有一个 Parquet 文件。
每行保存模型的结果、失败时的错误、整个堆栈的版本以及运行的 run.py。可以直接查询:
数据集卡给出了每个结果的确切含义。
下次当您想知道某个模型是否可以在 Trainium 上运行时,请查找一下。
查看英文原文
Does Your Model Run on AWS Trainium? Look It Up
Hugging Face Blog 发布了这条动态,详情请查看官方发布。
正文 · 来源原文
In a previous post, we introduced TorchNeuron, the native PyTorch backend for AWS Trainium (the torch-neuronx package). With it, Transformers runs its own modeling code on Trainium, as it does on any other device, so any Transformers model on the Hub may run. Which ones actually do?
The torch-neuronx model support Space answers that question for the most popular models on the Hub. It tells you whether a model runs unmodified on Trainium, and gives you the script to run it yourself.
The Space opens on the Selected view: our own selection of models picked among the top models on the Hub by downloads and by trending score. Each row gives the result, the number of Trainium cores the model is sharded over, the wall time of the run (compilation included) and the peak device memory.
To look up a given model, switch to the Trending or Downloads view and type part of its name. These views follow the Hub's own rankings, one task at a time, whether a model was tested or not. When a model was left out on purpose, the Space tells you why (most of the time it was not prioritized, sometimes it is truly incompatible). You can also pick the versions of the Neuron compiler (neuronx-cc) and of Transformers to look at.
At the time of writing, only Transformers models are tested, and our selection is limited totext-generationandimage-text-to-textmodels. We plan to expand to diffusers, sentence transformers, and other transformers tasks.
