Serving models
EngineSurogate EngineThis page shows how to serve the common cases. surogate serve <model> takes a Hugging Face
repo id, a local safetensors directory or a GGUF file. The first start prepares the model and
saves the result under ~/.cache/surogate/serve, and later starts reuse it.
surogate serve Qwen/Qwen3.6-27B --port 8080The examples below cover quantized models, models larger than GPU memory, several models across GPUs, and embeddings. See the CLI reference for all options.
NVFP4 model
Section titled “NVFP4 model”NVFP4 checkpoints use four-bit weights and need a supported Blackwell GPU (RTX 50 series, RTX PRO 6000 Blackwell, or the DGX Spark’s GB10). Surogate detects the format on its own, so you don’t pass a quantization flag.
surogate serve nvidia/Qwen3.6-27B-NVFP4 \ --served-model-name qwen3.6-27b \ --host 0.0.0.0 --port 8080 \ --max-model-len 8192 --kv-capacity auto --max-num-seqs 32A local directory works the same way:
surogate serve ~/models/qwen3.6-27b-nvfp4/ \ --served-model-name qwen3.6-27b --port 8080 --max-num-seqs 32Once the server is ready, send a request:
curl http://127.0.0.1:8080/v1/chat/completions \ -H 'Content-Type: application/json' \ -d '{"model":"qwen3.6-27b","messages":[{"role":"user","content":"Hello"}]}'Then tune the settings to your workload:
- Simultaneous requests:
--max-num-seqsdefaults to 1. Raise it to serve more users at once.--kv-capacity autogives the conversation cache whatever GPU memory is free (see Context and KV cache). - Context length:
--max-model-lendefaults toauto. Set a number, as above, to fix the limit for each request. Longer conversations need more memory. A Qwen3.5 / 3.6 mixture (Surogate3.7-35B-A3B, Qwen3.6-35B-A3B) or Qwen3.8-Flash-Next serves past its native 262,144 tokens, to a million, with--rope-scaling(YaRN; see the CLI reference). - Cache precision: the default
autochooses FP8 for this Qwen3.6 model. Use--kv-cache-dtype bf16for BF16 precision; it needs more memory. - Generation speed: if the checkpoint includes MTP weights, try
--spec mtp --draft-tokens 3(speculative decoding). How much it helps depends on the prompts, the hardware and the number of simultaneous requests. By default, MTP checks drafts only while one request is decoding.
Rollout server for RL with adapters
Section titled “Rollout server for RL with adapters”An RL run samples agent rollouts from the policy (here an adapter the trainer replaces every step) and trains on the sampled tokens’ log-probabilities. This is one such server per GPU, for a rank-16 adapter on the experts of Surogate3.7-35B-A3B:
MALLOC_ARENA_MAX=2 SUROGATE_SERVE_LORA_MODULES=experts.,shared_expert \surogate serve surogate/Surogate3.7-35B-A3B-NVFP4 --device 0 --port 8000 \ --max-model-len 132096 --kv-cache-dtype fp8 --kv-capacity 400000 \ --max-num-seqs 16 --max-num-batched-tokens 4096 --spec mtp --draft-tokens 2 --spec-max-lanes all \ --enable-lora --max-loras 1 --max-lora-rank 16 --lora-swap in-place --moe-route marlin \ --prefix-cache-host-gb 8--moe-route marlinkeeps decode, prefill and the trainer in agreement under the adapter; the default route’s adapter path scores some tokens too low (NVFP4 expert route).--lora-swap in-placelets each step’s adapter replace the policy under the running rollouts, and every choice reports inlora_versionswhich version sampled its tokens (Replacing an adapter in place).MALLOC_ARENA_MAX=2is required. Without it, each swap leaks about an adapter’s size of host memory (2.4 GiB for this adapter).SUROGATE_SERVE_LORA_MODULESgives adapter banks to the experts only, so attention and linear-attention projections keep their fused base kernels: 8 % more decode and 16 % more prefill under the adapter. The catch: in one test the server’s prefill of its own rollouts was then further from the trainer (k3 0.0189) than its sampled log-probabilities were (0.0055). A server that scores rollouts by prefill (KL panels, evaluations) should run without it.--prefix-cache-host-gb 8keeps the agent conversations the KV cache drops between turns in host RAM and resumes them from there: in our test, 85 % of the later turns’ prompts were cached instead of 15 % (Host prefix cache).
On one RTX 5090 this server decodes 1,943 tokens/s for 16 requests and prefills 16,662 tokens/s
under the adapter, against 2,224 and 19,218 for the base model. Each server holds about 12 GiB of
host memory plus its host cache tier; eight of them on a 251 GiB host, with the model in
/dev/shm, take about 160 GiB.
GGUF model
Section titled “GGUF model”Point surogate serve at the .gguf file:
surogate serve ~/models/Qwen3.6-27B-Q4_K_M.gguf \ --host 0.0.0.0 --port 8080 --max-num-seqs 16 --kv-capacity autoSurogate reads supported GGUF weights straight from the source
files, without making another full copy. Prepared files go under ~/.cache/surogate/serve, or
the directory set by SUROGATE_SERVE_CACHE. Keep the source GGUF files at their original paths
for as long as you use the cache. For a split GGUF, pass the first shard; Surogate finds the
rest.
To serve an adapter you trained with Surogate as a standalone model, merge it first. You can serve the merged directory as it is:
surogate merge --base-model Qwen/Qwen3.5-0.8B --checkpoint-dir out/step_00000050 --output mergedsurogate serve mergedOr quantize the merged model before serving it:
surogate quantize --model merged --output merged-Q4_K_M.gguf --type q4_k_msurogate serve merged-Q4_K_M.ggufMiniCPM5
Section titled “MiniCPM5”Serve the Hugging Face checkpoint directly:
surogate serve openbmb/MiniCPM5-1B --port 8080For GGUF, download a file from openbmb/MiniCPM5-2B-GGUF and pass its local path:
surogate serve ~/models/MiniCPM5-2B-Q4_K_M.gguf --port 8080The GGUF includes its tokenizer and chat template. For direct answers, start the server with
--no-thinking (Thinking), or set
"chat_template_kwargs": {"enable_thinking": false} in a single chat request. Set
enable_thinking to true to ask for reasoning output.
Granite 4.2
Section titled “Granite 4.2”Serve IBM’s 3B, 8B, or 30B text model from a Hugging Face repo or a local GGUF:
surogate serve ibm-granite/granite-4.2-3b --enable-auto-tool-choicesurogate serve ~/models/granite-4.2-8b-Q4_K_M.gguf --enable-auto-tool-choiceBoth the original BF16 safetensors checkpoints and GGUF quantizations work, and the GGUF
files include their tokenizer and chat template. For the 30B model, pick a GGUF that fits your
GPU, or use --devices 0,1 to spread it across two GPUs.
Thinking is on by default. Use --no-thinking for direct answers, or pass
"chat_template_kwargs": {"enable_thinking": false} in a request. For lighter reasoning,
set "chat_template_kwargs": {"reasoning_effort": "low"}. Tool calls use the default
parser (hermes, which reads JSON and XML calls inside <tool_call>), so you don’t need a
parser flag.
The published checkpoints declare a 131,072-token context, and the default
--max-model-len auto sizes it to the available memory.
IBM’s model card has prompting examples.
Spark-X2.5
Section titled “Spark-X2.5”Serve either Spark-X2.5-1.7B or Spark-X2.5-4B directly:
surogate serve XHToken/Spark-X2.5-1.7B --port 8080 --enable-auto-tool-choice --tool-call-parser spark25surogate serve XHToken/Spark-X2.5-4B --port 8080 --enable-auto-tool-choice --tool-call-parser spark25The spark25 parser turns on tool calling through the chat API. To serve LoRA adapters, add
--enable-lora --lora-modules name=/path/to/adapter (see LoRA adapters).
Run one of the two. The first start downloads the checkpoint and prepares its serving cache, and later starts reuse that cache. A local checkpoint directory works too.
Use --no-thinking for direct answers; a chat request can override it with
"chat_template_kwargs": {"enable_thinking": true} or false. Set --max-model-len
to the context length you need, for example --max-model-len 8192.
LFM2-MoE and LFM2-VL
Section titled “LFM2-MoE and LFM2-VL”Serve an LFM2-MoE checkpoint directly:
surogate serve LiquidAI/LFM2-8B-A1B --port 8080A local LFM2-MoE GGUF works too. GGUFs are prepared as 8-bit serving weights, so a lower-bit download takes more disk space and GPU memory once prepared.
For images or video, use an LFM2-VL or LFM2.5-VL checkpoint with --vision:
surogate serve LiquidAI/LFM2-VL-450M --vision --port 8080Send images through the chat API as image_url content parts, as shown in the
API guide. Large images are resized or split automatically, following the
checkpoint’s processor settings. A request can carry several images, or none. Videos are
sampled into timestamped image frames. For GGUF releases, pass the text GGUF and its matching
projector with --mmproj; see the vision options.
Use --devices to split the text decoder across GPUs. LFM2-MoE and LFM2-VL can also load
adapters separately; see supported adapter modules.
Gemma images and video
Section titled “Gemma images and video”Enable --vision for a Gemma 3 or Gemma 4 checkpoint that includes image support:
surogate serve google/gemma-3-4b-it --vision --port 8080surogate serve google/gemma-4-E2B-it --vision --devices 0,1 --port 8080Use image_url or video_url content parts in chat requests, or the equivalent
Responses inputs. Gemma 3 receives sampled video frames as separate
images, and its configured image crops are applied automatically. For Gemma 4, dense,
E-series and MoE checkpoints work, including the 12B unified release. A text-only Gemma
checkpoint can’t take media requests; use a checkpoint with vision for those.
For a GGUF, pass the matching projector with --mmproj. To save GPU memory, add
--offload-vision, --offload-embeddings or --offload-output-head; these work when the
decoder spans several GPUs too.
Gemma 4 tool calls
Section titled “Gemma 4 tool calls”Gemma 4 writes tool calls in its own notation instead of JSON:
<|tool_call>call:get_weather{city:<|"|>Paris<|"|>}<tool_call|>. A server for a Gemma 4
checkpoint reads it with the gemma4 tool-call parser automatically, so OpenAI clients receive
ordinary tool_calls (start the server with --enable-auto-tool-choice for
tool_choice: "auto"). When streaming, the server holds the call back and sends the parsed call
when the reply ends. With this parser, tool_choice: "required" and a named function are
refused, because there is no grammar for Gemma 4’s notation to constrain the reply with.
Gemma 4 mixture in NVFP4
Section titled “Gemma 4 mixture in NVFP4”You can serve the Gemma 4 26B-A4B mixture, or a fine-tune of it, from an NVFP4 export on a Blackwell GPU. The routed experts run in four-bit floating point on the FP4 tensor cores. From two tokens up, a round’s activations are quantised too (W4A4); a single decoding token reads the four-bit weights with BF16 activations. Anything the export left unquantised is served as the export stores it. To serve NVIDIA’s export directly:
surogate serve nvidia/Gemma-4-26B-A4B-NVFP4 --vision --port 8080 \ --max-model-len 16384 --kv-capacity auto --max-num-seqs 64NVIDIA’s export quantises only the routed experts, and so does the recipe below. The attention and the dense feed-forward beside the experts stay BF16, which also happens to be the fast route on this model: the W8 tensor-core kernels don’t take its 2,112-wide dense feed-forward shape.
For many short prompts, such as decision requests, add --max-num-batched-tokens 8192 so each
prefill round packs in more of them. That raised decision throughput by about 10%.
Quantising your own Gemma 4 mixture
Section titled “Quantising your own Gemma 4 mixture”To quantise a fine-tune, calibrate on the kind of prompts it will serve. For a decision model, that means decision prompts from its training data rather than benchmark rows. NVIDIA ModelOpt (0.47 or newer) does the post-training quantisation:
pip install nvidia-modeloptpython -m surogate.serve.tools.nvfp4.modelopt_ptq --model my-gemma4-26b --scope all \ --calibration corpus.txt --split bos --out my-gemma4-26b-nvfp4-allpython -m surogate.serve.tools.nvfp4.assemble --export my-gemma4-26b-nvfp4-all \ --source my-gemma4-26b --scope experts --out my-gemma4-26b-nvfp4surogate serve my-gemma4-26b-nvfp4 --vision --port 8080--split bos reads a corpus of rendered chats that each start with <bos>. --split blank
reads one sample per paragraph, with paragraphs separated by blank lines. ModelOpt collects its
calibration statistics with quantisation off, so a single --scope all run quantises everything
and records every module’s scales. assemble then writes a checkpoint for the scope you choose:
experts: the routed experts only (NVIDIA’s recipe);mlp: the experts plus the dense feed-forward;attention: the experts, the dense feed-forward and the attention projections.
Modules outside the scope keep the BF16 source weights. On a GPU with room for the BF16 model, calibrating on 700 prompts takes about an hour.
Start with experts. On a decision model, mlp answered a few percent more requests per second
and changed slightly more answers; attention was about 15% faster than experts but measurably
less accurate. Before you adopt a wider scope, compare it against experts on your own requests.
The converter keeps each module as the checkpoint stores it: NVFP4 where the export quantised
it, BF16 where it didn’t. To prepare the artifact yourself, for example to add a DFlash drafter,
run the converter directly. --text-format w8 stores the unquantised matrices as W8 instead of
BF16, which saves about 2 GB but makes prefill about three times slower on this model.
--text-format fp8 instead stores the attention and dense feed-forward projections in FP8 for
the FP8 tensor cores, with a scale per 128 by 128 block (per row where a matrix’s rows are not
whole 128s), and quantises each prompt token’s activations per 128 values.
The other Gemma converters take the same option. A per-channel FP8 export, such as Red Hat’s
Gemma 3 FP8-dynamic checkpoints, defaults to fp8 and keeps the export’s own codes and row
scales; --text-format w8 re-encodes it as before.
python -m surogate.serve.convert.gemma_vl.convert --model my-gemma4-26b-nvfp4 \ --out my-gemma4-26b-nvfp4.sinferAn NVFP4 export’s answers differ from the BF16 model’s by the quantisation error. The decisions endpoint’s width pin doesn’t apply to it (see Decisions), so an answer can move slightly depending on what else the server is batching. Two runs of a decision benchmark under load agreed on 99.4% of choices. Measure agreement on your own requests before you replace a BF16 deployment.
A model larger than the card
Section titled “A model larger than the card”When a model’s weights don’t fit in GPU memory, you can keep part of it in system RAM (see Host offload). You need enough RAM for the offloaded weights, and generation is usually slower.
For a supported mixture-of-experts (MoE) model, start with
--host-moe-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 2048--host-moe-layers all puts all routed expert weights in system RAM; give a number to offload
fewer MoE layers. --host-moe-layers auto offloads as much as it takes to fit, on one GPU or
across several. Every supported generation model also accepts --gpu-layers N, which keeps the
first N decoder layers on the GPU and the rest in RAM. --gpu-layers 0 offloads every decoder
layer; --gpu-layers all keeps them all on the GPU. Add --offload-vision,
--offload-embeddings or --offload-output-head to move those components to RAM as well.
The request cache and the computation still need GPU memory. For MoE models, offloading only
the experts usually costs less speed.
Offloaded weights can’t be swapped out, so leave enough RAM for the operating system and other applications. Loading a large offloaded model also takes time on every start, even when model preparation is cached.
Flash-Next GSQ/RCO Q2_0
Section titled “Flash-Next GSQ/RCO Q2_0”The GSQ/RCO Q2_0 export of Qwen3.8 Flash-Next
uses Q2_0 routed experts and mixed quantization for the other projections. Surogate keeps
those GGML blocks as they are, including fused projections whose parts use different formats.
Preparation decodes the small control tensors to their runtime floating-point format. Routed
Q2_0 experts use INT8 tensor-core prefill by default; set SUROGATE_SERVE_MOE_INT8=0 to use
the BF16-activation prefill path instead.
Download both Q2_0 shards into the same directory and pass the first shard:
surogate serve ~/models/Qwen3.8-Flash-Next-GSQ-RCO-Q2_0-00001-of-00002.gguf \ --host 127.0.0.1 --port 8080 \ --gpu-layers all --host-moe-layers 0 \ --max-model-len 4096 --max-num-seqs 1 --kv-capacity autoKeeping the experts on the GPU avoids expert transfers during inference. If they don’t fit, use the offload settings below. Plan for the Engram/PLE lookup table, which takes about 28.8 GB of pinned system RAM even with every decoder layer on the GPU. It is loaded from disk at startup, and the GPU fetches the rows it needs over PCIe, so the full table never occupies VRAM.
Keep the original GGUF shards in place, because the prepared artifact points at their weight
data. To accept images, also download the matching mmproj-Qwen3.8-Flash-Next-BF16.gguf from
the same release and add --vision --mmproj ~/models/mmproj-Qwen3.8-Flash-Next-BF16.gguf.
The vision tower stays BF16. Chat completions and decisions both accept images, including
several images per request and image requests with thinking on. Adapters with native GGML shared
experts aren’t supported yet.
The Decisions API works with this model for choice, noul and score
questions, shared state and option-order averaging. With thinking: true, decisions use
Qwen’s reasoning markers: an uncertain question generates a thought, then scores the choices
after </think>\n\n. You can’t combine thinking with option-order averaging. Chat generation
uses Qwen’s own thinking template through chat_template_kwargs.enable_thinking.
Using CPU cores and an expert cache
Section titled “Using CPU cores and an expert cache”Every supported MoE generation model can cache its most used offloaded experts on the GPU and send some expert computation to the CPU cores (see MoE expert cache). For example:
surogate serve ~/models/Qwen3.8-Flash-Next-00001-of-00004.gguf \ --port 8080 \ --max-num-seqs 16 --max-model-len 4096 --kv-capacity auto \ --host-moe-layers all --cpu-moe-share autoThe expert cache sizes itself from the free GPU memory. Start with the automatic settings, and
use --expert-slots N only if you need to set its size yourself. Higher concurrency or a longer
context leaves less memory for this cache.
The cache can be smaller than one layer’s experts, which lets automatic placement keep more model weights on the GPU. A smaller cache can mean more work during prompt processing, so try automatic sizing before you pick a smaller count. With a cache smaller than one layer, CPU sharing only applies to small decode batches, and prompt processing and wider batches compute experts on the GPU. If you want CPU sharing during prompt processing, give the cache at least one layer’s worth of experts.
--cpu-moe-share auto measures the machine at startup to decide how much work to send to the
CPU. --cpu-moe-prefill-share sets the CPU share during prompt processing, and 0 turns it off.
Offloaded experts get a precision chosen automatically from their source weights.
--host-expert-bank q4 forces four-bit storage to save system RAM, which can cost quality when
the source has higher precision. --host-expert-bank w8 stores eight-bit weights and uses more
RAM.
Using several GPUs
Section titled “Using several GPUs”Use --devices to spread a supported model across several cards (see Devices):
surogate serve ~/models/Qwen3.8-Flash-Next-00001-of-00004.gguf \ --devices 0,1,2,3,4,5,6,7 \ --max-num-seqs 64 --max-model-len 2048 --kv-capacity autoThis splits the model into one pipeline stage per card, which is what a model too large for one
card needs. If the model fits on one card, add --data-parallel instead: every card then serves
a whole copy of the model under the same name, which multiplies throughput. See
Pipeline or data-parallel.
How much memory you need depends on the model, the context length and the concurrency. Add
--host-moe-layers auto when the model needs system RAM as well. Supported models can also use
MTP across several GPUs if their checkpoints include the draft weights; see
Devices for the families. DFlash works with pipeline serving too.
Preparing a DFlash pair
Section titled “Preparing a DFlash pair”For a Muse-Glimmer GGUF, pass its separate assistant with --dflash-model when you start the
server; see Muse-Glimmer. The preparation example below is for Qwen3.5,
and the Gemma 4 mixture’s comes after it.
Use a DFlash drafter trained for your exact target checkpoint. For example, Qwen/Qwen3.5-4B has a matching z-lab/Qwen3.5-4B-DFlash drafter. Download both checkpoints, then prepare them together:
python -m surogate.serve.convert.qwen3_5.convert \ --model /path/to/Qwen3.5-4B \ --dflash-model /path/to/Qwen3.5-4B-DFlash \ --out /path/to/qwen35-4b-dflash.sinfer
surogate serve /path/to/qwen35-4b-dflash.sinfer \ --devices 0,1 --vision --spec dflash --draft-tokens 3 --kv-cache-dtype fp8Use --device 0 for a single GPU. Each pipeline GPU needs room for its share of the target,
the drafter and the cache. Sleep/wake and completed-turn cache reuse still work. The example
accepts text, images and videos. For a smaller text-only artifact, add --no-vision when you
prepare it and leave out --vision when you serve it. Use --kv-cache-dtype bf16 if you want
higher cache precision.
The Gemma 4 mixture pairs with z-lab/gemma-4-26B-A4B-it-DFlash, for the base model, its fine-tunes, or an NVFP4 export of either:
python -m surogate.serve.convert.gemma_vl.convert \ --model /path/to/gemma-4-26B-A4B-it \ --dflash-model /path/to/gemma-4-26B-A4B-it-DFlash \ --out /path/to/gemma4-26b-dflash.sinfer
SUROGATE_SERVE_DFLASH_PACKED_PREFILL=1 \ surogate serve /path/to/gemma4-26b-dflash.sinfer --vision --spec dflash --draft-tokens 7A DFlash 2 drafter, such as
incoai/Qwen3.8-27B-DFlash2 or
incoai/Qwen3.6-35B-A3B-DFlash2, is
prepared the same way, with --dflash-model, for any target that serves DFlash, NVFP4 exports
included. It adds a two-tap convolution over the block’s rows around every attention and
feed-forward sublayer, plus a candidate selector. The selector takes the 16 best draft tokens per
position and walks them left to right, scoring each token after the one chosen before it,
instead of taking each position’s best token on its own. Its blocks are 8 tokens, so serve it
with --draft-tokens 7 or fewer. To measure what the selector adds,
SUROGATE_SERVE_DFLASH_SELECTOR=0 drafts each position’s best token instead.
Inkling-2-Mini (and its fine-tunes) takes
incoai/Inkling-2-Mini-DFlash2 the same way, through
python -m surogate.serve.convert.inkling2 MODEL OUT.sinfer --dflash-model /path/to/Inkling-2-Mini-DFlash2. The
artifact keeps the release’s own DSpark drafter beside it; --spec dflash then serves the DFlash 2 drafter, and
SUROGATE_SERVE_INKLING_DRAFTER=dspark serves DSpark from the same artifact. The drafter reads DSpark’s four target
features and the target’s normalized input embedding. On a DGX Spark with Surogate3.8-26B-A3B (Inkling-2-Mini plus a
writing LoRA), one stream, eight prompts (code, prose, Romanian, math, tool calls, JSON): greedy 55 tokens/s against
44 for DSpark with --spec-adaptive, 46 against 43 at temperature 1, and 102 against 92 tokens/s in total at four
streams; --draft-tokens 7 without --spec-adaptive was the fastest DFlash 2 setting.
The drafter was trained against the base model, and a fine-tune accepts fewer of its drafts,
so measure acceptance on your own prompts. With real tool calls at 100k-200k tokens of context,
Surogate3.7-35B-A3B (a fine-tuned merge) accepted 26-27% of the stock Qwen3.6-35B-A3B DFlash 2
drafter’s tokens and 78-81% of its own MTP head’s, so it is served with --spec mtp --draft-tokens 3. On a fine-tuned 26B-A4B, seven draft tokens were faster
than three or fifteen, and faster than --spec-adaptive. Speculation speeds up generation,
including the thinking of a decision request with "thinking": true. It can’t speed up one-pass
decisions, which generate a single token.
By default, a speculative server prefills waiting prompts one at a time, so under load it
answers fewer one-pass decisions per second than the same model without speculation.
SUROGATE_SERVE_DFLASH_PACKED_PREFILL=1, as in the example above, lets a DFlash server prefill
them together, the way a server without speculation does. With experts stored as W8, its
decisions then match a server without speculation bit for bit.
Several models on one GPU
Section titled “Several models on one GPU”You can serve several models from one server: add each with --model name=path, and clients
pick one by name in the request’s model field (see
Serving several models from one process).
For now, every model after the first must be a prepared .sinfer cache file. To prepare one,
start it on its own first:
surogate serve Qwen/Qwen3.5-0.8B --served-model-name smallNote the cache path it prints during preparation, then stop that server. Use the path in place
of /path/to/cached-small.sinfer below. Cache files normally live in ~/.cache/surogate/serve.
surogate serve nvidia/Qwen3.6-27B-NVFP4 --served-model-name big \ --model small=/path/to/cached-small.sinfer,max-num-seqs=16,max-model-len=8192 \ --kv-capacity auto --max-model-len 8192 --max-num-seqs 16 --port 8080The first model accepts a repo id, a local safetensors directory or a GGUF as usual; the
others take cache paths. /v1/models lists every available name.
To put an additional model on another GPU, append ,device=1 to its --model value, or
,devices=2:3 for a separate GPU group. Without that, it uses the primary model’s GPUs. You can
also load the same artifact under different names to serve independent replicas from one
server. See Devices for examples.
Cache memory grows with demand
Section titled “Cache memory grows with demand”By default, each model’s conversation cache takes GPU memory as requests need it, instead of reserving its full capacity up front. The server can keep reusable prompts after a request finishes, so an idle model’s memory use doesn’t always drop to zero.
/kv_stats shows cache memory use (see Monitoring memory and requests).
--no-elastic-kv reserves the full cache instead; with that setting, each additional model
needs an explicit kv-tokens=N budget.
Sharing unused cache memory
Section titled “Sharing unused cache memory”Add --elastic-kv-overcommit to let models use spare GPU memory beyond their own cache
budgets:
surogate serve nvidia/Qwen3.6-27B-NVFP4 --served-model-name big \ --model small=/path/to/cached-small.sinfer,max-num-seqs=16,max-model-len=8192 \ --elastic-kv-overcommit --kv-capacity auto --max-model-len 8192 --max-num-seqs 16With this option, --kv-capacity sets each model’s guaranteed minimum. auto reserves enough
for one full-context request per model, and further requests share the free memory. When memory
is tight, new requests may wait for others to finish, and a request that waits too long expires
according to --pending-timeout-ms.
Models that do not fit together
Section titled “Models that do not fit together”Add --enable-sleep-mode to let the server put models to sleep in system RAM and wake them
when a request needs them (see Sleep mode). You need enough RAM for their
saved state. A request for a sleeping model waits while the server makes room and restores it.
Give frequently used models priority=high in their --model settings, or use
--model-priority high for the first model. The server puts idle lower-priority models to sleep
first. The CLI reference explains how
priorities affect waiting requests.
Embedding model, CPU and GPU
Section titled “Embedding model, CPU and GPU”Start an embeddings server with --embed (see encoder models).
EmbeddingGemma and Harrier Q8_0 GGUF models run on an NVIDIA GPU or on a CPU with AVX-512.
| Model | Embedding dimensions | Maximum tokens |
|---|---|---|
| EmbeddingGemma 300M | 768 | 2,048 |
| Harrier OSS v1 270M | 640 | 32,768 |
| Harrier OSS v1 0.6B | 1,024 | 32,768 |
| Harrier OSS v1 27B | 5,376 | 32,768 |
For example, start Harrier with:
surogate serve --embed ./models/harrier-oss-v1-0.6B-Q8_0.gguf --device 0Harrier returns normalized embeddings. For retrieval, put a task instruction in each query
input, such as Instruct: Find passages that answer the question\nQuery: What is the capital of France?,
and send documents as plain text. The client supplies the instructions; the
Harrier model card lists them for other
tasks.
The 27B Q8_0 model needs roughly 29 GB of GPU memory for its weights, plus memory for the
input. If a long input doesn’t fit, shorten it or use --device cpu with enough system RAM.
On GPU
Section titled “On GPU”surogate serve --embed ~/models/embeddinggemma-300M-Q8_0.gguf \ --host 0.0.0.0 --port 8413 --device 0The GGUF includes its tokenizer. To use separate tokenizer files, pass --frontend DIR
pointing at a directory with tokenizer.model and tokenizer_config.json.
On CPU
Section titled “On CPU”Use --device cpu. On a machine with 16 physical cores in one NUMA node, for example:
OMP_WAIT_POLICY=ACTIVE OMP_NUM_THREADS=16 \numactl --cpunodebind=0 --membind=0 \ surogate serve --embed ~/models/embeddinggemma-300M-Q8_0.gguf \ --host 0.0.0.0 --port 8413 --device cpuSet OMP_NUM_THREADS to the number of physical cores in one NUMA node; don’t count SMT threads
as extra cores (see CPU environment). Keeping compute and memory on
the same node can help performance. Change 16 and the node number to match your machine.
Sending an embedding request
Section titled “Sending an embedding request”The API request is the same on either device:
curl http://127.0.0.1:8413/v1/embeddings \ -H 'Content-Type: application/json' \ -d '{"input":"the capital of France"}'The served model name is the model argument you started the server with, local file path
included, and /v1/models lists it. An embedding request can leave out model to use the
running model; if it sends one, it must match that name, and an unknown name returns HTTP 404.
--served-model-name NAME at startup replaces the inferred name.
Leave out dimensions for the full embedding, or set it to a positive integer up to the
model’s output width for a shorter, normalized vector; "dimensions": 128 returns
128 coordinates. encoding_format accepts "float" (the default JSON array) or "base64"
(base64-encoded float32 values). Both options work on CPU and GPU and apply to every input in a
batch. Invalid dimensions, formats, token IDs or input lengths return HTTP 400.
Use a GPU when embedding speed matters most and a card is free. CPU serving makes sense when the GPU is busy with text generation, on CPU-only hosts, or for modest retrieval workloads.
Next: the OpenAI-compatible API covers the requests these servers answer, and the CLI reference lists every serving flag.