Inference
EngineSurogate EngineYou serve models with the same CLI you train them with. Start a server, then point any OpenAI- or Anthropic-compatible client at it:
surogate serve Qwen/Qwen3.6-27B --port 8080Features
Section titled “Features”- Chat and text completion, with streaming responses, tool calls, and separate reasoning output.
- Concurrent requests: set
--max-num-seqsto the number of requests to process at once. - Prompt caching: compatible earlier prompts are reused, which cuts processing time.
- Speculative decoding: speed up supported models with MTP or DFlash (
--spec). - Models larger than GPU memory: use system RAM for part of a model, or spread supported models across several GPUs.
- Several models across GPUs, with per-model placement and optional sleep mode to free memory when a model is idle.
- Images and video for supported vision models (
--vision). - Embeddings on GPU or CPU through
surogate serve --embed. - Romanian speech recognition with file uploads and live partial transcripts through
surogate serve --stt. - Romanian speech generation on CPU, with named and cloned voices through
surogate serve --tts.
See Serving models for worked examples.
Loading a model
Section titled “Loading a model”The model argument can be a Hugging Face repo id, a local safetensors directory, or a GGUF file:
surogate serve Qwen/Qwen3.6-27Bsurogate serve ~/models/qwen3.6-27b-hf/surogate serve ~/models/qwen3.6-27b-Q4_K_M.ggufSurogate reads the model’s dimensions and context limit from config.json, or from the GGUF
metadata. Keep the checkpoint’s configuration and tokenizer files alongside local safetensors
weights. Renaming the directory or setting --served-model-name only changes the name the
model is listed under. The model size and settings stay the same.
The served ID defaults to the model argument you passed, so a repository ID or local path
stays as you typed it. Set --served-model-name to choose another ID. /v1/models lists
the names the server accepts. This applies to text-generation, embedding, and speech servers.
The first start prepares the model and saves reusable files under ~/.cache/surogate/serve.
Later starts skip preparation but still take time to load the model. Set
SUROGATE_SERVE_CACHE to use a different cache directory; --no-cache rebuilds an entry.
Changes to local configuration, tokenizer, or chat-template files trigger fresh preparation.
Supported GGUF weights are read from the original file, so preparation doesn’t need a second full copy of the model. Keep the GGUF files at their original paths while using the cache. For a split GGUF, pass the first shard; the remaining shards are found automatically.
Preparation includes the model’s tokenizer and chat template. You can use a base model without
a chat template through /v1/completions.
To serve a model you trained here, merge its adapter first. You can serve the merged
safetensors directory directly or create a GGUF with surogate quantize; see the
CLI reference.
Supported quantizations
Section titled “Supported quantizations”Surogate detects the quantization from the model files, so there is no serving flag for the weight format. Supported formats depend on the model family and export:
| Format | What to know |
|---|---|
GGUF K-quants (Q2_K through Q6_K) | Supported models retain the GGUF’s weight quantization |
GGUF Q8_0 | Eight-bit weights; preparation preserves their values |
| Other GGUF formats | Includes Q4_0, Q5_0, Q4_1, Q5_1, and supported IQ formats; availability depends on the model |
| BF16 safetensors | Prepared using the model family’s conversion settings |
| NVFP4 checkpoints | Four-bit floating-point weights for supported Blackwell GPUs |
| FP8 checkpoints | Block-scaled exports (quant_method: fp8, 128 x 128 blocks) keep their FP8 weights on Qwen3, Qwen3-VL, Qwen3.5/3.6/3.8 and its MoE models, Llama, Gemma 3, the dense and E-series Gemma 4, and LFM2. Row-scaled exports keep them on Qwen3.5/3.6/3.8 and are converted to 8-bit weights on the others |
Preparing model files
Section titled “Preparing model files”| Source | First-start behavior |
|---|---|
| Supported GGUF | Prepare cached metadata and read supported weights from the source files |
| Hugging Face repo | Download the checkpoint, prepare it, and cache the result |
| Local safetensors directory | Prepare and cache the model without downloading the checkpoint |
| NVFP4 export | Detect its quantization settings; some exports also need a compatible base checkpoint for missing model files |
Weight precision and prompt-cache precision are separate settings. Host offload also has its
own precision option: forcing --host-expert-bank q4 can reduce the precision of weights
originally stored at more than four bits.
KV cache precision
Section titled “KV cache precision”The KV cache holds what the model computed for earlier tokens, so it can continue a response
without processing the whole conversation again. Set its precision with
--kv-cache-dtype auto|fp8|bf16|int8.
The default, auto, picks a setting for the model: BF16 for models such as Qwen3 and
Llama, and FP8 for hybrid models such as Qwen3.5/3.6/3.8. Explicit fp8 uses half the cache
storage of BF16; explicit bf16 keeps BF16 regardless of model family. Changing cache
precision can affect output quality. int8 is also available for comparison.
With an FP8 cache on compute capability 12.x GPUs (RTX 50 series, RTX PRO 6000, DGX Spark),
prompt attention in layers without a sliding window multiplies the attention probabilities,
rounded to FP8, with the cached values on the FP8 tensor cores. On a DGX Spark this makes prompt
attention about a third faster, with the same accuracy in our measurements. Set
SUROGATE_SERVE_PROMPT_ATTENTION_FP8_PV=0 to keep that product in BF16 (see
Environment).
DFlash supports BF16 and FP8 caches. Use --kv-cache-dtype fp8 to reduce cache memory.
Model families
Section titled “Model families”Surogate detects the family automatically. Available formats and optional features vary by model:
| Family | Notes |
|---|---|
| Qwen3 | Dense models |
| Qwen3-VL | Dense and MoE safetensors or GGUF checkpoints; text, images, and video (--vision). GGUFs need a matching --mmproj file. |
| Qwen3 MoE | Mixture-of-experts models |
| Llama | Includes TinyLlama |
| MiniCPM5 | Hugging Face safetensors and GGUF; thinking can be enabled or disabled |
| Spark-X2.5 | Hugging Face safetensors; thinking can be enabled or disabled |
| Gemma 3 | Text generation; images and sampled video frames on vision-enabled checkpoints |
| Gemma 4 | Text, images and video with dense, E-series, and mixture-of-experts models; NVFP4 exports and DFlash speculation for the 26B-A4B mixture |
| LFM2 / LFM2.5 | Dense text models from Hugging Face safetensors or GGUF |
| LFM2-MoE | Hugging Face safetensors and GGUF |
| LFM2-VL / LFM2.5-VL | Text, images and sampled video frames from safetensors or paired GGUF files; use --vision |
| Qwen3.5/3.6/3.8 | Includes BF16 and NVFP4 exports |
| Qwen3.5/3.6 MoE | Includes 35B-A3B and 122B-A10B; ModelOpt mixed-precision exports (weight-only NVFP4 experts and head, FP8 attention) such as Ornith-1.5-122B-NVFP4; optional speculative decoding |
| Qwen3.8 Flash-Next | GGUF; supports CPU offload |
| GLM-5.3-Flash | GGUF; supports CPU offload, multiple GPUs, and MTP |
| EmbeddingGemma 300M | Embeddings on GPU or CPU |
Model size is read from the checkpoint. Its format and features must still be supported: the server refuses an unsupported checkpoint with an error message.
LFM2, LFM2.5, and LFM2-MoE GGUF files include their configuration, tokenizer, and chat template, so no separate Hugging Face download is needed. They are prepared as 8-bit serving weights; lower-bit GGUFs can therefore require more disk space and memory after preparation.
Hardware
Section titled “Hardware”Supported GPU builds target NVIDIA Ada, Hopper and RTX Blackwell cards, including RTX 4070/4090, L4/L40, H100/H200, RTX 5070/5080/5090, and RTX Pro 6000 Blackwell, and the DGX Spark’s GB10 on aarch64. The accelerated NVFP4 path requires RTX Blackwell (SM120) or GB10 (SM121); on Hopper, serve FP8, GGUF or BF16 checkpoints instead.
On the DGX Spark the GPU shares the machine’s 128 GB with the system. The engine counts as free
what the system can still hand over (MemAvailable from /proc/meminfo, which includes
reclaimable page cache) less 8 GiB it leaves to the host; set
SUROGATE_UNIFIED_MEMORY_RESERVE_MIB to keep more or less back. --kv-capacity auto also
leaves 2.5 GiB for the engine’s own host memory, which grows by about that much while it warms
up and captures its graphs, so a full cache still leaves the host its reserve; set
SUROGATE_UNIFIED_MEMORY_STARTUP_MIB to change that figure. Sleep mode is not available
there: with no separate system RAM to park a model in, sleeping would free nothing.
See the CLI reference for models that can use several GPUs.
CPU-only serving supports embedding models and requires AVX-512. Generative models need an NVIDIA GPU even when some work is offloaded to the CPU.
- OpenAI-compatible API: endpoints, request fields, and supported client features.
- CLI and parameters: options and defaults.
- Serving models: NVFP4, GGUF, offload, and embedding examples.