This document is relevant for: Trn2, Trn3

Reference: SGLang-Neuron configuration#

Note

SGLang-Neuron is in public preview. Features, APIs, and supported models can change in later releases.

Applies to#

SGLang-Neuron 0.1.0 in the container image public.ecr.aws/neuron/pytorch-inference-sglang-neuron:v0.1.0-neuron-py314-sdk-2.33.0-ubuntu26.04.

Overview#

You configure an SGLang-Neuron server with the standard SGLang server flags. The plug-in also reads environment variables for settings that SGLang has no flag for. This page lists the container options, the variables of the example scripts, and the environment variables that most deployments use.

The plug-in refuses any unknown SGLANG_NEURON_* name in the launch environment, so a misspelled variable stops the launch. The plug-in also sets some variables itself for every process, and it refuses a launch that sets a different value for them. For the full list, including the debug and test variables, see the configuration reference in the sglang-neuron repository.

Container options#

A server container takes these docker run options:

Option

Description

--device /dev/neuron<N>

Passes each Neuron device to the container. Set DEVICES=$(for d in /dev/neuron*; do printf -- '--device %s ' "$d"; done) in bash, and pass $DEVICES.

--init

Reaps the worker processes of the server.

--ipc=host

Gives the SGLang processes the shared memory that they use to exchange tensors. The default Docker /dev/shm is 64 MB.

--cap-add SYS_NICE

Lets the NUMA library and NIXL place memory. Without it, NIXL cannot map its network rails to NUMA nodes.

-v <models dir>:/models:ro

Mounts the checkpoints. Put each checkpoint in its own directory, such as <models dir>/Qwen3-8B.

-v <cache dir>:/cache

Mounts the compile cache. Use the same path every time, and use one directory for each image version and node role.

-p 127.0.0.1:30000:30000

One-node servers only. Publishes the server port on the loopback address of the host. For a client on a different computer, forward the port over SSH (ssh -L 30000:127.0.0.1:30000 <host>).

-e HF_HUB_OFFLINE=1

On a host without internet access. Keep the checkpoints and the tokenizer files under the models directory.

A server of a prefill-decode (PD) pair also takes these options:

Option

Description

--device /dev/infiniband/uverbs<N>

Passes each EFA device to the container. Add /dev/infiniband/uverbs* to the DEVICES loop.

--network host

Uses the network of the node. -p does not apply. Give each server the address of the node that the other node and the balancer reach.

--cap-add IPC_LOCK and --ulimit memlock=-1

Let NIXL lock memory for the KV transfer over EFA.

Do not mount a volume at /workspace, and do not start processes from /workspace. The Neuron SDK container installs torch-neuronx from /workspace/torch_neuronx.

Compile cache variables#

Set these variables in the container to keep the compiled programs in the mounted cache directory. The example scripts set them from CACHE_DIR.

Variable

Value

TORCH_NEURONX_NEFF_CACHE_DIR

/cache/neff

TORCH_NEURONX_HLO_CACHE_DIR

/cache/hlo

NKI_COMPILE_CACHE_URL

/cache/nki

Example script variables#

The example scripts at /opt/sglang-neuron/examples/<folder>/ read these variables. The README of each example gives the defaults for its model.

Variable

Script

Description

HOST

run_prefill.sh, run_decode.sh

Required. An address of this node that the other node and the balancer reach.

HOST

run_server.sh

The address that the server listens on. The default is 127.0.0.1.

PORT

Server scripts

The server port.

MODEL_PATH

Server scripts, run_client.sh

The checkpoint, /models/<checkpoint>.

CACHE_DIR

Server scripts

The compile cache. The default is /cache.

PREFILL_URL, DECODE_URL

run_balancer.sh

Required. The two servers, http://<node address>:<port>.

URL

run_client.sh

The balancer, http://127.0.0.1:8000, or a one-node server.

HOST, PORT

run_gsm8k.sh

The balancer, 127.0.0.1 and 8000, or a one-node server.

NUM_QUESTIONS, GSM8K_DATA

run_gsm8k.sh

The number of questions (default 100), and a local copy of the GSM8K test.jsonl file.

Arguments after the script name go to its command: SGLang server flags for a server script, and the balancer options (--host, --port, or one more --decode) for run_balancer.sh.

Launch environment#

Variable

Description

SGLANG_PLATFORM

neuron selects the Neuron platform. The container image sets this value.

NEURON_RT_VISIBLE_CORES

The NeuronCores of the server, as a range list such as 4-7. Without it, the server uses the first cores of the node. The plug-in refuses --base-gpu-id and --gpu-id-step. Use this variable instead.

Plug-in environment variables#

Variable

Default

Description

SGLANG_NEURON_SAMPLER

greedy

The sampler. greedy takes the argmax. temperature samples from the tempered distribution over the whole vocabulary. topk_topp adds the SGLang top-k, top-p, and min-p filters over the top 256 tokens. host runs the SGLang sampler on the logits, with --disable-overlap-schedule. The plug-in refuses a request that the sampler cannot serve.

SGLANG_NEURON_MAX_TOP_LOGPROBS

0

The maximum number of top logprobs that a request can ask a device sampler for. The maximum is 256 under topk_topp.

SGLANG_NEURON_KIMI_PROMPT_HOST_SLOTS

0

Kimi-K3 prefill with --radix-cache-backend kimi-prompt: the host page slots of each rank. 0 means no host tier.

SGLANG_NEURON_KIMI_PROMPT_HOST_STATE_SLOTS

A twentieth of the page slots

Kimi-K3 prefill: the host state slots of each rank.

SGLANG_NEURON_GLM52_POINT

128k

The GLM-5.2 decode point, on both PD roles: 128k (32 slots of 131,072 positions) or 1m (32 slots of 1,048,576 positions). Set the same value on both servers of a pair.

SGLANG_NEURON_WAN_VAE_PATCH_PARALLEL_SIZE

Unset

SGLang Diffusion (Wan2.2): the patch-parallel group size of the VAE. The Wan2.2 example script sets 16 for 480p text to video.