|
Download README.md from aws-neuron/torch-neuronx-model-support: direct link, hf CLI and curl.
- Browser
- Download file 7.44 kB
-
https://huggingface.co/datasets/aws-neuron/torch-neuronx-model-support/resolve/main/README.md
- Command line
-
hf download hf://datasets/aws-neuron/torch-neuronx-model-support/README.md
-
curl -L -o README.md https://huggingface.co/datasets/aws-neuron/torch-neuronx-model-support/resolve/main/README.md
7.44 kB
| license: apache-2.0 | |
| pretty_name: torch-neuronx model support | |
| tags: | |
| - neuron | |
| - trainium | |
| - transformers | |
| configs: | |
| - config_name: default | |
| data_files: | |
| - split: train | |
| path: data/*/*.parquet | |
| # torch-neuronx model support | |
| Which Hugging Face Hub models run unmodified on AWS Trainium, through the | |
| native PyTorch backend | |
| [`torch-neuronx`](https://github.com/aws-neuron/torch-neuronx), for each | |
| `neuronx-cc` and library version tested. The only library tested so far is | |
| [`transformers`](https://github.com/huggingface/transformers). | |
| To look up a model, use the | |
| [Space](https://huggingface.co/spaces/aws-neuron/torch-neuronx-model-support). | |
| ## What is tested | |
| ### transformers | |
| Each run loads a model on a `trn2` instance and generates 32 tokens greedily | |
| from the prompt `"The future of AI is"`, sent as a user message for chat | |
| models. The model is sharded over the smallest power-of-two number of | |
| NeuronCores that fits its bf16 weights, one rank per core: with | |
| `tp_plan="auto"`, or expert-parallel for mixture-of-experts models without a | |
| tensor-parallel plan. Generation uses `torch.compile(backend="neuron")` with a | |
| static cache and chunked prefill. An encoder-decoder model runs its encoder | |
| once on the prompt, then generates from its decoder, on one NeuronCore. | |
| A text encoder, such as a BERT, RoBERTa or DeBERTa model, runs one forward pass | |
| instead, on one NeuronCore, compiled with `torch.compile(backend="neuron")`. Its | |
| input is the sentence `"My name is Wolfgang and I live in Berlin."`, padded to | |
| 128 tokens, with `Berlin` masked for a masked language model, and after the | |
| question `"Where do I live?"` for a question-answering one. It loads with the | |
| head class its checkpoint declares, or without a head. | |
| For now, only models that fit on 4 Trainium2 devices are tested, 16 | |
| NeuronCores at most. | |
| | `result` | Meaning | | |
| |---|---| | |
| | `PASS` | The model loaded, `generate()` or an encoder's forward pass returned, and the output check passed or could not run. | | |
| | `FAIL(load)` | `from_pretrained` raised. | | |
| | `FAIL(gen)` | `generate()` raised. | | |
| | `FAIL(forward)` | An encoder's forward pass raised. | | |
| | `FAIL(output)` | `generate()` or the forward pass returned, but the output check failed. | | |
| | `FAIL(other)` | The run crashed, or the model's extra Python packages could not be installed. | | |
| | `EXCLUDED` | Not tested: the sweep's selection left the model out, for the reason in `notes`. A later run of the model replaces this row. | | |
| The output check compares a run on one NeuronCore with a CPU run of the same | |
| checkpoint and prompt: the tokens must match, or differ first at a near-tie. | |
| On more cores, or when the CPU run cannot complete, a small instruct model | |
| judges whether the text is fluent English. `PASS` says nothing about | |
| throughput or about longer generations. | |
| For an encoder, the CPU runs the same forward pass in fp32, the reference, and | |
| in bf16, which shows how far bf16 alone drifts from it: far, for some models. | |
| Neuron, in bf16, is held to what the CPU achieves in bf16. The predictions must | |
| be the CPU's, in fp32 or in bf16, or differ from fp32's only at a near-tie: the | |
| masked word, each token's label, the class or the answer span. A head with a | |
| single output, such as a reranker's score, must stay within 1.0 of fp32's, or | |
| within twice the bf16 CPU run's distance to it. Without a head, each token's | |
| hidden state must have a cosine similarity of at least 0.99 with fp32's, or a | |
| cosine distance to it at most twice the bf16 CPU run's. | |
| The models are the top `text-generation` and `image-text-to-text` models on | |
| the Hub by downloads and trending, reselected before each sweep: the 100 | |
| best-ranked form the selection. The sweep's list continues with the models of | |
| these tasks, of `translation` and `summarization`, encoder-decoder models | |
| included, and of the text encoder tasks (`fill-mask`, `token-classification`, | |
| `text-classification`, `question-answering`, `zero-shot-classification`, | |
| `feature-extraction`, `sentence-similarity` and `text-ranking`), down to rank | |
| 1000 among the Hub's transformers models of their task, by downloads or | |
| trending. Each sweep goes down the list in order until it has | |
| run 100 models, skipping those whose test script has not changed since their | |
| last run. Quantized checkpoints and models that need `trust_remote_code` are | |
| left out. A model that leaves the list keeps the results it already has. | |
| ## Layout | |
| There is one file per tested `(neuronx-cc, library version)` pair: | |
| ``` | |
| data/neuronxcc-<version>/<library>-<version>.parquet | |
| ``` | |
| Each sweep tests the current Neuron SDK with the library version of the day, | |
| so most pairs are never tested. A model missing from a pair was not tested | |
| there, which does not mean it fails. A model the sweep left out has an | |
| `EXCLUDED` row instead, with no `neuron_cores` or `runner`. | |
| | Column | Content | | |
| |---|---| | |
| | `model_id`, `library`, `neuron_cores`, `runner` | The model, the library that loads it, the number of NeuronCores it was sharded over (its tensor- or expert-parallel degree), and the load class (`run_dense`: `AutoModelForCausalLM`, `run_multimodal`: `AutoModelForImageTextToText`, `run_seq2seq`: `AutoModelForSeq2SeqLM`, `run_dense_ep`: expert-parallel, `run_encoder`: the head class the checkpoint declares, or `AutoModel`). | | |
| | `selection_rank` | The model's rank, from 1, in the selection of the latest sweep of the pair, empty if that selection does not hold it. | | |
| | `result`, `notes` | The outcome, and the start of the generated text, of an encoder's prediction or of the error, or why the model was excluded. | | |
| | `exclusion` | The category of the rule that excluded an `EXCLUDED` model, such as `quantized` or `trust-remote-code`. | | |
| | `error` | The full exception message of a `FAIL(load)`, `FAIL(gen)` or `FAIL(forward)` run. | | |
| | `cpu_match` | Runs on one NeuronCore only: `Y` if the tokens, or an encoder's predictions, match a CPU run, `~ near-tie …` if they differ only at a near-tie, `N …` if not. | | |
| | `english` | The judge's verdict, `Y` or `N`, when the CPU comparison did not run. | | |
| | `wall_s`, `hbm_peak_gb`, `hbm_capacity_gb` | Wall time of the run, including compilation, and peak device memory against what its NeuronCores provide. | | |
| | `neuronx_cc`, `library_version`, `transformers`, `accelerate`, `torch_neuronx`, `torch`, `nki`, `python`, `neuron_driver` | The stack the run used. `transformers` is also set for the libraries built on it. | | |
| | `tested_at` | When the run started (UTC). | | |
| | `run_py` | The standalone script that ran. | | |
| ## Querying | |
| ```python | |
| import pandas as pd | |
| df = pd.read_parquet("hf://datasets/aws-neuron/torch-neuronx-model-support/data") | |
| df[df.model_id == "Qwen/Qwen3-0.6B"][["neuronx_cc", "library", "library_version", "neuron_cores", "result"]] | |
| ``` | |
| ## Reproducing a run | |
| Each `run_py` is a standalone script. Its header lists the Neuron stack it ran | |
| on and a `pip install` line for the packages it adds on top. On a Trainium2 | |
| instance with that stack, for example the AWS Neuron Deep Learning Container, | |
| install those packages, then: | |
| ```bash | |
| python3 run.py | |
| ``` | |
| On a `trn2` instance, the run can skip compilation by first copying the | |
| compiled graphs of its compiler, from the public | |
| [NEFF cache](https://huggingface.co/buckets/aws-neuron/torch-neuronx-neff-cache): | |
| ```bash | |
| hf buckets sync hf://buckets/aws-neuron/torch-neuronx-neff-cache/neuronxcc-<neuronx_cc> /tmp/neff_cache | |
| ``` | |
| On more than one NeuronCore, the script launches its own `torch.distributed` | |
| ranks. | |