Options and API

The server is tqserve. tqserve --help prints the same list. In Docker, a few variables set the common options and anything else goes after the image name.

HTTP API

OpenAI-compatible, on 127.0.0.1:8086 by default.

EndpointWhat it does
POST /v1/chat/completionschat, with streaming, reasoning and images (with --mmproj)
POST /v1/completionsplain text completion
GET /v1/modelsthe served model
GET /healthstatus, engine commit and the memory fit's choices (fit)
GET / POST /admin/slotsread or change the live number of parallel requests

Each response reports its own timing (prompt and decode tok/s, drafted and accepted tokens). top_k accepts 0 to INT_MAX (sampling uses at most 16 candidates); seed accepts 0 to 9007199254740991, and negative seeds are rejected with HTTP 400.

Docker variables

VariableDefaultSets
MODEL_FILEthe GGUF to serve
TOKENIZER_FILEfrom the GGUFtokenizer override
DRAFT_MODEL_FILE, DRAFT_VOCAB_FILEDFlash2 drafter and its token list
KV_FORMATbf16KV cache format, e.g. tq3
CONTEXT16384context, split across parallel slots
PARALLEL1requests served at once
MAX_TOKENS1024default output cap
REASONINGoffthinking mode

Model and serving

OptionDefaultWhat it does
--model FILE / --model-dir DIRthe GGUF (or a safetensors directory) to serve
--tokenizer FILEthe GGUF itselfonly for safetensors or a deliberate override
--host IPv4, --port N127.0.0.1, 8086where the API listens
--context N2048context per server, split across --np slots; the memory fit may lower it
--max-tokens N512default output cap per request
--np N1requests served at once (batched verify)
--name NAME, --system TEXTmodel name in the API; a default system prompt
--api-key KEY / --api-key-file FILErequire a bearer key
--mmproj FILEvision projector for image input (--image-min-tokens, --image-max-tokens)
--repeat-limit N256end a request after N identical tokens in a row (0 off)

Reasoning and chat templates

OptionDefaultWhat it does
--reasoning on|offoffthinking mode
--reasoning-effort low|medium|xhigheffort hint for the template
--reasoning-budget N-1thinking token budget (-1 unlimited, 0 end now)
--reasoning-answer-reserve N8192tokens kept for the answer after a budgeted think
--jinja / --no-jinjajinjathe model's Jinja chat template, or the native Qwen layout
--chat-template-file FILE, --chat-template-kwargs JSONoverride the template or pass template variables

Speculative decoding

OptionDefaultWhat it does
-md FILE, --draft-vocab FILEDFlash2 drafter and its token list; the output equals decoding without it
--draft-max N7drafted tokens per step
--no-treetree onverify a single draft chain instead of a token tree
--draft-window NGGUF valuedrafter attention window (0 = whole context)
--draft-retrieve N0N far chunks of the prompt in the drafter window; faster on long prompts, ~20 KB per token of memory
--lookup L [--lookup-first K]offprompt-lookup drafts next to the tree
--mtpoffdraft with the model's own MTP head (text-only, greedy, one user)
--mtp-from N0with -md and --mtp: prompts of N+ tokens draft with MTP

KV cache and long context

OptionDefaultWhat it does
--kv FORMAT / -ctk K -ctv Vbf16KV format; --list-kv lists them (tq3, trellis tcq3 / tcq2, q8, q4, splits)
--kv-host Nmemory fitKV positions kept in system RAM (exact)
--kv-stage on|offonstream the RAM part back layer by layer while decoding
--kv-compact Roffcompress old KV R-fold (not exact; one slot)
--prompt-cache on|offoffkeep the previous turn's KV for follow-ups (one slot)
--rope-scaling none|linear|yarnnonecontext past the trained length (--rope-scale, --yarn-orig-ctx)

Memory fit and prefill

You normally pass only --context (and --np). If that does not fit at full settings, the server picks what fits and prints one line, for example:

tqserve: fit: to fit 1 slot(s) x 131072 in GPU memory: KV cache q4/tcq2 (asked bf16), prefill buffers -ub 512,
prefill FP16 weight blocks of 2048 rows (choose yourself with --kv, -ub, --gemm-rows or a smaller --context)
OptionDefaultWhat it does
-fit on|offonload, measure, and step down until the margin is free
-fitt MiB768 (256 under WSL)free memory to leave on the GPU
-fitc N4096smallest context the fit may choose
-fitl on|offonon: pick compact settings and say so; off: refuse instead
--gemm-rows N0 (fit)prefill FP16 weight blocks of N rows (less VRAM)
-ub Nautomaticprefill chunk size
--prefill-int8 on|offon for RTX 30 / 40 / 50int8 prefill GEMMs
--prefill-fp8 on|offoffFP8 prefill GEMMs (sm_89+); faster prefill on GB10, small accuracy cost
--slot-reserve MiB128free memory per parallel slot; an --np that does not fit is refused
--graph-cache N256captured CUDA graphs kept (~12 MB each, least recently used evicted)
You wantAdd
full-quality BF16 KV, accept a shorter context--kv bf16
bigger prompt buffers (faster prefill, more memory)-ub 2048
exactly what you asked for, or an error-fitl off
several users at a long context (4 x 32K)--np 4 --context 131072
more free memory for other programs-fitt 2048

Diagnostics

Option / variableWhat it does
--list-kv, --list-flagsKV formats; every environment flag with its status
TQLLM_DEBUG=key,...memlog, profile, steps, stageprof, matvec, tune, prefill, draft, tree_chain, ...
TQLLM_MATVEC_RULE=BITS:KERNEL[:PF],...override the decode matvec kernel per format

Tokenizer conversion

GGUF models need no tokenizer file: tqserve reads it from the GGUF metadata. Only safetensors checkpoints, or a deliberate --tokenizer FILE override, need a tokenizer.tqtok, built from tokenizer.json and tokenizer_config.json of the same model family. It needs Python 3, not PyTorch:

python3 tools/tqconvert.py --source /path/to/hf-tokenizer --out-dir models --tokenizer-only