Trainium host (trn2)¶
Stock vllm-neuron 0.29.0.1.2.0 can't run Qwen3-ASR well: TP1 fails to
compile at batch sizes of 2 or more, and LNC=1 doesn't work. This host uses
jimburtoft/vllm-neuron qwen3-asr/0.29-champion
and its companion nki-library branch, built into an image on top of AWS's
Neuron SDK 2.33 vLLM image, the same base the fork was tested in.
| Component | Version |
|---|---|
| Neuron SDK | 2.33 |
| vLLM | 0.29.0 |
| neuronx-cc | 2.28.7631 |
| nki | 0.7.0 |
| Base image | public.ecr.aws/neuron/pytorch-inference-vllm-neuronx:0.29.0.1.2.0-neuronx-py314-sdk2.33.0-ubuntu26.04, pinned by digest in deploy/trn2/Dockerfile |
The host only needs the Neuron driver, Docker and neuron-monitor (for the
sidecar). The DLAMI's own vLLM install isn't used.
Quick install¶
First build the trn2 image into an ECR repository in your account and point
deploy/trn2/trn2.local.env at it (step 2). Then
connect with SSM (the trn2 host's region, ap-southeast-4 by default), run
sudo -iu ec2-user, and with the code in ~/snap-asr-bench
(Deploy code via S3):
cd ~/snap-asr-bench
sudo dnf install -y make # if missing
make install-trn2
journalctl -u vllm -f # each start compiles for about 10 minutes
This does steps 2 and 3 below, then installs the log sidecar.
It reads the image, registry and region from IMAGE in trn2.local.env
(or trn2.env), and stops if IMAGE is still the placeholder.
1. Check the driver and Docker¶
neuron-ls
docker info
If Docker is missing:
sudo dnf install -y docker
sudo systemctl enable --now docker
sudo usermod -aG docker ec2-user # then log out and back in
2. Pull the image¶
The image is built from deploy/trn2/Dockerfile into an ECR repository in
your account, in the trn2 host's region. Build and push it from any x86-64
machine with make image-push-trn2 REGISTRY=<account-id>.dkr.ecr.<region>.amazonaws.com,
or follow Container images. Its tag names the fork and
nki-library commits, for example trn2-8533ceb-90dc412-audio.
IMAGE in trn2.env is a placeholder. Put the real name in
deploy/trn2/trn2.local.env, which overrides it:
echo 'IMAGE=<account-id>.dkr.ecr.<region>.amazonaws.com/snap-vllm-neuron:trn2-8533ceb-90dc412-audio' > ~/snap-asr-bench/deploy/trn2/trn2.local.env
The instance role's ecr-trn2-image policy (terraform/iam.tf) allows pull
and push on that repository only. Its name is the trn_ecr_repository
variable, snap-vllm-neuron by default. Then pull it:
sudo mkdir -p /opt/snap-asr-bench/{hf-cache,champion-cache,neuron-compile-cache} /etc/snap-asr-bench
sudo chown -R ec2-user: /opt/snap-asr-bench
IMAGE="$(cat ~/snap-asr-bench/deploy/trn2/trn2.env ~/snap-asr-bench/deploy/trn2/trn2.local.env | sed -n 's/^IMAGE=//p' | tail -1)"
aws ecr get-login-password --region "$(echo "$IMAGE" | cut -d. -f4)" | docker login --username AWS --password-stdin "${IMAGE%%/*}"
docker pull "$IMAGE"
How the image is built¶
deploy/trn2/Dockerfile clones the fork and nki-library at pinned commits
(VLLM_NEURON_SHA, NKI_LIBRARY_SHA) and adds soundfile and av, which
the base image lacks. Without them every transcription returns 400
Invalid or unsupported audio file. The -audio tag suffix marks images
that have them.
entrypoint.sh sources the fork's setup_champion.sh, which points
PYTHONPATH at the clones and checks the fork's kernels are the ones that
load. It then logs both commit hashes, so they appear in each run's JSONL.
To rebuild with other commits, see Container images, then
update IMAGE in trn2.local.env.
3. Install the service¶
cd ~/snap-asr-bench
sudo install -m 0755 deploy/trn2/start-vllm.sh /opt/snap-asr-bench/start-vllm.sh
cat deploy/trn2/trn2.env deploy/trn2/trn2.local.env | sudo tee /etc/snap-asr-bench/vllm.env >/dev/null
sudo install -m 0644 deploy/systemd/vllm.service /etc/systemd/system/vllm.service
sudo install -D -m 0644 deploy/systemd/journald-snap-asr-bench.conf /etc/systemd/journald.conf.d/snap-asr-bench.conf
sudo systemctl restart systemd-journald
sudo systemctl daemon-reload
sudo systemctl enable --now vllm
The journald drop-in caps the journal at 2 days and 2 GB, so each run's
replay of vLLM's journal (--journal-from service-start) stays short.
Start-up lines older than that are dropped; the sidecar's /health
records what the server runs instead.
start-vllm.sh passes every /dev/neuron* device into the container and
mounts three caches from /opt/snap-asr-bench: hf-cache (weights),
champion-cache (NKI and vLLM caches) and neuron-compile-cache
(neuronx-cc). A start compiles every bucket, so the unit has
TimeoutStartSec=infinity and the env file sets
VLLM_ENGINE_READY_TIMEOUT_S=3600. The caches are meant to make later starts
quicker, but so far every start has recompiled for about 520 s
(Limitations).
When the model loads¶
There's no separate step to load the model: starting vllm.service does it.
start-vllm.shreadsMODELfrom/etc/snap-asr-bench/vllm.env(Qwen/Qwen3-ASR-1.7B) and passes it to the container. The entrypoint sets up the fork, then runsvllm serve <MODEL>.- Hugging Face, every start: vLLM checks the Hugging Face Hub for the
latest revision of the model. On the first start it also downloads the
weights into
/opt/snap-asr-bench/hf-cache(4.4 GB for 1.7B). The model is public, so no token is needed. The model isn't pinned to a revision, so a change upstream is picked up at the next restart. See Network dependencies. - Every start: the fork compiles the model for every bucket in
VLLM_ADDITIONAL_CONFIG, loads it onto the Neuron cores for each of the four DP ranks, and warms up. Plan for about 10 minutes after any restart. - The server is ready when
curl -s localhost:8000/v1/modelslists the model (Check). Even then, the first requests with a new chunk length are slow (Limitations), so benchmark with a warm-up phase.
To serve a different model, see Switch model.
Configuration¶
trn2.env uses the fork's documented 1.7B throughput setup: LNC=2,
TP1 × DP4, max-num-seqs 48, max-model-len 1024, prefill buckets
[128, 256, 416, 512, 1024] and decode_context_length_buckets [512].
It adds one setting the fork doesn't document for ASR,
encoder_cache_num_blocks: 1025. The fork's default on-device encoder cache
is 9 blocks of 128 tokens, but vLLM's scheduler admits audio by token count
and every chunk takes a whole block. With 2 s chunks (26 tokens each) the
cache filled after about 8 chunks and the engine died with Encoder cache
full. 1025 blocks (one per token of the 1024-token budget, plus a scratch
block) can't overflow, and cost about 512 MiB of HBM per DP rank.
By the fork's estimate, a prompt is about 13 + 13 × seconds tokens, which
sets the prefill bucket each request uses:
| Audio per request | Prompt tokens | Prefill bucket |
|---|---|---|
| 1 s | ~26 | 128 |
| 5 s | ~78 | 128 |
| 10 s | ~143 | 256 |
30 s (default growing cap) |
~403 | 416 |
With --max-model-len 1024, keep --max-window-seconds at or below about
60 s to leave room for output tokens.
Throughput or latency layout
At --concurrency 1 the client sends one stream, so a single request
uses one of the four DP replicas. Use --concurrency of 4 or more to
load every replica. The fork measures single-stream latency with TP4
instead. See Limitations.
Check¶
curl -s localhost:8000/v1/models | jq -r '.data[].id'