This document is relevant for: Trn2, Trn3
Configuration options#
Overview#
All Neuron-specific options are passed through additional_config with
two config namespaces:
neuron_config— text model settings (compilation, sampling, quantization, KV cache, scheduling)encoder_neuron_config— multimodal encoder settings (multimodal models only)
from vllm import LLM
llm = LLM(
model="meta-llama/Llama-3.3-70B-Instruct",
max_model_len=4096,
tensor_parallel_size=32,
additional_config={
"neuron_config": {
"num_batched_tokens_buckets": [128, 256, 512, 1024, 2048, 4096],
"num_seqs_buckets": [1, 2, 4, 8],
}
}
)
Or via CLI:
vllm serve meta-llama/Llama-3.3-70B-Instruct \
--tensor-parallel-size 32 \
--additional-config '{"neuron_config": {"num_batched_tokens_buckets": [256, 512, 1024]}}'
Compilation options#
For conceptual overview and trade-offs, see Bucketing and dynamic shapes and Compilation.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
list[int] |
Power-of-2 from 128 to |
Compiled prefill token counts. Inputs padded to nearest bucket. Fewer = faster startup, more padding. Largest must equal |
|
list[int] |
Power-of-2 from 1 to |
Compiled decode batch sizes. Requests batched to smallest bucket >= current size. Largest must equal |
|
list[int] or null |
null (disabled) |
KV segment sizes for segmented attention kernel. Values must be in {512, 1024, 2048, 4096, 8192}, divisible by |
|
list[int] or null |
null (disabled) |
Second decode bucketing dimension. Compiles smaller NEFFs sized to typical context lengths instead of |
KV cache options#
For conceptual overview, see Prefix caching.
Prefix caching is enabled by default and controlled through standard vLLM
parameters (not neuron_config). The options below are vLLM parameters passed
directly to LLM(...) or on the CLI.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
float |
vLLM default |
Applies to default fractional-cap sizing. Explicit headroom mode sets this value to 1.0. |
|
bool |
true |
Reuse KV cache from shared prompt prefixes. On by default; pass |
|
int |
– |
Number of KV cache blocks. More blocks retain more prefixes for reuse. Not nested under |
|
int |
32 |
KV cache block size in tokens. Not nested under |
|
str |
“auto” |
KV cache data type. Set to |
# FP8 KV cache via CLI
vllm serve meta-llama/Llama-3.3-70B-Instruct --kv-cache-dtype fp8
Sampling options#
For conceptual overview, see On-device sampling.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
dict or null |
null (CPU sampling) |
Enable on-device sampling. Supported sub-parameters: |
# Greedy on-device sampling
"on_device_sampling_config": {"all_greedy": True}
# Temperature-based
"on_device_sampling_config": {"temperature": "0.7"}
Scheduling options#
For conceptual overview, see Async scheduling.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
true (enabled) |
Disable async scheduling. Async overlaps CPU work with device execution. Requires on-device sampling. |
Prompt embedding options#
For conceptual overview, see Prompt embeddings.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
false |
Enable passing precomputed embedding tensors instead of token IDs. Not nested under |
vllm serve meta-llama/Llama-3.3-70B-Instruct --enable-prompt-embeds
Multi-LoRA options#
For conceptual overview, see Multi-LoRA.
vLLM Neuron reads the vLLM LoRA arguments. None of them is nested under
neuron_config. For the full LoRA interface of vLLM, see the
vLLM LoRA documentation.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
false |
Enable multi-LoRA. |
|
int |
1 |
Number of adapter slots in HBM, not including slot 0 (the base model). Also the largest number of different adapters in one step. |
|
int |
16 |
Rank of the adapter slot tensors. Must be equal to or larger than the rank of each adapter. Accepted values: 1, 8, 16, 32, 64, 128, 256, 320, 512. |
|
|
– |
Adapters to register at startup. |
|
list[str] |
all LoRA modules |
LoRA modules that get LoRA weights. For Llama: |
|
str |
auto |
Dtype of the LoRA weights. Llama accepts |
vllm serve meta-llama/Llama-3.1-8B \
--tensor-parallel-size 32 \
--enable-lora --max-loras 2 --max-lora-rank 32 \
--lora-modules sql=/path/to/adapters/sql math=/path/to/adapters/math
Quantization options#
For conceptual overview, see Quantization.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
str |
– |
Neuron-specific weight quantization (e.g., |
Warning
Do not set vLLM’s --quantization flag to neuron_quant. Keep it
unset and configure Neuron-specific quantization through neuron_config,
or supply a calibrated checkpoint for FP8 static weight quantization.
Multimodal encoder options (encoder_neuron_config)#
For multimodal models, for example Qwen3-VL and Qwen3-ASR, see Multimodal support.
Option |
Type |
Default |
Description |
|---|---|---|---|
|
list[int] |
null |
Deprecated: set |
|
int |
2048 |
Deprecated: set |
|
list[[int, int]] or null |
auto (vision) |
The encoder graphs to compile, as |
|
int |
– |
Caps the largest auto-generated graph, limiting how many buckets compile. Use it to bound compile time/memory when your workload won’t need the full token ceiling. Do not set it with |
|
int |
1 |
Tensor parallel degree for the encoder. Whichever of |
|
int |
1 |
Data parallel degree for the encoder — encoder blocks are scattered across |
|
int or null |
null (auto) |
Block count for the on-device encoder cache. Auto-derived from the scheduler’s |
|
float or null |
null (auto: 0 monolithic, 100 EPD) |
Minimum time a written cache block stays allocated before it can be freed. Guards against reuse while a remote reader is still pulling the data, which is why EPD defaults to 100 ms and a single-server deployment to 0. |
|
bool |
false |
Split a video that does not fit one encoder graph into shards. Each shard fills the largest graph of the block size that its frames use. Each shard is its own multimodal item, so the scheduler encodes it when prefill reaches it. Set it on a server for long videos. One prefill step then encodes up to ceil(prefill step tokens / shard embeds) shards, one encoder run for each graph, and the encoder cache grows to hold those shards. This uses more HBM. The server logs the resulting values at startup. With segmented prefill, |
For vision models, the platform generates encoder_graph_shapes when the
config sets no graph list and no bucket option. It makes a power-of-2
progression of token buckets from the block size 2048 to a token ceiling from
the serving configuration. Then it converts each bucket to one graph. An
explicit list always takes precedence. Set max_encoder_seq_len to cap the
ceiling and compile fewer graphs. Without max_encoder_seq_len, the ceiling is
the largest attention block size, or less for a small max_model_len.
For Qwen3-ASR, num_blocks counts encoder blocks, and the list takes one
block size. Use the block size 128, which holds one 104-token window produced
from 800 mel frames. At batch size 1, one 30-second clip needs 4 blocks.
num_blocks counts the blocks of all encoder DP ranks, and the encoder pads
it to a multiple of dp_size, so use a multiple of dp_size: [[128, 4]]
up to dp_size 4, and [[128, 8]] at dp_size 8. The transcription endpoint
chunks longer audio automatically. Add a graph with more blocks, for example
[[128, 8], [128, 16]], for larger batches or longer offline input.
To set the vision list yourself, choose each [block_size, num_blocks] pair as
follows. The largest block_size must hold the largest image or video frame, in
pre-merge vision tokens ((H / 16) × (W / 16) for a Qwen3-VL image).
num_blocks counts the blocks of all vision DP ranks, so it must be a multiple
of the vision DP degree. A graph holds block_size × num_blocks pre-merge
tokens.
The scheduler may batch images from multiple requests into one encoder forward pass, so size the graphs for total images processed together. A block of 2048 holds two 448×448 px images (784 tokens each). At vision DP 1:
|
Approximate capacity |
|---|---|
|
1–2 images at 448×448 px |
|
Up to ~8 images |
|
Up to ~20 images |
At a higher vision DP, round each num_blocks up to a multiple of the DP
degree. The graph then holds more images. For example, at vision DP 4,
[[2048, 4], [2048, 12]] holds up to ~24 images.
For details, see Encoder parallelism.
EPD construction roles#
These two flags select which half of a vision-language model an engine builds, and are what split a multimodal deployment into an encoder pool and a prefill+decode pool. See Encoder-disaggregated inference (EPD).
Option |
Where it goes |
Type |
Default |
Description |
|---|---|---|---|---|
|
|
bool |
false |
Build vision-only — the Vision Encoder (VE) pool. The language model is dropped, so no prefill/decode warmup runs. This is an upstream vLLM flag, not a |
|
top level of |
bool |
false |
Build language-only — the Prefill+Decode (PD) pool. The vision tower is dropped, so no encoder warmup runs. Plugin-specific: upstream has no equivalent because its disaggregated-encoder consumer loads the full model and leaves the vision tower unused. |
Important
mm_language_model_only sits at the top level of additional_config, not
inside encoder_neuron_config or neuron_config, and there is no
--mm-language-model-only CLI flag. Nesting it produces no error — the flag is
silently ignored and the engine builds both towers, wasting device memory on a
vision tower it never runs.
# Correct — top level, sibling of neuron_config / encoder_neuron_config.
--additional-config '{"neuron_config": {...}, "encoder_neuron_config": {...}, "mm_language_model_only": true}'
The two are mutually exclusive: a pool is either vision-only or language-only.
Setting both raises ValueError at startup. Leaving both unset is the default
monolithic path, where one engine builds and runs both towers.
Environment variables#
Compilation and caching#
For conceptual overview, see Compilation.
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
str |
– |
Path to cache/load compiled models. Skips recompilation when valid artifacts exist. |
|
bool |
0 |
Enable CPU-only compilation mode (compile NEFFs without Neuron hardware). |
|
str |
– |
Target platform for CPU compile mode (e.g., |
|
int |
1 for each 4 host vCPUs (4 to 128) |
Native backend. The number of compilation service workers, that is, the maximum number of graph compiles that run at the same time. This variable has priority over |
|
int |
– |
The number of graph compiles that run at the same time. Native backend: when |
|
int |
host vCPUs / local ranks |
The number of trace processes that each rank forks to trace its graphs. The number of graphs limits this value. Each trace process adds to the host memory. |
|
str |
– |
Path to NFS/FSx mount for shared persistent cache across nodes. |
|
bool |
0 |
Disable compilation cache entirely. Forces recompilation on every startup. |
|
int |
– |
Timeout in seconds for individual NEFF compilation. |
|
bool |
0 |
Treat cache miss as fatal error. Use when all graphs must be pre-compiled. |
|
str |
|
Root directory for vLLM cache storage. |
|
str |
|
NKI kernel-intermediate cache. |
|
str |
|
NKI kernel trace cache. torch-neuronx enables it with |
What triggers recompilation#
Your compilation cache is invalidated (causing a full recompile on next startup) when any of the following changes:
Neuron SDK version upgrade (
neuronxcc,torch_neuronx, or NKI)Model architecture changes (different model code producing a different FX graph)
Different input shapes (new bucket sizes)
Different compiler flags (e.g., changing
--optimization-level)Different hardware target (e.g., moving from trn2 to trn3)
Different tensor parallel degree
Restarts on the same instance with the same versions will hit the local cache — no recompilation. New nodes with a remote cache configured will fetch from the remote store — also no recompilation.
For full details on cache key composition, see Compilation cache design.
Runtime and execution#
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
0 |
Enable CPU fallback mode (no Neuron hardware needed). For development/testing only. |
|
str |
INFO |
Logging level for vLLM Neuron components. |
|
bool |
0 |
Disable all NKI kernels, forcing torch fallback paths. |
|
bool |
0 |
Build the decode attention mask in PyTorch, in place of the |
|
bool |
0 |
Set the NKI and framework debug flags ( |
|
bool |
unset |
Select the Neuron model runner. Unset uses Model Runner V2 (MRv2), except for the configurations under Configurations that use MRv1, which use Model Runner V1 (MRv1). |
Memory management#
For conceptual overview, see Memory management.
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
float |
0.30 |
Fractional cap for default KV sizing. Explicit headroom bypasses this cap. |
|
float |
unset |
Explicit reserve per worker. Enables headroom sizing on both backends. |
|
float |
1.0 |
Minimum KV budget in GiB. Server fails fast if below. |
When headroom is unset, the worker respects memory
utilization and the fractional cap. An explicit reserve, including zero,
enables headroom sizing. This mode sets gpu_memory_utilization to 1.0
and bypasses the fractional cap.
On a Neuron device, the worker sizes the KV cache from the HBM of one logical NeuronCore. That share is not the HBM of the instance. On Trn2 and Trn3, one HBM stack serves 2 physical cores. At LNC 2, one logical core owns the whole stack. At LNC 1, two logical cores share the stack, so each core plans against half of it. Read the share from the startup log line that reports the logical-core HBM.
For example, 4 GiB is a tested reserve for GPT-OSS 120B on Trn3 with the Native backend and MXFP4 weights. Validate the reserve for your model and configuration.
Both backends use VLLM_NEURON_RESERVED_HEADROOM_GIB.
Each deployment can select a different reserve.
Use the smallest value that passes the validated workload.
Hybrid model KV memory#
A hybrid model has attention and recurrent layers, such as Qwen3.8. On Model
Runner V2, it stores attention K/V in its own buffer, outside the shared KV
cache pool. The pool still reserves a page for each attention block, so
attention memory is about 2x. For Qwen3.8-27B BF16 at TP8, the pool page and
the K/V page are the same size. So the same KV budget holds about half the
blocks. The startup log reports the budget cut in the line Reduce the KV budget from ... for the dense attention pages.
Hybrid model prefix caching and MTP#
On Model Runner V2, a hybrid model serves prefix caching (APC) and MTP
speculative decoding together. Prefix caching uses mamba_cache_mode="align",
which stores the recurrent state at the end of each block. A verify step
writes the state at a block boundary directly to the page of that block. Thus
a block that the decode fills can be reused like a prompt block. This applies to
each MTP width, with synchronous and asynchronous scheduling. MTP needs a
model implementation that keeps a recurrent state for each verified token
(SupportsRecurrentStateCheckpoints). The Qwen3.8-27B values in this section
show the cache geometry of one model. Other
speculative methods, such as EAGLE3 and DFlash, are not supported on a
hybrid model.
By default (--prefix-cache-retention-interval 0), vLLM keeps recurrent
states only at prompt boundaries. A later turn then reuses the prompt of an
earlier turn, but not the blocks that its decode filled. To also reuse those
blocks, for example in a multi-turn chat, pass
--prefix-cache-retention-interval with the block size.
By default, the runner aligns the block so that an attention page holds a recurrent state page. With prefix caching, the block is also a multiple of the recurrent checkpoint alignment of the model. For Qwen3.8-27B at TP8, this block has 512 tokens with prefix caching and 416 tokens without it.
The recurrent checkpoint alignment is the token grid on which the model saves and resumes its recurrent state. A state that the model saves on this grid gives the same output as a cold prefill. For Qwen3.8, the alignment is 128 tokens, the chunk of the Gated DeltaNet prefill kernel. A resume off this grid makes the rest of the prefill use other chunks, so the output drifts from a cold prefill. The drift grows with the number of tokens after the resume.
With prefix caching (--mamba-cache-mode align), each requested value of the
cache geometry must be a multiple of the alignment: --block-size,
--mamba-block-size and --prefix-match-unit. If a value is not a multiple,
the server stops at startup with an error. The runner does not replace the
value. vLLM Neuron makes this check. vLLM also requires each block that prefix
caching keeps to be a multiple of --prefix-match-unit. Without prefix caching, no request resumes from a saved state, so this
limit does not apply. A model that declares no recurrent checkpoint alignment
has no such limit.
The cache keeps the recurrent state at block ends. It also keeps the state at one prefix match unit near the end of each prompt. MTP moves each prefix hit back by one prefix match unit. The default prefix match unit is the block, so with the 512-token block, APC with MTP reuses less of each prompt.
To reuse a prompt in steps of 128 tokens with MTP, pass
--prefix-match-unit 128. The block and the KV capacity do not change. A
decode-filled block is reused when the decode also fills the next block,
because the attention cache keeps full blocks only.
To keep the state at more block ends with MTP, pass a smaller --block-size,
for example 128 or 256. Use a multiple of the alignment. If you also pass
--mamba-block-size, set it to the same value. The block must also be larger
than the number of speculative tokens.
With prefix caching, the runner uses a requested --block-size only if it
keeps that block. If it cannot keep the block, the server stops at startup
with an error that gives the block that the runner needs. The runner keeps
the block in these cases:
With MTP, the block is a multiple of the alignment.
Without MTP, the block holds a recurrent state page. For Qwen3.8-27B at TP8, 512 and 1024 are examples. A smaller block, such as 128, stops the startup.
A requested --mamba-block-size must equal the final block, or the server
stops at startup. vLLM copies the block size into an unset
--mamba-block-size, and the runner cannot tell an explicit value that equals
this copy from an unset value. Thus without --block-size, the runner replaces
--mamba-block-size 16 with the final block, and it gives no error. Without
prefix caching, the runner replaces a requested
block that does not hold a recurrent state page. It then logs a warning that
gives the two blocks.
A block smaller than the aligned block pads its attention page to a full
recurrent state page. An attention token then takes more bytes. The aligned
block pads each recurrent state page to its attention page, and each request
holds G × (3 + K) recurrent state pages, where G is the number of recurrent
cache groups (3 for Qwen3.8-27B). At a short context, the recurrent
state pages are the larger cost. Thus a 256-token block holds more tokens than
the 512-token block at 8K. At a long context, the attention pages are the
larger cost, so a smaller block holds fewer tokens. The server logs a warning
at startup when it keeps a block that is smaller than the aligned block.
The table gives KV tokens for each GiB of the KV budget for Qwen3.8-27B BF16
at TP8, with prefix caching and MTP (K=4). The budget includes the pool and
the dense K/V pages. The values come from the cache geometry, without a
device. To compute them again, run pytest -k capacity test/vllm_neuron/vllm/worker/test_neuron_model_runner_v2_recurrent_checkpoint_grid.py
with VLLM_NEURON_CPU_MODE=1. The test computes each value from the real cache
specification of the model, and it checks the value:
Context length |
512-token block (default) |
256-token block |
128-token block |
|---|---|---|---|
8,192 |
13,740 |
14,723 |
11,442 |
32,768 |
23,924 |
20,949 |
14,045 |
131,072 |
29,366 |
23,425 |
14,892 |
262,144 |
30,523 |
23,896 |
15,043 |
With prefix caching, the 512-token default holds fewer tokens than the earlier 416-token block, which was not on the checkpoint grid. With MTP (K=4), the loss is 10% at 8K, 4% at 32K, 1% at 128K and 0.6% at 256K. Without MTP, it is 6% at 8K, 2% at 32K, and less than 0.5% at 128K and 256K. The loss is largest at short contexts with MTP, because each request holds G × (3 + K) recurrent state pages. Without prefix caching, the block and the KV capacity do not change.
Choose the geometry for the workload:
For requests that share prompts, keep the default block and pass
--prefix-match-unit 128.For requests that resend earlier turns at short or medium context lengths, pass
--block-size 128or--block-size 256to reuse more decode-filled tokens with MTP.For long contexts or many concurrent requests, remove
--block-sizeto keep the aligned block and its KV capacity.
Multi-LoRA#
For conceptual overview, see Adapter file staging and environment variables.
These variables control a host-memory copy of each adapter file that vLLM
Neuron makes for its tensor-parallel workers. They are not related to
VLLM_LORA_RESOLVER_CACHE_DIR, the directory where the vLLM filesystem
resolver finds adapters.
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
str |
|
Host-memory directory for the staged copy of each adapter file. Set |
|
int |
64 |
Maximum number of staged adapter files. The least recently used files are removed first. |
|
float |
16 |
Maximum total size of the staged adapter files, in GB. The files count against the memory limit of the container. |
Metrics#
Variable |
Type |
Default |
Description |
|---|---|---|---|
|
str |
auto-created tempdir |
Directory for prometheus_client multiprocess mode. Wipe between server restarts. |
Complete configuration example#
from vllm import LLM, SamplingParams
llm = LLM(
model="meta-llama/Llama-3.3-70B-Instruct",
max_model_len=4096,
max_num_seqs=8,
tensor_parallel_size=32,
block_size=128,
kv_cache_dtype="fp8",
enable_prompt_embeds=True,
additional_config={
"neuron_config": {
# Compilation buckets
"num_seqs_buckets": [1, 2, 4, 8],
# Segmented prefill buckets
"kv_segment_size_buckets": [2048],
"num_batched_tokens_buckets": [2048],
# On-device sampling (required for async scheduling)
"on_device_sampling_config": {
"all_greedy": True
},
}
}
)
prompts = ["What is machine learning?"]
sampling_params = SamplingParams(max_tokens=100, temperature=0.0)
outputs = llm.generate(prompts, sampling_params)
Equivalent CLI:
export NEURON_COMPILED_ARTIFACTS=/opt/neuron-cache/llama-70b
export NEURON_LIBTORCH_PARALLEL_COMPILE_WORKERS=4
vllm serve meta-llama/Llama-3.3-70B-Instruct \
--max-model-len 4096 \
--max-num-seqs 8 \
--tensor-parallel-size 32 \
--block-size 128 \
--kv-cache-dtype fp8 \
--enable-prompt-embeds \
--additional-config '{
"neuron_config": {
"num_seqs_buckets": [1, 2, 4, 8],
"kv_segment_size_buckets": [2048],
"num_batched_tokens_buckets": [2048],
"on_device_sampling_config": {"all_greedy": true}
}
}' \
--port 8000
Configuration tips#
Startup time vs flexibility trade-off#
Fewer buckets = faster startup, but less flexibility
More buckets = slower startup, but handles more scenarios efficiently
Recommended approach:
Start with minimal configuration (single bucket) during development
Profile your workload to understand prompt length distribution
Add buckets matching your 25th, 50th, 75th, and 95th percentile lengths
Remove unused buckets to speed up startup
Memory considerations#
Each compiled bucket consumes device memory
Monitor memory usage when adding many buckets
KV cache FP8 halves cache footprint but requires calibrated scales
Default sizing respects memory utilization and a 30% fractional cap
An explicit headroom value enables the reserve policy
In headroom mode, increase the reserve after an HBM allocation failure
A cold compile uses host memory for each graph that compiles at the same time. For large models, set
NEURON_COMPILE_SERVICE_WORKERSfrom the host memory (see Host out of memory during a cold compile)A hybrid model holds about half the KV blocks of the same budget, because attention K/V has its own buffer outside the pool
Async scheduling guidance#
Keep async scheduling enabled (default) for production workloads
Disable only for debugging or when CPU sampling is required
Longer responses benefit more from async scheduling
Smaller models see larger relative speedups from async overlap
Prefix caching constraints#
kv_segment_size_bucketsandnum_batched_tokens_bucketsmust currently be identical (kernel constraint)Only a single segment size is supported at this time
Block size must divide evenly into the segment size
Troubleshooting#
“Request exceeds largest bucket” error#
Your input exceeds the largest num_batched_tokens_buckets value.
Either add a larger bucket or reduce your input length.
Compilation during inference#
If you see compilation messages after warmup, you have inputs that do not match any configured bucket. Check your bucket configuration covers your actual workload.
“Only support greedy sampling” error#
Currently, on-device sampling only supports temperature=0. For
non-greedy sampling, remove on_device_sampling_config to use CPU
sampling.
HBM allocation errors during load or compilation#
Check the active budget policy when logs contain an HBM allocation signature:
NCC_EOOM002orMaximum peak HBM usageNRT_RESOURCEinnrt_load_utilnrt_tensor_allocate status=4Allocation Failurewhile loading a model
The KV cache can leave too little HBM for code, scratch, internal tensors,
or communication buffers. In default mode, reduce
VLLM_NEURON_KV_GMU_BUDGET_CAP_FRACTION to reduce the KV budget.
In explicit headroom mode, increase the active reserve from its logged value. For a deployment that currently reserves 4 GiB, the next step is:
export VLLM_NEURON_RESERVED_HEADROOM_GIB=5
Start with 1 GiB increments and rerun the same model, sharding, backend, and
hardware configuration. Each additional 1 GiB of headroom reduces the KV cache
budget by 1 GiB. Keep the smallest value that passes. If more headroom would
leave too little KV cache, reduce max_model_len or max_num_seqs.
Host out of memory during a cold compile#
When the compile cache is empty, the server compiles all bucket graphs before
it serves requests. On the native backend, the compilation service runs up to
NEURON_COMPILE_SERVICE_WORKERS compiles at the same time. Each compile is a
separate neuronx-cc process. When you do not set a value, the service starts
one worker for each 4 host vCPUs, with a minimum of 4 and a maximum of 128. For
example, a 192-vCPU host gets 48 workers. This default does not use the host
memory.
When a model has as many bucket graphs as workers, or more, all workers
compile at the same time. For a large model, one neuronx-cc process can use
tens of GiB of host memory. The total can be more than the memory of the host
or of the container. The operating system then stops the server (OOM kill).
Before the compile, each rank also forks trace processes. Each rank forks one trace process for each graph, up to its usable vCPUs divided by the number of ranks on the host. These processes also use host memory.
To limit the host memory of the compile, set the worker count before you start the server:
export NEURON_COMPILE_SERVICE_WORKERS=8
To select the value:
Measure the peak resident memory (RSS) of one
neuronx-ccprocess for your model, for example withps -C neuronx-cc -o rss=,args=during a compile.Divide the host memory that the server can use (the container limit, if there is one) by that peak.
Make the result smaller to keep memory for the server, the model weights and the trace processes. Do not use a value less than 1.
A smaller value increases the compile time only when the model has more graphs
than workers. To also decrease the memory of the trace processes, set
NEURON_LIBTORCH_PARALLEL_TRACE_WORKERS.
To compile only one time, save the compiled artifacts and use them when the server starts again. See How to precompile and cache.
NCC_EVRF059 compiler error#
The compiler cannot find NKI kernel JSON files that a saved graph references by absolute path. The cache is stale, not the compiler. A complete graph-cache hit returns the NEFF and does not run the compiler, so it cannot cause this error. The error occurs when the graph cache holds an uncompiled graph.hlo and a later parallel_compile compiles it, but the NKI files from the first run are gone. This happens when the NKI cache and the graph cache were persisted separately (for example, a container-local NKI_COMPILE_CACHE_URL that a restart deleted while the graph cache stayed). On the native backend the compile is asynchronous, so the symptom is No NEFF persistent key for cache_key=... instead. Solutions:
Keep both caches on one persistent mount. By default, both are under
<cache_root>/neuron/, where<cache_root>is$NEURON_LIBTORCH_CACHE_ROOT, else$VLLM_CACHE_ROOT. If you setNKI_COMPILE_CACHE_URL, point it below that mounted root.To recover immediately, clear the graph cache for your backend to force a re-trace:
XLA:
<cache_root>/neuron/compile_cache.Native:
$TORCH_NEURONX_NEFF_CACHE_DIRif set, else<cache_root>/neuron/native_neff_cache.
Out-of-bound access on the device#
The device found a DMA access outside the bounds of a tensor. The request fails with nrta status=1006, and the runtime log holds a TDRV:oob_debug_log_source_info block for each core:
scatter/gather (indirect memory copy via vector DGE) out-of-bound access
model=<neff path>
nd0:nc4 neff_idx=7 subgraph=0 engine=GPSIMD
Source location: /path/to/my_kernel.py:47
No stack trace found for neff_idx=7
IR trace:
[backend] I-1_inst__I-9-0
Use the fields in this sequence:
Read
Source location. It gives the file and the line of the instruction that made the access. For an NKI kernel, it is the line of thenisa.dma_copycall in the kernel.Read
neff_idx. It is the instruction index (PC) in the NEFF. Use it to find the instruction in a profile.Read
Python stack traceandIR trace, if they are in the block. They give the framework call site and the HLO instruction.
To set the NKI and framework debug flags, set the switch before you start vLLM:
export NEURON_LIBTORCH_OOB_DEBUG=1
libtorch_neuronx_lite owns the switch, so each framework that uses lite can use it. The switch sets NKI_DEBUG_INFO, XLA_IR_DEBUG and XLA_HLO_DEBUG when lite is imported. A flag that you set yourself keeps its value. Each worker process imports lite before the first compile, so each worker gets the flags. NKI_DEBUG_INFO changes the NKI cache key, so the first start after you set the switch compiles the NKI kernels again.
With the current compiler, the OOB block is the same with the switch on and off. The compiler writes the PC, the source location and the IR trace without the flags. With the switch on, NKI also writes the kernel debug info (a .debuginfo.json file in the NKI cache).
The debug info increases the NEFF load time. The runtime reads the debug info of each NEFF when it loads the NEFF. The increase depends on the model. For Qwen/Qwen3-0.6B at TP 1 on Trn3, the measured load times were:
Route |
Debug info off ( |
Default |
|
|---|---|---|---|
native |
3370 ms |
3881 ms (+15%) |
3906 ms (+16%) |
XLA |
7732 ms |
8714 ms (+13%) |
8867 ms (+15%) |
The compiler writes most of the debug info by default, so the default load time already includes most of the increase. The increase can be much larger for other models, so the switch is off by default.
To make the load faster, set NEURON_RT_DISABLE_DEBUG_INFO=1. The runtime then does not read the debug info, and an OOB block has no Source location:
No debug info available for this model; cannot resolve source location.
The data in the block depends on the source of the access:
Source of the access |
Route |
|
|
|
HLO name in |
|---|---|---|---|---|---|
NKI kernel |
XLA and native |
Yes |
Kernel line |
No |
No |
PyTorch operation, for example |
XLA |
Yes |
Model line |
Yes |
Yes |
PyTorch operation, for example |
native |
Yes |
Model line |
No |
Yes |
For an NKI kernel, the compiler does not connect the kernel instructions to the HLO debug info. The native route does not write Python stack frames into the NEFF.
“KV cache budget below minimum threshold” error#
The computed KV budget is less than VLLM_NEURON_MIN_KV_BUDGET_GIB
(default 1.0 GiB). In default mode, increase gpu_memory_utilization or
VLLM_NEURON_KV_GMU_BUDGET_CAP_FRACTION and validate the configuration. The
error gives that advice only when it carries no cause line. See “Zero free HBM”
below for the error that carries a cause line.
In explicit headroom mode, the worker computes:
CPU:
available = max(host_available / local_workers - headroom_bytes, 0)
Neuron:
available = max(
logical_core_hbm - model_weight_bytes - encoder_cache_bytes
- headroom_bytes, 0)
CPU host available memory already reflects loaded weights and current allocations.
logical_core_hbm is the HBM of one logical NeuronCore. It is not the HBM of
the instance, and it is not the HBM of one stack. At LNC 1 on Trn2 and Trn3,
two logical cores share one HBM stack, so this figure is half of a stack. A
Trn2 core at LNC 1 plans against 12 GiB, and not against the 24 GiB of the
stack. A Trn3 core at LNC 1 plans against 18 GiB. At LNC 2, one logical core
owns the whole stack. Read the figure from the startup log line that reports
the logical-core HBM. Do not calculate it from the HBM of the instance.
encoder_cache_bytes is the on-device encoder cache of a multimodal model.
It is zero for a text-only model.
headroom_bytes comes from VLLM_NEURON_RESERVED_HEADROOM_GIB.
The error reports this variable and max_headroom_gib, which is the largest
headroom that satisfies the configured minimum:
min_kv_bytes = int(VLLM_NEURON_MIN_KV_BUDGET_GIB * 1024 ** 3)
memory_before_headroom_bytes = max(
logical_core_hbm - model_weight_bytes - encoder_cache_bytes, 0)
max_headroom_gib = (memory_before_headroom_bytes - min_kv_bytes) / 1024 ** 3
The worker converts the minimum to bytes first, so it subtracts bytes from
bytes. It converts only the result to GiB. It prints max_headroom_gib when
the value is zero or more. A negative value means that no headroom satisfies
the minimum. The error then states instead: No headroom value can raise the KV cache budget to the minimum.
For example, a Trn2 core at LNC 1 holds 4 GiB of weights and no encoder cache.
It keeps the default minimum of 1 GiB. max_headroom_gib is then
12 - 4 - 0 - 1 = 7. A reader who sizes against the whole 24 GiB stack
instead computes 19. A headroom of 19 leaves no KV cache, and the server
fails again with the same error.
Do not increase headroom for this error: increasing it makes the KV cache
budget smaller. Decrease the active headroom variable, or lower
VLLM_NEURON_MIN_KV_BUDGET_GIB only when a smaller KV cache is valid for the
workload.
Zero free HBM#
On a Neuron device, the error can carry a cause line. The runtime then reports zero free HBM with used HBM above zero. The allocations of this core reach or pass its HBM share, so the budget is zero. The cause line is:
Cause: the Neuron runtime reports zero free HBM, and the used HBM is above zero. The allocations of this core reach or pass its HBM share, so no HBM is left for the KV cache. A larger memory utilization value cannot add HBM. Raise the tensor-parallel degree to make the device footprint smaller.
The cause line owns the corrective actions, so the error drops the generic advice of the active policy:
In default mode, the error prints
KV budget = 0.It does not ask you to raisegpu_memory_utilizationorVLLM_NEURON_KV_GMU_BUDGET_CAP_FRACTION, because neither value can add HBM to the core.In headroom mode, the error prints
KV budget = max(0, 0).It repeats that you must not increase the headroom. It reports no headroom ceiling. It states instead:No headroom value can raise the KV cache budget to the minimum.
Reduce the device footprint with a larger tensor-parallel degree.
A report of zero used HBM with zero free HBM is a different state. Those figures describe no logical core, so the worker rejects them with a separate error. See determine_available_memory design for that message.
Async scheduling not engaging#
Async scheduling requires:
On-device sampling enabled (
on_device_sampling_configset)--no-async-schedulingNOT passedConsecutive decode steps with unchanged batch composition
Check logs for “batch composition changed” if you see frequent sync fallbacks.