Inference CLI
EngineSurogate Enginesurogate serve <model> [options...] # OpenAI/Anthropic HTTP serversurogate serve --generate <model> --prompt "..." # one-shot generationsurogate serve --embed <model> [--frontend DIR] # embeddings server<model> is a Hugging Face repo id, a local safetensors directory, or a GGUF file. The first
start prepares and caches the model; later starts reuse that preparation. Keep source GGUF
files in place while using their cache entries.
surogate serve Qwen/Qwen3.6-27Bsurogate serve ~/models/qwen3.6-27b-hf/surogate serve ~/models/qwen3.6-27b-Q4_K_M.ggufFrom a source checkout, build serving support with make serve-build.
surogate serve --engine-help prints server help. Add --generate or --embed to see the
options for those modes. Help does not prepare or download a model. Options may appear before
or after the model, and value options accept both --flag value and --flag=value.
Server options
Section titled “Server options”Endpoint and access
Section titled “Endpoint and access”| Flag | Default | Meaning |
|---|---|---|
--host H | 127.0.0.1 | Bind address; use 0.0.0.0 to accept remote connections |
--port N | 8080 | HTTP port |
--api-key KEY | none | Require this key through a bearer token or x-api-key header |
--api-key-file PATH | none | Read that key from a file instead, keeping it out of the process’s command line |
--openrouter-models-file PATH | none | Serve an operator-supplied OpenRouter catalog at /openrouter/v1/models |
--served-model-name ID | model argument | Name clients use in the model field |
--cors# | off | Allow browser cross-origin requests |
--max-request-mib N | 384 | Maximum request body size |
--request-log-jsonl FILE | none | Append request records to this file |
--log-stats-interval-ms N | 5000 | Throughput log interval; 0 disables |
Tenant-scoped prefixes behind an authenticated gateway
Section titled “Tenant-scoped prefixes behind an authenticated gateway”Start the backend with --trusted-prefix-scope, a gateway-only credential from --api-key-file, and --thinking-retention off. Restrict backend connectivity to the gateway and protect that connection. For each authenticated account, the gateway assigns an opaque 256-bit namespace and encodes it as 64 lowercase hexadecimal characters. Store a randomly assigned namespace per account or derive it with a server-held, domain-separated HMAC key. Reuse the namespace across that account’s requests.
Strip every inbound X-Surogate-Prefix-Scope and set exactly one trusted value on the upstream request after authorization. The backend requires that header on Chat Completions, Completions, Responses, Messages, and their tokenization/counting paths. Decisions rejects requests in this mode. The process-wide credential authenticates the gateway. Its value cannot distinguish the accounts using it.
The namespace participates in retained, shared-page, archived, and host-tier KV lookup, as well as tokenizer prefix reuse, shared media preparation, and replica prefix routing. API bodies never assign the namespace. Operator metrics describe the entire process and belong behind operator authorization. Accounts share scheduling, memory capacity and eviction pressure.
Context and KV cache
Section titled “Context and KV cache”The context limit controls how much text a request can use. The KV cache holds what the model computed for earlier tokens, and its capacity affects how many requests can run together.
| Flag | Default | Meaning |
|---|---|---|
--max-model-len N|auto | auto | Context limit per request; auto fits available GPU memory up to the model’s maximum |
--rope-scaling JSON | off | Extend the context with YaRN (see Context past the model’s native length) |
--kv-capacity N|auto | follows context | Total cache capacity in tokens; auto sizes from free GPU memory, leaving 1024 MiB |
--kv-cache-dtype auto|fp8|bf16|int8 | auto | Choose cache precision automatically for the model, or force a specific format |
--kv-cache-dtype-skip-layers L,... | none | Keep the listed attention layers’ cache at BF16 |
--elastic-kv# | on | Grow cache memory use with demand |
--no-elastic-kv# | off | Reserve the full cache in GPU memory instead of growing memory use with demand |
--elastic-kv-overcommit# | off | Let several models share unused GPU memory for their caches |
--gpu-memory-limit-mib N | whole card | Cap everything the server holds on each GPU; automatic sizing fits in it (see Sharing a GPU) |
--prefix-cache-host-gb N | off | Keep up to N GiB per GPU of conversations the cache gives back in host RAM, and resume them from there (see Host prefix cache) |
--no-cache# | off | Rebuild the prepared model cache on disk |
--no-prefix-reuse# | off | Disable reuse of compatible earlier prompts |
--enable-prefix-caching, --no-enable-prefix-caching | enabled | Alternative spellings for enabling or disabling prompt reuse |
--enforce-eager# | off | Disable CUDA graphs for debugging |
--batch-invariant# | off | Make each request’s results independent of the other requests batched with it (see Reproducible results) |
With auto, the cache grows with demand up to the capacity it was sized for. The 1024 MiB left
over stays free for CUDA graphs and working buffers. The cache goes past its capacity only when
its pages are too scattered to fit, and then only while that 1024 MiB is still free.
When --max-model-len is automatic, omitted --kv-capacity also defaults to auto. When
context is explicit, omitted cache capacity defaults to that same token count. Use
--kv-capacity auto explicitly to make more cache available for simultaneous requests.
Context past the model’s native length
Section titled “Context past the model’s native length”--rope-scaling takes the Hugging Face rope_scaling object, as vLLM does, and serves the
model with YaRN: the context limit becomes the original length times factor. Qwen3.5 / 3.6
MoE checkpoints (Surogate3.7-35B-A3B, Qwen3.6-35B-A3B) and Qwen3.8-Flash-Next (its GGUFs and
NVIDIA’s NVFP4 release) are trained to 262,144 tokens; factor 4 serves them to 1,048,576.
Flash-Next’s QSA indexer turns its queries and block keys with the same coefficients as the
attention, so the blocks it selects past the native length are scored as the model scores them:
surogate serve surogate/Surogate3.7-35B-A3B-NVFP4 --max-model-len 1048576 \ --rope-scaling '{"rope_type":"yarn","factor":4.0,"original_max_position_embeddings":262144}'Only rope_type: "yarn" is accepted, with optional beta_fast (32), beta_slow (1) and
attention_factor (0.1 ln factor + 1); the checkpoint’s own rope keys may be included and are
ignored. Other model families refuse the flag. No reconversion is needed. YaRN changes the
rotation for every position, so it costs a little quality below the native length (about 0.02
nats per token at 95k on the 35B), so turn it on only when you need the longer context. A cold
million-token prompt takes about 16 minutes on a DGX Spark; later turns reuse the cache.
Compatible conversation context is cached automatically, including after a response
ends on EOS or a stop string. Completed conversations can also be reused after an
unrelated request. Without --prefix-cache-host-gb, each model has a 512 MiB host cache
budget per GPU for conversations whose lane another request took; conversations that exceed
that budget are not retained there, and one the KV cache needs back under pressure is dropped.
Older entries can be released as new requests arrive. Changing earlier messages, requesting
additional prompt logprobs, or a cache miss can require some or all of the prompt to be
processed again. Use --no-prefix-reuse to disable reuse.
Host prefix cache
Section titled “Host prefix cache”An agent’s conversation waits on the GPU between its turns. When the KV cache needs the room
for other requests, a waiting conversation is dropped, and its next turn prefills the whole
context again: tens of seconds for a 100k-token agent prompt. --prefix-cache-host-gb N keeps
those conversations in N GiB of page-locked host RAM per GPU instead, and resumes them with a
host-to-device copy:
surogate serve surogate/Surogate3.7-35B-A3B-NVFP4 --devices 0,1,2,3 --data-parallel \ --max-model-len 262144 --kv-cache-dtype fp8 --prefix-cache-host-gb 16- A finished turn is copied to host memory in the background, on a copy stream of its own, so evicting it later costs nothing; one not copied yet is copied when it is evicted.
- Conversations are stored as 1,024-token chunks of KV and the state at their turn boundaries (the recurrent state of a hybrid model, the draft head’s columns under MTP). Conversations that open the same way share their chunks, and a longer turn of a conversation reuses the chunks of its earlier ones.
- The memory is one pool for the whole process: data-parallel replicas and pipeline stages each add N GiB to it, and the least recently used conversations go first when it is full.
- The memory is page-locked at startup (about a second per 8 GiB) and is not available to other programs. Keep the total (N times the GPUs) well inside the host’s free memory.
- A conversation the KV cache could not keep, and that does not fit in the pool either, is
dropped as before;
surogate_host_prefix_cache_dropped_lanes_totalcounts them. - A restored conversation continues exactly as one still on the GPU would: the same tokens and log-probabilities.
/metricsreports the pool (surogate_host_prefix_cache_*), the prompt tokens reused by where they were (surogate_prefix_cache_hit_tokens_total{tier="gpu|shared_prefix|host"}), copy times, and request TTFT and queue-wait histograms;/kv_statshas the same per replica.
Give it enough for the conversations that wait while others hold the GPU. With 24 agents replaying recorded tool-calling conversations of up to 100k tokens on four GPUs (FP8 cache of 300k tokens each, 262,144 context), 2 GiB per GPU still let 18 % of the long turns prefill again and 8 GiB per GPU none. An RL rollout server on one RTX 5090 (FP8 cache of 400k tokens, an adapter loaded) running ten agent conversations that grow to 100k tokens, four at a time, kept 85 % of the later turns’ prompts cached with 8 GiB, against 15 % without the tier, and a turn took 7.1 s instead of 18.8 s; 4 GiB held two or three of those conversations and kept 23 %.
Across an in-place adapter swap (--lora-swap in-place), no prefix computed under the earlier
weights is reused: conversations retained on the GPU, shared prefixes and the host’s entries of
that adapter all prefill again once under the new weights, and their next finished turn is
stored under them. Requests in flight continue as they are. Other adapters and the base model
keep their cached prefixes.
0 keeps nothing on the host, not even the 512 MiB archive.
Cache precision auto selects BF16 for models such as Qwen3 and Llama, and FP8 for hybrid
models such as Qwen3.5/3.6/3.8, including with DFlash. FP8 uses half the cache storage of BF16.
With --elastic-kv-overcommit, --kv-capacity becomes a guaranteed minimum; auto guarantees
enough for one full-context request per model. See Serving models.
Reproducible results
Section titled “Reproducible results”By default a request’s logits, and so its log-probabilities and greedy tokens, can change in the last bits with the other requests the server batches it with: a BF16 projection’s algorithm follows the number of tokens in the step, some fused kernels split their sums by it, and a long prompt that shares a step is cut where the step’s token budget runs out. The differences are rounding-level, but a sensitive model turns them into visible ones: on Qwen3.5-0.8B, scoring sentences sixteen at a time moved sentence log-probabilities by up to 4 nats against scoring them one at a time, and changed some greedy answers.
--batch-invariant removes that dependence for BF16 text models. Every BF16 projection runs a
kernel whose per-value reduction order is fixed by the matrix alone; the GDN gating projection
takes a fixed-order kernel; and prompts are cut at fixed positions (every
--max-num-batched-tokens less 128 tokens, 1920 by default, for up to 128 sequences) whatever
shares their steps.
A request then returns the same bits alone, among sixteen, or in any arrival order. It implies
--enforce-eager and --no-prefix-reuse (a prefix hit continues from another request’s state),
and cannot be combined with --spec. Other weight formats keep their own kernels (the GGUF ones
already compute a token the same way at every width; FP8, NVFP4 and W8 are not verified), and
images and pipelines across several GPUs are not covered.
Measured on an RTX 5090 with Qwen3.5-0.8B, against the same eager, no-reuse server without the flag: short-prompt scoring 5% slower one at a time and 9% slower sixteen at a time, long-prompt scoring 12% slower, sixteen concurrent generations unchanged, one generation stream 26% slower.
Sharing a GPU
Section titled “Sharing a GPU”--gpu-memory-limit-mib N gives the server a budget of N MiB on each of its GPUs. The budget
covers weights, cache, working buffers and the CUDA context. Automatic sizing then works within
it instead of within the card’s free memory:
--kv-capacity autoand--max-model-len auto;--host-moe-layers auto, automatic expert slots and pipelines;- the optional repacked weight copies.
An explicit --kv-capacity, or the capacity that an explicit --max-model-len implies, must fit
the budget with 1024 MiB left over, or the server refuses to start. So must the weights and
their load staging.
The cache never grows past the capacity it was sized for. The 1024 MiB left over absorbs working buffers that grow later, so the server stays within its limit.
Several models in one server share the budget. To share a GPU between processes, give every
process on it a limit, and keep the limits below the card’s memory less what the driver reserves.
Processes without a limit, such as other programs, can still take memory the others counted on.
--expert-slots N is not checked against the limit.
The server measures its own usage through NVML. Inside a container that hides host process ids,
NVML cannot attribute usage to the process. The server then counts everything allocated on the
device since it started, plus 512 MiB for the CUDA context, and prints a warning. Run such
containers with --pid=host for an exact figure.
With a limit set, the device_free_bytes reported by /kv_stats and /metrics is what the
server may still allocate.
Devices
Section titled “Devices”| Flag | Default | Meaning |
|---|---|---|
--device N | 0 | Use one GPU |
--devices A,B,... | — | Split a supported model across the listed GPUs, one pipeline stage per GPU |
--data-parallel# | off | With --devices, run a whole copy of the model on each listed GPU instead |
--devices takes precedence over --device; its first GPU is also used for model preparation.
With one GPU, preparation follows --device. SUROGATE_CONVERT_DEVICE overrides the preparation
device when needed. GPU indices follow CUDA_VISIBLE_DEVICES.
All supported text-generation families can use --devices. MTP and DFlash can also use
multiple GPUs when the prepared model includes compatible draft weights. The maximum
number of GPUs depends on the checkpoint; if the requested split is rejected, use fewer GPUs.
Additional models can share a GPU, use different GPUs, or use their own GPU groups. They inherit the primary model’s placement unless you override it:
surogate serve /path/to/primary.sinfer --devices 0,1 --enable-sleep-mode \ --model second=/path/to/second.sinfer,devices=2:3 \ --model small=/path/to/small.sinfer,device=4Within --model, separate GPU indices with colons. Sleep and wake apply to every GPU used
by the selected model. The scheduler accounts for available memory on each GPU.
Pipeline or data-parallel
Section titled “Pipeline or data-parallel”--devices on its own is pipeline parallelism: each GPU holds a contiguous range of layers,
and every token passes through all of them in turn. This is how you serve a model too large for
one GPU, and it gives the longest context, because every card’s memory left after the weights
holds cache. It adds no throughput, though: at any moment most of the cards wait for the one
working on the current layers.
When the model fits one GPU, add --data-parallel. Each listed GPU then runs its own complete
engine, all under one model name, and requests are spread across them:
surogate serve /path/to/model --devices 0,1,2,3,4,5 --data-parallel --max-num-seqs 16- A conversation goes back to the replica that served its previous turn, which holds that prompt in its cache. Without that, a later turn of a long agentic conversation would be prefilled again on another card. A replica that already carries more than 1.25 times the average load gives the request to the least busy replica instead.
- A client that manages its own placement can send
X-data-parallel-rank: N(vLLM’s header) to send a request to replica N, counted from 0 in--devicesorder. - Each replica has its own
--max-num-seqs, request queue and cache: six replicas with--max-num-seqs 16serve 96 requests at once. - Adapter loads,
/sleepand/wake_upapply to every replica./v1/modelslists the model once;/kv_statsand/metricsreport each replica separately, with areplicafield or label. - Extra models need an explicit
device=ordevices=placement under--data-parallel.
For a model that fits one GPU, this is much faster than a pipeline: measured on six RTX PRO 6000 cards with an agentic workload, six single-GPU engines decoded about 40 times more tokens per second than one six-stage pipeline.
For independent replicas under separate names, add the same artifact as an extra model,
for example --model replica=/path/to/primary.sinfer,device=2. Select the replica with the
request’s model field; each replica has its own request capacity and cache.
Host offload
Section titled “Host offload”Use system RAM for part of a model when it does not fit in GPU memory. This reduces GPU memory requirements but can make responses slower. The machine needs enough RAM to hold the offloaded weights; that memory cannot be swapped out while the model is loaded.
| Flag | Default | Meaning |
|---|---|---|
--host-moe-layers N|auto|all | off | Move experts from N MoE layers to RAM; auto chooses enough to fit on one GPU or each GPU in a multi-GPU run |
--gpu-layers N|all, -ngl N, --n-gpu-layers N | all | Keep the first N decoder layers on the GPU; 0 offloads all decoder layers, and all keeps them resident |
--offload-vision# | off | Store the image encoder and projector weights in system RAM |
--offload-embeddings# | off | Store the token embeddings in system RAM |
--offload-output-head# | off | Store the output-head weights in system RAM |
Whole-layer and component offload work on one or multiple GPUs. Combine the flags as needed; GPU computation and the decode cache still need GPU memory. When a model shares its embeddings and output head, offloading either one moves their shared weights to RAM. MoE-specific options apply only to MoE models and only affect experts that are offloaded.
For a mixture-of-experts (MoE) model, try --host-moe-layers first. It generally transfers
less data than offloading whole layers.
surogate serve models/GLM-5.3-Flash-UD-Q4_K_XL-00001-of-00006.gguf \ --device 0 --host-moe-layers all --max-model-len 2048MoE expert cache
Section titled “MoE expert cache”Every supported MoE generation model can cache offloaded experts on the GPU and use CPU
cores for some expert computation. Enable expert offload with --host-moe-layers or offload
whole layers with --gpu-layers before using these settings.
| Flag | Default | Meaning |
|---|---|---|
--expert-slots N | automatic | Number of experts cached on the GPU; omitted or 0 sizes the cache from available memory. An explicit count must hold at least the experts selected for one token |
--host-expert-bank auto|w8|q4 | auto | Precision of offloaded experts. w8 uses eight bits throughout; q4 uses four bits, saving RAM but potentially reducing quality |
--cpu-moe-share F|auto | off | Fraction of expert work sent to CPU cores; auto measures the machine at startup |
--cpu-moe-prefill-share F | 0 | CPU share during prompt processing; 0 disables it |
--cpu-moe-min-tokens N | model default | Minimum token count before CPU sharing is used |
CPU shares must be numbers from 0 to 1; decode also accepts auto. They apply to cache
misses, so a fully cached expert does not need CPU execution.
Automatic host precision keeps four-bit, five-bit, and wider source weights at suitable
precisions. Force q4 only when you want the RAM saving from reducing wider weights to four bits.
NVFP4 expert route
Section titled “NVFP4 expert route”--moe-route chooses the kernels for the routed experts of an NVFP4 mixture
(Surogate3.7-35B-A3B and other Qwen3.5/3.6 mixtures in NVFP4):
| Route | What runs the routed experts |
|---|---|
auto (default) | Rounds of two or more tokens: the FP4-activation (W4A4) runner, fastest in prefill. One-token rounds and adapter rounds: BF16-activation (W4A16) kernels |
w4a16# | The BF16-activation kernels at every round width |
marlin# | The experts are rewritten into Marlin tiles at load and every width runs on BF16 activations, with grouped tensor-core GEMMs; adapter deltas run on the same expert tiles |
The FP4-activation runner’s result for a token depends on how many tokens share its round, so
under auto a token’s log-probability at decode differs from the one a prefill of the same text
gives it, with a fat tail. One RTX 5090 serving Surogate3.7-35B-A3B with MTP 2, an FP8 cache and
16 requests at once:
| Route | Decode / prefill tokens/s, no adapter | With a rank-16 expert adapter | Decode vs prefill k3, no adapter |
|---|---|---|---|
auto# | 2,238 / 26,498 | 714 / 4,742 | 0.0117 |
w4a16# | 1,469 / 2,654 | — | 0.0054 |
marlin# | 2,224 / 19,218 | 1,728 / 14,418 | 0.0053–0.0060 |
Use marlin when the server serves adapters, and wherever decode and prefill log-probabilities
are compared (RL rollouts, KL panels). A trainer re-scoring the server’s rollouts under an
adapter of realistic size (rank 16, a mean shift of 0.11 nats a token from the base model) agreed
with marlin nearly as closely as with the base model, and less with auto:
| Rollouts scored by the trainer | k3 against the sampled log-probabilities | Tokens more than 1 / 2 / 3 nats apart |
|---|---|---|
No adapter (w4a16) | 0.0047 | 11 / 0 / 0 per 17k |
Adapter, marlin | 0.0055 | 9 / 1 / 0 per 8.5k |
Adapter, auto | 0.0076 | 23 / 2 / 1 per 8.4k |
Prefill of a fixed text under the adapter put auto further off (k3 0.0395, 56 / 16 / 7
tokens) than marlin (0.0074, 25 / 1 / 1). The default route’s adapter path scores some of the
tokens the adapter moves most too low: where the two routes differ by more than a nat, the
trainer sides with marlin on 49 of 65 tokens. marlin does not apply router adapters
(mlp.gate and its aliases): an adapter that has them is refused. auto stays the default
for serving the base model, where its prefill is fastest.
Scheduling
Section titled “Scheduling”| Flag | Default | Meaning |
|---|---|---|
--max-num-seqs N | 1 | Maximum active requests per model |
--max-num-batched-tokens N | 2048 | Prompt tokens processed at a time; must be a positive multiple of 128 |
--max-pending-requests N | 16 | Additional requests allowed to wait |
--pending-timeout-ms N | 30000 | Time allowed for model wake-up, prompt preparation, and waiting to start generation |
--overlong-max-tokens reject|cap | reject | A max_tokens that does not fit the context next to the prompt: reject answers HTTP 400 as vLLM 0.31 does (BadRequestError, “This model’s maximum context length is …”); cap silently caps it to the rest of the context (the earlier behaviour). A chat / Responses request without max_tokens gets --default-max-tokens, capped to the rest of the context, either way; /v1/completions without one asks for 16 under reject, as vLLM does |
--default-max-tokens N | none | Output limit when a request omits it (vLLM’s generation-config max_new_tokens). Not given: the rest of the context, as vLLM serving a checkpoint without max_new_tokens; with --kv-admission reserve that reserves the whole context per request |
--kv-admission reserve|ondemand | ondemand | How a request’s KV cache is committed: its prompt at admission and the rest as it generates (ondemand), or prompt + output limit up front (reserve) |
--kv-admission-headroom N | 256 | Ondemand: output tokens a request is given room for when it is admitted |
--kv-admission-watermark F | 0.01 | Ondemand: fraction of the KV cache an admission leaves free while other requests run |
With --kv-admission ondemand a request starts as soon as its prompt fits, however large its
output limit, and its cache grows a step at a time. When the cache runs out, the running request
that arrived last is paused: its cache is released, it goes back to the front of the queue, and it
continues later by recomputing its prompt and the tokens it had produced (its stream, budget and
sampling state carry on). Requests are admitted strictly in arrival order. A request whose prompt
plus output limit could never fit the cache is refused at once. surogate_kv_preemptions_total
and surogate_kv_recomputed_tokens_total count the pauses and the tokens they recomputed.
Requests that return prompt log-probabilities or routing, decision readouts, DFlash drafting and
multi-GPU pipelines keep the up-front reservation. An image request admitted this way keeps its
prepared media until it completes, so that a recompute can encode it again; that media counts
against --media-live-mib, and once it would take more than half of it, further image requests
are given the up-front reservation instead.
Set --max-num-seqs 256 (or higher) to allow more than 128 active requests per model.
More simultaneous requests need more memory and may increase response latency; pair this
setting with --kv-capacity auto. The pending timeout does not limit how long an
already-running response may take.
Wake waits count toward the pending-request limit. If the pending timeout expires,
the request returns HTTP 503; disconnecting while waiting releases its queue slot.
Incoming prompts can share a batch with requests already generating, including requests
using different LoRA adapters, DFlash, and images or video. On one GPU without --spec, prompts
that arrive together while nothing is generating are prefilled together too, up to
--max-num-batched-tokens per step: a burst of short prompts, such as one-question
/v1/decisions, costs a few steps rather than one step each. A decision, or a chat request with
parallel_decoding, takes the queue places its questions need, up to the smaller of their count,
--max-num-seqs and 64, before any of it runs. When the queue is busy it waits for them, in
arrival order and within --pending-timeout-ms (then HTTP 503), rather than run its shared prefix
and find no room for its questions. While it waits, the places it needs are kept for it, so other
requests can get HTTP 429 before the queue is full; surogate_requests{state="reserving"} counts
the requests waiting this way. Lower --max-num-batched-tokens
to reduce the time spent on each prompt chunk when streaming responsiveness matters;
larger values can improve prompt throughput. Active text requests continue generating throughout
image and video processing, on one or multiple GPUs. Sharing the GPU can delay image responses;
lower image resolution or fewer video frames can improve latency. DFlash needs room in the batch
for both prompt tokens and the proposed tokens it checks.
Speculative decoding
Section titled “Speculative decoding”Speculative decoding can make generation faster by proposing several tokens for the model to check together. It works best when those proposals are often accepted. Measure it on your workload: more simultaneous requests or heavy CPU offload can reduce the benefit.
| Flag | Meaning |
|---|---|
--spec mtp | Enable MTP on a supported model; supports one or multiple GPUs |
--spec dflash | Use a compatible separate drafter on one or multiple GPUs; supports BF16 or FP8 caches and can be combined with --vision. Qwen3.5 and the Gemma 4 mixture take the drafter at preparation; see Preparing a DFlash pair |
--dflash-model PATH | Matching separate Muse-Glimmer DFlash GGUF; see Muse-Glimmer |
--draft-tokens N | Number of proposed tokens: 1–5 for MTP, 1–15 for DFlash; required with --spec. With --spec-adaptive, sets the maximum |
--spec-adaptive# | Adjust DFlash draft length to measured throughput. Can temporarily stop drafting and retry it later. Off by default |
--spec-max-lanes N|all | MTP checks drafts only while at most N requests are decoding. Default (or 0) is 1, or all on a DGX Spark (GB10) outside a pipeline; all keeps checking at every concurrency level. Does not affect DFlash |
--lm-head-draft# | Draft with the model’s smaller draft vocabulary (shortlist head). MTP and DFlash already do this by default when the model provides one |
--full-head-draft# | Draft MTP or DFlash proposals with the full output head instead of the shortlist head. Greedy output is the same either way, and sampled output keeps the model’s distribution |
For workloads where DFlash acceptance or concurrency varies, use --spec dflash --draft-tokens 15 --spec-adaptive. The engine learns from completed decode rounds, so short requests may finish before it has enough measurements. It keeps separate measurements for different batch sizes and context lengths. Adaptive mode uses more GPU memory and can take longer to start. Calibration and periodic retries add some overhead; compare throughput on your workload. This option also works with vision prompts, BF16 or FP8 caches, and pipeline serving. Omitting --spec-adaptive keeps the requested draft length fixed. Changing draft lengths can also change individual token scores or greedy wording through numerical rounding, especially with an FP8 cache.
MTP needs the checkpoint’s MTP weights, which some community exports omit. DFlash needs a compatible drafter included during model preparation. Missing draft weights produce a startup error. See Preparing a DFlash pair.
With DFlash, --kv-cache-dtype fp8 reduces cache memory for both the target and drafter.
Use --kv-cache-dtype bf16 for higher cache precision. FP8 can change generated output and
draft acceptance, so compare memory use and generation speed on your workload.
For image or video conversations, prepare the pair with the target’s vision weights and
start the server with --vision --spec dflash. Text-only requests can use the same server.
Draft acceptance and speed depend on the prompt; compare with ordinary decoding for your workload.
Serving several models from one process
Section titled “Serving several models from one process”Use --model name=path[,key=value...] for each additional model. Currently, the additional
model’s path must be a prepared .sinfer file from the serving cache. Prepare the model
separately first, then use its cache path; see Serving models.
The first, positional model still accepts a repo id, safetensors directory, or GGUF.
| Setting | Meaning |
|---|---|
--model name=path | Add a model; clients select it with model: "name" |
kv-tokens=N | Override this model’s cache budget; required with --no-elastic-kv |
max-num-seqs=N | Override its maximum simultaneous requests |
device=N | Place this model on one GPU |
devices=A:B:... | Split this model across these GPUs |
max-model-len=N | Override its context limit |
spec=mtp|dflash | Enable speculation for this model; defaults its draft token count to 3 |
draft-tokens=N, spec-max-lanes=N|all, spec-adaptive=true|false | Override this model’s speculation settings |
lora=name:path | Add an adapter to this model; repeatable |
priority=high|normal|low | Priority when models compete for memory; defaults to normal |
--model-priority high|normal|low | Set the first model’s priority |
Put per-model settings after its path, separated by commas. Omitted context, concurrency,
and cache settings inherit from the first model. Speculation is off unless enabled for each
additional model. /v1/models lists all served model and adapter names.
With --enable-sleep-mode, the models do not all need to fit in GPU memory at once. Requests
for a sleeping model wait while the server frees room and wakes it. Less recently used,
lower-priority idle models are preferred for sleeping. After a grace period, a busy model may
be paused for an equal- or higher-priority request, then resumed when memory is available.
Higher-priority models stay ready longer after use, but idle models can still be put to sleep.
Allow enough system RAM for the saved models. Multi-model startup prepares this memory in
advance. Management endpoints accept ?model=NAME to select a particular model.
Sleep mode
Section titled “Sleep mode”| Flag | Default | Meaning |
|---|---|---|
--enable-sleep-mode# | off | Enable /sleep and /wake_up to release and restore GPU memory while preserving model state across its GPUs |
See the API guide for commands and behavior while asleep.
LoRA adapters
Section titled “LoRA adapters”Serve PEFT adapters beside the base model. A request selects an adapter by putting its name in
model; the base model’s name selects the unadapted model. Different adapters can serve
requests at the same time.
| Flag | Default | Meaning |
|---|---|---|
--enable-lora# | off | Enable adapters, including loading them later through the API |
--lora-modules name=path,... | — | Adapter directories to load at startup |
--max-loras N | 1 | Maximum loaded adapters per model |
--max-lora-rank N | 32 | Largest adapter rank accepted |
--lora-swap in-place|drain | drain | How loading a name that is already loaded replaces it: in-place swaps the weights at a round boundary while that adapter’s requests keep running; drain waits for them to finish. The load’s "in_place" field overrides it per call |
LoRA and DoRA adapters support the following modules, where they exist in the checkpoint:
| Model or component | Adapter modules |
|---|---|
| Llama, dense Qwen layers, Gemma 3 and Gemma 4 | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Token embeddings and output head | embed_tokens (or the checkpoint’s embedding, tok_embeddings, word_embeddings), lm_head |
| Gemma 4 E2B/E4B per-layer inputs | per_layer_input_gate, per_layer_projection |
| Qwen3.5/3.6 and Qwen3.8-Flash-Next attention | q_proj (including its attention gate), k_proj, v_proj, o_proj |
| Qwen hybrid linear attention | linear_attn.in_proj_qkv, linear_attn.in_proj_z, linear_attn.in_proj_a, linear_attn.in_proj_b, linear_attn.out_proj |
| Spark-X2.5 | q_k_v_proj, g_proj, out_proj, gate_proj, up_proj, down_proj |
| LFM2, LFM2-MoE and the text decoder of LFM2-VL | Attention projections, conv.in_proj, conv.out_proj, and dense feed_forward.w1, w2, w3 |
| Qwen vision towers | Patch projection, attention QKV/output, MLP projections, merger and deepstack projections |
| LFM2-VL vision tower | Patch projection, attention Q/K/V/output, MLP projections and multimodal projector |
| Gemma 3/4 vision | Patch, attention and MLP projections; Gemma 4 output projection |
| Routed experts on supported MoE models | Each expert’s gate_proj, up_proj, down_proj; LFM2 expert names w1, w3, w2 are also accepted |
| MoE router and shared expert | mlp.gate (or the checkpoint’s router.proj / feed_forward.gate), mlp.shared_expert_gate, and the shared expert’s gate_proj, up_proj, down_proj, where present |
Keep the checkpoint’s module paths, including expert numbers. Surogate’s fused
gate_up_proj adapter exports are also accepted. Expert adapters use separate A/B matrices
for each expert and support ranks up to 256. Adapters work with supported quantized base
models, including NVFP4.
Use the smallest --max-lora-rank and --max-loras that fit your adapters, especially for MoE models.
Expert adapters support batched prefill and CPU expert computation. CPU weight offloading,
--cpu-moe-share and --cpu-moe-prefill-share remain available with adapters enabled.
Adapters may include DoRA magnitudes, LoRA B biases, saved base biases, and per-module rank
or alpha overrides. Set --max-lora-rank to cover the largest rank used by any module.
Vision adapters require a model served with --vision; embedding and output-head adapters
must match the served vocabulary.
Saved full embedding and output-head weights, including modules_to_save exports, are
also supported. These consume additional GPU memory for each loaded adapter.
Full replacements of other modules and targets outside the supported
modules still need surogate merge before serving. If an adapter contains unsupported weights,
loading fails with a message naming the affected tensor or module and explaining the next step.
Runtime loading also writes a warning to the server log. Unsupported weights are never silently
skipped; a rejected replacement leaves the currently loaded adapter available.
Additional models have their own adapters through lora=name:path in --model. Every model
and adapter name must be unique. The runtime load/unload endpoints accept ?model=NAME; see
LoRA adapters at runtime.
An RL trainer that publishes a new adapter every step replaces it in place: with
--lora-swap in-place the new weights are staged in host memory while the engine serves and
copied in at the next round boundary, requests in flight continue on them, and every choice
reports which adapter version sampled its tokens. See
Replacing an adapter in place. On an NVFP4 mixture,
serve adapters with --moe-route marlin (NVFP4 expert route).
A server that loads or replaces adapters repeatedly needs MALLOC_ARENA_MAX=2 in its
environment. A load parses the adapter into tens of thousands of small buffers on an HTTP
thread, and glibc keeps the freed ones in that thread’s arena, so without the cap the process
grows by about an adapter’s size with every load: twelve in-place swaps of a 2.5 GB rank-16
expert adapter took the server from 11.2 to 30.3 GiB of resident memory, and with
MALLOC_ARENA_MAX=2 it stayed at 11.2 GiB.
When the adapters cover only part of the model, such as the experts of a mixture,
SUROGATE_SERVE_LORA_MODULES limits the adapter banks to those modules (see
Environment). Every other projection then keeps its fused base route in adapter
rounds and runs no delta: on --moe-route marlin with an expert-only adapter,
SUROGATE_SERVE_LORA_MODULES=experts.,shared_expert raised adapter decode from 1,728 to
1,943 tokens/s and prefill from 14,418 to 16,662 on one RTX 5090. Those projections’ outputs
in adapter rounds then match base rounds instead of the adapter-capable routes: a
rounding-level change.
Sampling defaults
Section titled “Sampling defaults”For each sampling field, the precedence is:
- Explicit request parameter.
- Server CLI setting.
- The model’s
generation_config.json. - Built-in family default.
The generation config supplies temperature, top_k, top_p, min_p, repetition_penalty,
presence_penalty, and frequency_penalty. Its values apply to both thinking modes; missing
or null fields retain the family default for that mode. For GGUF models, the file’s optional
sampling metadata supplies the generation defaults. If neither source provides a field,
the family default applies.
--temperature, --top-p, --top-k, --min-p, --presence-penalty, and --frequency-penalty
set server defaults. --seed sets the random seed, which can also be overridden per request.
--greedy always forces temperature zero, including when a request asks for another value.
Requests also accept repetition_penalty.
Sampling honors the requested top_k without a fixed candidate cap; top_k: 0 leaves the
whole vocabulary available. min_p removes tokens with low probability relative to the most
likely token, and top_p keeps the smallest remaining prefix reaching the requested probability
mass. These filters also apply during speculative decoding.
Thinking
Section titled “Thinking”Without a flag, each model thinks or not as its chat template does by default (Qwen and
Granite think, Gemma 4 answers directly). --thinking or --no-thinking sets that default
for every request on a model whose template has the toggle.
--preserve-thinking keeps earlier assistant reasoning in later prompts. These settings are
independent and can be overridden per request. Supported reasoning-effort values depend on
the model’s chat template.
| Flag | Default | Meaning |
|---|---|---|
--reasoning-parser NAME | qwen3 | Read reasoning in the model’s output format; also accepts deepseek_r1, glm4_moe, think, or none/off |
--tool-call-parser NAME | hermes (qwen3_coder for Qwen3.5 / Qwen3.6, gemma4 for Gemma 4) | Read tool calls; also accepts qwen3_coder / qwen3_xml (one parser, as in vLLM), spark25, muse_glimmer, llama3_json, llama4_json, gemma4, or none/off. qwen3_coder reads a finished generation exactly as vLLM 0.31’s qwen3_coder parser does, from its token ids: any function name is a call, a call cut off by max_tokens or missing its closing tags is still a call, <tool_call> inside the reasoning ends it, and text after a call is dropped. A checkpoint whose vocabulary has <tool_call> as one token and whose template asks for <function=...> calls gets qwen3_coder; a Gemma 4 checkpoint gets gemma4; either unless the flag names another. hermes also reads a JSON body inside <tool_call>. The gemma4 parser does not constrain tool_choice: "required" or a named function, and refuses them |
--enable-auto-tool-choice# | off | Allow the model to choose a tool automatically; requires an enabled tool parser |
--chat-template FILE | model template | Use this Jinja file to format chat prompts |
--thinking-retention off|loop|all | off | Keep the reasoning of every chat completion in RAM and put it back into a later request of the same conversation whose assistant turn comes without it: loop for the turns after the last user message, all for every turn |
--thinking-retention-mb N | 512 | Size of the retention store, in MiB; the least recently used entries go first |
--thinking-retention-ttl T | 6h | How long an entry is kept after its last use: seconds, or with an s, m, h or d suffix |
--thinking-loop-guard# | off | Close a thought that goes round in circles and answer instead (see Thinking guard) |
--thinking-answer-reserve N | off | Close a thought that reaches the request’s output budget less min(N, budget/4) tokens, so the answer keeps that room; 4096 is a good value |
Agent harnesses resend the whole conversation every turn, and many rebuild each assistant turn from
its content and tool calls only (tau2’s to_litellm_messages does), so a model that relies on its
earlier reasoning sees an empty think block for each of its own turns. --thinking-retention
restores that reasoning on the server: each answer’s reasoning is filed under a key over the
API key the request presented, the model it named, its messages and the answer’s content and tool
calls, and an assistant turn of a later request whose reasoning is absent or empty is looked up by
the messages before it and the turn itself. The match survives a client’s re-serialization:
reasoning fields, tool-call ids and tool_call_id are not hashed, content is trimmed (null is
""), and tool-call arguments are compared as canonical JSON. A turn that carries reasoning of its
own is never changed, and nothing is restored across API keys or models. With all, a restored
turn before the last user message is rendered with preserve_thinking where the template needs it
and the request did not turn it off. Restored reasoning never grows a prompt past the context less
the request’s max_tokens (else --default-max-tokens, else 32768 or a quarter of the context):
restored turns are taken back, oldest first, until it fits. The request log’s start line shows
thinking_retention=[restored=R missed=M dropped=D] (also in the JSON record), and /metrics
counts surogate_thinking_retention_{stored,restored,misses,dropped,evictions,expired}_total.
Only /v1/chat/completions with messages takes part; token-id prompts, /v1/completions, the
Responses and Messages APIs and /tokenize are served as before.
Thinking guard
Section titled “Thinking guard”A thinking request whose thought runs until max_tokens ends with an empty answer, after the longest possible
wait. The two guard flags turn that into an answer. They are off by default.
--thinking-loop-guardwatches the thought for a loop. A thought position repeats when the 32 tokens ending there have already appeared at least twice earlier in the same thought. The guard fires once 90% of the last 2,048 positions repeat. On Surogate3.7 replies it ended every looping thought 5,500 to 25,000 tokens in. It never fired on 7,200 ordinary chat replies and long agent turns, whose highest window share was 0.55.--thinking-answer-reserve Ncloses a thought that reaches the request’s output budget (itsmax_tokens, else--default-max-tokens, else the rest of the context) lessmin(N, budget/4)tokens.
When either fires, the engine closes the thought with Qwen3’s thinking-budget sentence:
Considering the limited time by the user, I have to give the solution based on the thinking directly now.
It then adds the model’s close marker (</think>) and the request answers in what is left of its budget, on the
same response:
- The sentence is streamed as reasoning, and the answer as content.
usagecounts the whole reply.finish_reasonis the answer’s own.- The answer runs on the same GPU state as the thought, so only the closing tokens are processed again.
- With no room left, the reply ends as the output limit would have ended it (
"length").
The engine prints each event to stderr, for example:
thinking-guard: closed a 7804-token thought (loop); answer 999 tokens, finish stop, 7831 of 7857 prompt tokens reusedThe guard applies to /v1/chat/completions, Responses and Messages requests built from messages, with thinking
on. These requests are served exactly as without it:
- token-id and raw-text prompts;
- requests for logprobs, prompt logprobs, token ids or routed experts;
- the tool grammar (
tool_choice"required"or a named function, strict tools); - a JSON schema,
min_tokens, images or video, and parallel decoding.
The guard only cuts a thought that would have run to the limit. The answer after it is the model’s best guess at that point, and a hard problem may still be answered wrongly.
Decisions calibration
Section titled “Decisions calibration”| Flag | Default | Meaning |
|---|---|---|
--decision-temperature T | 1 | Calibration temperature of the decisions endpoint: every answer is read from softmax(option logits / T) |
--decision-attempts N | 3 | How many times a decisions request runs while its option logits come out non-finite (1..16; 1 returns the error at once) |
T must be a finite number greater than zero (anything else is refused at startup); 1
returns the model’s own distribution unchanged. It applies to every decisions request
the process answers: every question type, every route alias, every served model (including
those added with --model) and every adapter. T > 1 softens an overconfident model and
T < 1 sharpens an underconfident one. The chosen option never changes, only the
probabilities and what is computed from them (confidence, noul, a score’s expected
level). Other endpoints are unaffected, and it is independent of --temperature, which the
decisions readout never uses. The value appears in the server_start and decisions request
records of --request-log-jsonl, and in the startup log when it is not 1.
Fit T on a held-out calibration split, never on evaluation data, and state the recommended
value in the model card; see Choosing the temperature.
surogate serve ./models/decision-model/ --decision-temperature 2.5Vision
Section titled “Vision”--vision enables images and video on supported models. --media-cache-mib N (default 1024)
sets how much processed media to retain for reuse; 0 disables retention. --media-live-mib N
(default 2048) limits memory for media currently being processed or used by requests.
--media-preprocess-threads N chooses processing threads; 0 selects automatically, up to 16.
Qwen3-VL dense and MoE, vision-enabled Gemma 3 and Gemma 4, and LFM2-VL/LFM2.5-VL checkpoints support image requests. Video requests sample frames; Gemma 3 and LFM2-VL receive those frames as a sequence of images. For example:
surogate serve Qwen/Qwen3-VL-2B-Instruct --vision --port 8080surogate serve Qwen/Qwen3-VL-30B-A3B-Instruct --vision --devices 0,1 --port 8080surogate serve google/gemma-3-4b-it --vision --port 8080surogate serve google/gemma-4-E2B-it --vision --offload-vision --port 8080Pick one of these commands and size the GPU group to the checkpoint. Send media through the
chat API or Responses API. Without --vision, the same checkpoint
serves text prompts.
For a Qwen3-VL, Gemma 3/4, or LFM2-VL GGUF, supply the matching vision projector from the same model release:
surogate serve /models/Qwen3-VL-2B-Instruct-Q4_K_M.gguf \ --mmproj /models/mmproj-BF16.gguf --vision --port 8080Dense and MoE GGUFs are supported, including split text files; pass the first shard.
If exactly one compatible mmproj*.gguf is beside the text model, it is selected automatically.
Otherwise, use --mmproj explicitly. Keep all source GGUF files available after preparation.
Supported projector quantization is preserved during preparation. Use --offload-vision
to reduce GPU memory further, and add --offload-embeddings --offload-output-head when needed.
LFM2-VL text weights use the same 8-bit serving format as LFM2; the other families retain
supported GGUF text quantization.
Qwen3-VL image and video serving has been checked with the 2B and 30B-A3B GGUF checkpoints.
The complete 235B-A22B checkpoint has not yet been tested.
Muse-Glimmer
Section titled “Muse-Glimmer”Muse-Glimmer-30B GGUF supports text, image, and video chat. Download the text GGUF and its
matching mmproj from the model release, then run:
surogate serve /models/Muse-Glimmer-30B-UD-Q4_K_XL.gguf \ --mmproj /models/mmproj-Muse-Glimmer-30B-BF16.gguf --vision \ --enable-auto-tool-choice --tool-call-parser muse_glimmerAdd --devices 0,1 to split the model across two GPUs. Omit --vision for text-only
serving. Reasoning is returned separately in reasoning_content.
Send videos using video_url in the chat API. The first conversion downloads a small
video-weight file from the original model release; later starts use the local cache.
To enable the separate DFlash assistant, also download dflash-kquant.gguf from the
same GGUF release and add:
--spec dflash --dflash-model /models/dflash-kquant.gguf --draft-tokens 15With --spec dflash, the assistant is found automatically when it is the only DFlash
GGUF beside the main model. DFlash works with text, images, video, and constrained
tool calls on one or multiple GPUs. A smaller --draft-tokens value can improve speed
when the assistant’s suggestions are frequently rejected.
Tools support auto, none, required, named tool choice, and strict argument schemas.
The general tool schema limits also apply to Muse-Glimmer.
--generate: one-shot
Section titled “--generate: one-shot”surogate serve --generate Qwen/Qwen3.6-27B --prompt "Suggest three easy vegetarian dinners." --max-new 256Answer content goes to stdout; reasoning and diagnostics go to stderr. Use > answer.txt to
save only the answer. This mode uses --max-context instead of --max-model-len, and
--kv-dtype instead of --kv-cache-dtype.
| Flag | Meaning |
|---|---|
--prompt <text> / --messages <file.json> | Input |
--max-new N | Maximum new tokens |
--prefill-chunk N | Prompt-processing size; default 2048 |
--stop <text>, --stop-token-id N, --reasoning-stop <text> | Repeatable stop conditions |
--raw-output, --print-token-ids | Verbatim output or token ids |
--prefill-warmup# | Run the supplied prompt once before timing; the measured run processes the prompt again |
--no-cuda-graph# | Disable CUDA graphs for debugging |
--reasoning-effort minimal|low|medium|high|xhigh|max | Reasoning setting, where the model supports it |
--embed: encoder models
Section titled “--embed: encoder models”surogate serve --embed <model.gguf> --device 0| Flag | Default | Meaning |
|---|---|---|
--host H | 127.0.0.1 | Bind address |
--port N | 8413 | HTTP port |
--device N|cpu | 0 | GPU number, or cpu |
--served-model-name NAME | model argument | Model name accepted by requests and listed by /v1/models |
--frontend DIR | automatic | Optional tokenizer override containing tokenizer.model and tokenizer_config.json |
EmbeddingGemma and Harrier (270M, 0.6B, 27B) Q8_0 GGUF files include their tokenizer, so no separate download or --frontend
is required. If both tokenizer files are beside the GGUF, they are used instead. An explicit
--frontend takes precedence; keep it in the command when using a custom tokenizer.
CPU environment
Section titled “CPU environment”| Variable | Setting | Purpose |
|---|---|---|
OMP_WAIT_POLICY# | ACTIVE | Reduce delays between CPU operations |
OMP_NUM_THREADS# | Physical cores of one NUMA node | Keep work on one CPU socket; avoid counting SMT threads as extra cores |
SINFER_CPU_GEMM# | unset | Use automatic selection, or force builtin, onednn, or zendnn when available in the build |
Pin CPU and memory use to the same node with numactl --cpunodebind=0 --membind=0.
See CPU embedding examples.
Environment
Section titled “Environment”| Variable | Meaning |
|---|---|
SUROGATE_SERVE_CACHE# | Prepared-model cache directory; default ~/.cache/surogate/serve |
SUROGATE_CONVERT_DEVICE# | Override the preparation device, such as cuda:1 or cpu; otherwise follows the serving GPU |
SUROGATE_SERVE_ELASTIC_KV_HEADROOM_MIB# | GPU memory kept free when sharing caches across models; default 1024 MiB |
SUROGATE_SERVE_DFLASH_PACKED_PREFILL# | 1 lets a DFlash server prefill several waiting prompts in one round, as a server without speculation does; off by default. See Preparing a DFlash pair |
SUROGATE_SERVE_MOE_TRTLLM_FUSED_FINALIZE# | 1 lets NVFP4 mixture experts add their outputs in the GEMM epilogue: up to about 3% faster, but the same request can then get slightly different answers from run to run; off by default |
SUROGATE_SERVE_LORA_MODULES# | Comma-separated fragments of adapter module names, such as experts.,shared_expert. Only layer modules whose name contains one get an adapter bank; embeddings, the output head and a mixture’s router and expert tables keep theirs. Projections without a bank keep their fused base kernels in adapter rounds and run no delta. An adapter that covers another module then fails to load, naming it. Unset: every module. See LoRA adapters |
SUROGATE_SERVE_MARLIN_LORA_FAST# | 0 runs --moe-route marlin’s wide adapter rounds (more than 1,024 routed rows) on the earlier grouped kernels: the same results, slower prefill (9,836 instead of 14,418 tokens/s in the table under NVFP4 expert route). A fallback |
SUROGATE_SERVE_PREFILL_GRAPH_BUDGET_MIB# | GPU memory for prefill and mixed-round CUDA graphs captured while serving; new shapes run without a graph once it is spent; default 512 MiB, 0 captures none |
SUROGATE_SERVE_PROMPT_TOKEN_REUSE# | By default a prompt that opens with a recent prompt’s text, such as an agent’s next turn, reuses that prompt’s token ids and tokenizes only the rest, with the same ids as a whole encode. 0 tokenizes every prompt whole; verify tokenizes both ways and fails the request if they differ |
SUROGATE_SERVE_PROMPT_ATTENTION_FP8_PV# | With an FP8 KV cache on compute capability 12.x GPUs (RTX 50 series, RTX PRO 6000, DGX Spark), prompt attention over 128- and 256-wide heads in layers without a sliding window multiplies the probabilities, rounded to e4m3, with V’s cached codes on the FP8 tensor cores (a third faster on a DGX Spark, with the same accuracy in our measurements). 0 keeps that product in bf16 |
MALLOC_ARENA_MAX# | glibc’s arena limit. Set 2 for a server that loads or replaces adapters repeatedly, or it grows by about an adapter’s size per load; see LoRA adapters |
Public admission limits
Section titled “Public admission limits”The server can reject excess POST requests with HTTP 429 and Retry-After, before JSON
parsing or media preparation. Limits are shared by all models and route aliases in the process.
Authentication runs first; unauthenticated requests do not consume the bucket. Health checks,
model discovery and CORS preflights remain available.
| Flag | Default | Meaning |
|---|---|---|
--rate-limit-rps R | disabled | Token bucket refill rate in requests/second (0.001–1,000,000) |
--rate-limit-burst N | 1 | Maximum accumulated requests; starts full |
--max-inflight-requests N | disabled | Concurrent POSTs, from admission through response delivery, including streams |
--max-thinking-requests N | disabled | Concurrent decisions with thinking: true, across all decisions aliases |
--max-image-requests N | disabled | Concurrent decisions carrying images, across all decisions aliases |
For a Gemma 4 mixture with --vision, --gemma-image-tokens 280|560|1120 overrides the
artifact’s per-image soft-token budget. Omission preserves the artifact default. Video frame
budgets are unchanged. Unsupported targets or an artifact with a smaller vision envelope are
rejected at startup.
Accepted malformed requests consume rate capacity but release their in-flight slot when their
error response completes. A full concurrency gate does not spend a rate token. Thinking requests
also consume the general bucket. Retry-After is an integer number of seconds; for concurrency
rejections it is a retry hint of one second, not a reservation. Clients should retry with jitter.
These limits protect preparation and inference. Place a reverse proxy with connection, body,
timeout and per-client limits in front of the loopback server for public service: the native HTTP
worker queue does not bound accepted sockets. Expose only the inference routes your clients need,
and keep administration and metrics private. Use --api-key-file to keep the secret out of process args.
Next: the OpenAI-compatible API describes the endpoints and request fields these options shape, and Serving models puts them together in worked examples for NVFP4, GGUF, offload and several models per GPU.