Server Arguments#
This page provides a list of server arguments used in the command line to configure the behavior and performance of the language model server during deployment. These arguments enable users to customize key aspects of the server, including model selection, parallelism policies, memory management, and optimization techniques.
Common launch commands#
To enable multi-GPU tensor parallelism, add
--tp 2
. If it reports the error “peer access is not supported between these two devices”, add--enable-p2p-check
to the server launch command.python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --tp 2
To enable multi-GPU data parallelism, add
--dp 2
. Data parallelism is better for throughput if there is enough memory. It can also be used together with tensor parallelism. The following command uses 4 GPUs in total. We recommend SGLang Router for data parallelism.python -m sglang_router.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --dp 2 --tp 2
If you see out-of-memory errors during serving, try to reduce the memory usage of the KV cache pool by setting a smaller value of
--mem-fraction-static
. The default value is0.9
.python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --mem-fraction-static 0.7
See hyperparameter tuning on tuning hyperparameters for better performance.
For docker and Kubernetes runs, you need to set up shared memory which is used for communication between processes. See
--shm-size
for docker and/dev/shm
size update for Kubernetes manifests.If you see out-of-memory errors during prefill for long prompts, try to set a smaller chunked prefill size.
python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --chunked-prefill-size 4096
To enable
torch.compile
acceleration, add--enable-torch-compile
. It accelerates small models on small batch sizes. By default, the cache path is located at/tmp/torchinductor_root
, you can customize it using environment variableTORCHINDUCTOR_CACHE_DIR
. For more details, please refer to PyTorch official documentation and Enabling cache for torch.compile.To enable torchao quantization, add
--torchao-config int4wo-128
. It supports other quantization strategies (INT8/FP8) as well.To enable fp8 weight quantization, add
--quantization fp8
on a fp16 checkpoint or directly load a fp8 checkpoint without specifying any arguments.To enable fp8 kv cache quantization, add
--kv-cache-dtype fp8_e5m2
.If the model does not have a chat template in the Hugging Face tokenizer, you can specify a custom chat template.
To run tensor parallelism on multiple nodes, add
--nnodes 2
. If you have two nodes with two GPUs on each node and want to run TP=4, letsgl-dev-0
be the hostname of the first node and50000
be an available port, you can use the following commands. If you meet deadlock, please try to add--disable-cuda-graph
# Node 0 python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --tp 4 --dist-init-addr sgl-dev-0:50000 --nnodes 2 --node-rank 0 # Node 1 python -m sglang.launch_server --model-path meta-llama/Meta-Llama-3-8B-Instruct --tp 4 --dist-init-addr sgl-dev-0:50000 --nnodes 2 --node-rank 1
Please consult the documentation below and server_args.py to learn more about the arguments you may provide when launching a server.
Model, processor and tokenizer#
Arguments |
Description |
Defaults |
---|---|---|
|
The path of the model weights. This can be a local folder or a Hugging Face repo ID. |
None |
|
The path of the tokenizer. Defaults to the |
None |
|
See different mode. |
|
|
The format of the model weights to load. |
|
|
Whether or not to allow for custom models defined on the Hub in their own modeling files. |
|
|
Dtype used for the model. |
|
|
Dtype of the kv cache. |
|
|
The model’s maximum context length. Defaults to None (will use the value from the model’s config.json instead). Note that extending the default might lead to strange behavior. |
None |
|
The device we put the model. |
None |
|
The device we put the model. |
None |
|
Override the model name returned by the v1/models endpoint in OpenAI API server. |
None |
|
|
|
|
Adjust if a specific version of the model should be used. |
None |
|
Set to |
|
|
A dictionary in JSON string format used to override default model configurations. |
|
|
Adopt base image processor instead of fast image processor (which is by default). See details. |
|
Serving: HTTP & API#
HTTP Server configuration#
Arguments |
Description |
Defaults |
---|---|---|
|
Host for the HTTP server. |
|
|
Port for the HTTP server. |
|
API configuration#
Arguments |
Description |
Defaults |
---|---|---|
|
Sets an API key for the server and the OpenAI-compatible API. |
None |
|
Directory for storing uploaded or generated files from API calls. |
|
|
If set, includes detailed usage of cached tokens in the response usage. |
|
Parallelism#
Tensor parallelism#
Argument |
Description |
Default |
---|---|---|
|
The number of GPUs the model weights get sharded over. Mainly for saving memory rather than for high throughput, see this tutorial: How Tensor Parallel works?. |
|
Data parallelism#
Arguments |
Description |
Defaults |
---|---|---|
|
Will be deprecated. The number of data-parallel copies of the model. SGLang router is recommended instead of the current naive data parallel. |
|
|
Will be deprecated. Load balancing strategy for data parallel requests. |
|
Expert parallelism#
Arguments |
Description |
Defaults |
---|---|---|
|
Enables expert parallelism that distributes the experts onto multiple GPUs for MoE models. |
|
|
The size of EP. Please shard the model weights with |
|
|
Enables expert parallelism that distributes the experts onto multiple GPUs for DeepSeek-V3 model based on |
|
|
Select the mode when using DeepEP MoE: can be |
|
Memory and scheduling#
Arguments |
Description |
Defaults |
---|---|---|
|
Fraction of the free GPU memory used for static memory like model weights and KV cache. Increase it if KV cache building fails. Decrease it if CUDA runs out of memory. |
None |
|
The maximum number of requests to run concurrently. |
None |
|
The maximum number of tokens that can be stored in the KV cache. Mainly used for debugging. |
None |
|
Perform prefill in chunks of this size. Larger sizes speed up prefill but increase VRAM usage. Decrease if CUDA runs out of memory. |
None |
|
Token budget for how many tokens can be accepted in one prefill batch. The actual limit is the max of this value and |
|
|
The scheduling policy to control how waiting prefill requests are processed by a single engine. |
|
|
Controls how conservative the server is when accepting new requests. High conservativeness may cause starvation; low conservativeness may reduce performance. |
|
|
Amount of RAM (in GB) to reserve for offloading model parameters to the CPU. |
|
Other runtime options#
Arguments |
Description |
Defaults |
---|---|---|
|
Interval (in tokens) for streaming responses. Smaller values lead to smoother streaming; larger values improve throughput. |
|
|
Can be used to enforce more deterministic behavior. |
None |
|
Timeout setting for the watchdog thread before it kills the server if batch generation takes too long. |
|
|
Overrides the default Hugging Face cache directory for model weights. |
None |
|
Sets the first GPU to use when distributing the model across multiple GPUs. |
|
|
Automatically truncate requests that exceed the maximum input length. |
|
Logging#
Arguments |
Description |
Defaults |
---|---|---|
|
Global log verbosity. |
|
|
Separate verbosity level for the HTTP server logs. |
None |
|
Logs the inputs and outputs of all requests for debugging. |
|
|
Ranges from 0 to 2: level 0 only shows some basic metadata in requests, level 1 and 2 show request details (e.g., text, images), and level 1 limits output to 2048 characters. |
|
|
Prints or logs detailed timing info for internal operations (helpful for performance tuning). |
|
|
Exports Prometheus-like metrics for request usage and performance. |
|
|
How often (in tokens) to log decode progress. |
|
Multi-node distributed serving#
Arguments |
Description |
Defaults |
---|---|---|
|
The TCP address used for initializing PyTorch’s distributed backend (e.g. |
None |
|
Total number of nodes in the cluster. See Llama 405B guide. |
|
|
Rank (ID) of this node among the |
|
LoRA#
Arguments |
Description |
Defaults |
---|---|---|
|
List of adapters to apply to your model. Each batch element uses the proper LoRA adapter. |
None |
|
Maximum number of LoRAs allowed in a running batch, including the base model. |
|
|
Backend used to run GEMM kernels for LoRA modules. Can be |
|
Kernel backend#
Arguments |
Description |
Defaults |
---|---|---|
|
This argument specifies the backend for attention computation and KV cache management, which can be |
None |
|
Specifies the backend used for sampling. |
None |
Constrained Decoding#
Arguments |
Description |
Defaults |
---|---|---|
|
The grammar backend for constraint decoding. See detailed usage. |
None |
|
Use with |
Speculative decoding#
Arguments |
Description |
Defaults |
---|---|---|
|
The draft model path for speculative decoding. |
None |
|
The algorithm for speculative decoding. Currently EAGLE and EAGLE3 are supported. Note that the radix cache, chunked prefill, and overlap scheduler are disabled when using eagle speculative decoding. |
None |
|
How many draft passes we run before verifying. |
None |
|
The number of tokens proposed in a draft. |
None |
|
The number of top candidates we keep for verification at each step for Eagle. |
None |
|
Optional, the path to the high frequency token list of FR-Spec, used for accelerating Eagle. |
None |
Debug options#
Note: We recommend to stay with the defaults and only use these options for debugging for best possible performance.
Arguments |
Description |
Defaults |
---|---|---|
|
Disable Radix backend for prefix caching. |
|
|
Disable CUDA Graph for model forward. Use if encountering uncorrectable CUDA ECC errors. |
|
|
Disable CUDA Graph when padding is needed; otherwise, still use CUDA Graph. |
|
|
Disable disk cache for outlines grammar backend. |
|
|
Disable usage of custom all-reduce kernel. |
|
|
Disable the Overhead-Scheduler. |
|
|
Enable warning if the logits contain |
|
|
Turns off the default of always allowing P2P checks when accessing GPU. |
|
|
In Triton kernels, cast the intermediate attention result to |
|
Optimization#
Note: Some of these options are still in experimental stage.
Arguments |
Description |
Defaults |
---|---|---|
|
Enables mixing prefill and decode, see this discussion. |
|
|
Enable Data Parallelism Attention for Deepseek models. |
|
|
Torch compile the model. Note that compiling a model takes a long time but has a great performance boost. The compiled model can also be cached for future use. |
|
|
The maximum batch size when using |
|
|
Adjust the maximum batchsize when using CUDA graph. By default this is chosen for you based on GPU specifics. |
None |
|
The batch sizes to capture by |
None |
|
Experimental feature that optimizes the model with torchao. Possible choices are: int8dq, int8wo, int4wo-<group_size>, fp8wo, fp8dq-per_tensor, fp8dq-per_row. |
|
|
Use to adjust the number of KV splits in triton kernels. |
|
|
Disable the use of the ragged prefill wrapper for the FlashInfer MLA attention backend. Only use it when FlashInfer is being used as the MLA backend. |
|
|
Disable the use of chunked prefix cache for DeepSeek models. Only use it when FA3 is attention backend. |
|