This document is relevant for: Inf1, Inf2, Trn1, Trn2, Trn3
Tutorial: Port a GPU-compatible model to vLLM Neuron using the Autoport skill#
This tutorial walks you through porting a GPU-compatible transformer model to the vLLM Neuron backend on Trn2 using the Autoport vLLM Neuron agent. You provide a model name and a source model ID, invoke the agent, and the agent handles the rest: architecture research, code generation, model registration, and validation.
By the end of this tutorial you will have a model registered with vLLM Neuron that serves through the vLLM OpenAI API server and passes logit and equivalence validation against the GPU-compatible reference implementation.
Note
This tutorial ports a model to the vLLM Neuron serving backend, the supported inference stack on Trn2 and Trn3. For background on the skill, see the Autoport vLLM Neuron deep dive. The earlier NxD Inference variant of this tutorial is archived (legacy); see Tutorial: Port a HuggingFace model to NxD Inference using the Autoport skill (archived).
Prerequisites#
Set up a Trainium instance#
This tutorial uses a trn2.48xlarge instance. vLLM Neuron also runs on Trn3
instances; the tensor parallel sizes in this tutorial are for trn2.48xlarge.
Launch the instance from the Neuron Deep Learning AMI (DLAMI) and SSH in.
Verify that Neuron devices are available.
neuron-ls
If you see 0 devices, your instance does not have Neuron hardware attached or the driver is not loaded. Stop here and fix that first.
Install Neuron Agentic Development#
If you have not already installed the package, follow the Getting Started guide.
Make sure the deploy step completed.
# For Claude Code
deploy-neuron-agentic-development-to-claude
# For Kiro
deploy-neuron-agentic-development-to-kiro
Activate your Python environment#
source /opt/aws_neuronx_venv_pytorch_inference_vllm_<version>/bin/activate
Verify the vLLM Neuron package#
The skill needs the vllm_neuron (or private_vllm_neuron) package in your
workspace. If it is not present, the agent stops without porting.
python3 -c "import vllm_neuron; print(vllm_neuron.__file__)"
Download your model weights#
Download the model that you want to port. For this example, use a small model to keep compilation and validation fast.
huggingface-cli download 01-ai/Yi-6B-Chat --local-dir ~/models/yi-6b-chat
Step 1. Choose your model name and ID#
The Autoport vLLM Neuron agent needs two values: a short snake_case name for the port and the source model ID.
Argument |
What it is |
Example value |
|---|---|---|
|
The snake_case name for your port. Becomes the directory under
|
|
|
The source model identifier. |
|
The agent derives the PascalCase class prefix from your model name (yi becomes
Yi). Pick a name that matches the convention of the existing models in
vllm_neuron/model/ (for example, llama3, qwen3_moe, deepseek_v2).
Step 2. Invoke the Autoport agent#
Open your agentic IDE (Claude Code or Kiro) on the Trainium instance.
Invoke the skill with your model name and source model ID.
Port the model yi from 01-ai/Yi-6B-Chat to vLLM Neuron.
The agent confirms the inputs and starts working. You do not need to do anything else.
If you want to review the agent’s architecture decisions before it writes any model
code, add the --review flag. The agent pauses after the architecture analysis
(Step 3 below) and waits for your confirmation.
Port the model yi from 01-ai/Yi-6B-Chat to vLLM Neuron with --review.
If you want a dry run (research and code generation only, no hardware), add
dry-run to your request.
Step 3. What happens during the port#
The agent works through three phases. Here is what you will see.
Phase A: Research and analysis. The agent fetches the source model config, reads
the modeling source, inspects the checkpoint weight keys, and computes valid tensor
parallel sizes. It then picks the closest existing vLLM Neuron model as a reference
(for Yi, a standard GQA + RoPE model, this is llama3/) and prints an architecture
analysis table comparing the two. If you passed --review, it pauses here.
Phase B: Code generation. The agent generates the model package under
vllm_neuron/model/yi/ (config.py, factory.py, __init__.py, and
model.py), registers the model in vllm_neuron/model/registry.py, and creates
an example run script and a model README. You can watch the code appear in real time.
Phase C: Validation. The agent runs four validation steps in order, then two more when the architecture supports them.
Smoke test. Offline inference through the example script. The agent checks that weights load, the model compiles, and the generated text is coherent.
Online serving. The agent starts the vLLM OpenAI API server and runs completion, batch, streaming, and counting tests, then re-runs them with prefix caching.
Logit validation. The agent compares Neuron logits against a CPU reference implementation and reports sigma values across top-k levels.
Deep equivalence validation. The agent invokes the Equivalence skill with the vLLM Neuron adapter for component-level and end-to-end verification.
Disaggregated inference (DI). If the architecture’s KV layout allows it, the agent generates DI launch scripts and validates the port with separate prefill and decode servers, reusing the logit test’s reference and tolerances.
Speculative decoding. If the architecture supports it, the agent validates the port as a speculative-decoding target and checks that greedy output matches a non-speculative control.
An architecture that cannot run DI or speculation is recorded as unsupported with the reason, and that step is skipped.
Step 4. Check the results#
When the agent finishes, you will have these outputs.
vllm_neuron/model/yi/
├── __init__.py
├── config.py
├── factory.py
├── model.py # The ported implementation
└── README.md # Architecture and feature status
vllm_neuron/model/registry.py # Modified: yi registered
examples/vllm_neuron/models/yi/
├── run.py
├── results/results.md # Offline, online, DI, and spec results
├── di/ # DI-supported models only
└── spec/ # Spec-supported models only
test/vllm_neuron/model/yi/bf16/e2e/
├── test_logits.py # Logit validation test
├── test_logits_di.py # DI logit validation (DI-supported models only)
└── test_spec_*.py # Spec validation (spec-supported models only)
The model in vllm_neuron/model/yi/ is the final product, and the registry entry
makes it available to vLLM. Review results/results.md for the inference and
serving numbers, and the README for the feature status table.
Step 5. Serve your model#
Once the port is registered and validated, serve it through the vLLM OpenAI API server.
NEURON_SKIP_EFA_AFFINITY=1 python3 -m vllm.entrypoints.openai.api_server \
--model 01-ai/Yi-6B-Chat \
--tensor-parallel-size 8 \
--max-model-len 256
Send a test completion.
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{"model": "01-ai/Yi-6B-Chat", "prompt": "The capital of France is", "max_tokens": 16}'
Use the tensor parallel size that the agent recommended in Phase A. See Quickstart: Launch an OpenAI-compatible API server with vLLM Neuron and Configuration options for the full set of serving options.
Step 6. Serve your model disaggregated (optional)#
If the agent generated a di/ directory, you can serve the port with separate prefill
and decode servers on one instance. Start each server in its own terminal, then the proxy.
Prefill and decode each take their own window of cores, so the two servers together need
2 × TP cores.
cd examples/vllm_neuron/models/yi/di
ROLE=prefill ./run_di_server.sh # terminal 1
ROLE=decode ./run_di_server.sh # terminal 2
./run_di_proxy.sh # terminal 3, sends one completion and stays up
The proxy prints the completion it receives through the prefill-to-decode path. If the
agent generated a spec/ directory, spec/run_spec_server.sh serves the same port with
speculative decoding; run it with SPEC=0 to get the non-speculative control with
identical flags.
For multi-node DI, the topology rules, and the failure triage table, see the deep dive.
Troubleshooting#
The agent handles most issues automatically, but here are things that might require your input.
Agent stops because it cannot find vllm_neuron. The vllm_neuron or
private_vllm_neuron package must be present in your workspace. Confirm with
python3 -c "import vllm_neuron" and check that your virtual environment is
activated.
Out of memory during weight loading or warmup (nrt_tensor_allocate
status=4). The model does not fit at the chosen tensor parallel size. Ask the agent
to increase the TP size. MoE models are especially memory-hungry and may need expert
parallelism.
Degenerate output (repeated tokens). This usually points to a decode path bug (bias shape, KV cache, or normalization). The agent diagnoses this by testing prefill only first, then debugging the decode path.
Logit validation reports high sigma. This is not a hard failure. The agent reports the sigma values and which top-k levels diverged and continues to completion. Decide whether the accuracy is acceptable for your use case, and consult the equivalence report for component-level detail.
DI output is wrong but each server works alone. Colocated DI needs
FI_EFA_ENABLE_SHM_TRANSFER=0. run_di_server.sh sets it for you; if you launch the
servers another way, export it yourself or single-node DI can return silently wrong output.
Decode hangs waiting for remote KV. Each engine needs its own side-channel port and a unique engine ID, and the core windows of the two servers must not overlap.
No EFA device found. PCI topology mismatch on trn2. The agent runs with
NEURON_SKIP_EFA_AFFINITY=1, which is safe for single-node tensor parallelism.
No NeuronCores detected. Run neuron-ls. If it shows 0 devices, your instance
either does not have Neuron hardware or the driver is not loaded. Check that
aws-neuronx-dkms is installed.