Skip to content

Latest commit

 

History

History
535 lines (441 loc) · 34.6 KB

USAGE.md

File metadata and controls

535 lines (441 loc) · 34.6 KB

Usage

Every command, flag and environment variable of rustingstrata. Install and quick start: README. A server for other people: HOSTING.md. Measured speeds: BENCHMARKS.md.

Commands

Command What it does
(none) Starts the server on http://127.0.0.1:8080 and opens the chat page.
interface Asks for the model, the mode and the main settings, then runs the command they make.
chat --model M Chat in the terminal. -n limits a reply (default 2048 tokens).
generate --model M --prompt TEXT Generates -n tokens (default 32). --prompt - reads stdin.
serve Chat page and API server. See Server API.
bench --model M Speed test. Defaults: --pp 512,4096, --tg 128, --reps 3.
calibrate --model M Measures the best settings for this machine. See Calibration.
stats Prints what serve answered over all runs, by model and by API key name.
update Replaces the binary with the newest release. update --check only checks.
info, check, perplexity, score Developer tools. Run them with --help.

A failed command prints one error: ... line and exits with status 1. Colours go only to a terminal. NO_COLOR=1 turns them off.

serve adds each answered chat to usage.json next to the default models folder (~/.local/share/rusting_strata/usage.json on Linux). Delete the file to start stats again.

Terminal

rustingstrata interface asks for the model, the mode (terminal chat, chat page, API server or speed test), GPU or CPU, the context length and, for a server, the address. Enter takes the default in brackets. It prints the command it runs, so you can copy it.

  • Models: the last 10 picked here, the models folder, and the Hugging Face and llama.cpp caches. The last row takes a path to a file or a folder. --models-dir DIR lists another folder.
  • GPUs: every NVIDIA card by default. For other cards type their numbers, such as 0,1.
Flag Default What it does
--pretty off Status panel on stderr instead of the timestamped speed logs. Needs a terminal, not TERM=dumb.
--graph off Adds Braille graphs of prefill and decode speed. Requires --pretty.
--status-interval T 500ms with --pretty, else 2s 100ms through 5s. Or STRATA_STATUS_INTERVAL; the flag wins.

update works on Linux and Windows x86_64. The old binary stays as rustingstrata.old until the next update. A source build is replaced by the release build. A binary under /usr/ or /opt/ (the AUR package rustingstrata-bin) or in winget's or Scoop's folders is left alone: use the package manager.

At start, serve and a double-clicked binary ask GitHub once, with a 5 s limit, and print one line if a newer release is out. STRATA_NO_UPDATE_CHECK=1 turns that off.

Chat page

rustingstrata with no arguments opens the chat page. Chats are kept in the browser. The page offers these models:

  • The models folder: %LOCALAPPDATA%\rusting_strata\models on Windows, ~/.local/share/rusting_strata/models elsewhere, or serve --models-dir.
  • GGUF files in the Hugging Face cache (~/.cache/huggingface/hub, HF_HUB_CACHE, HF_HOME) and in llama.cpp's cache (~/.cache/llama.cpp, LLAMA_CACHE).
  • Downloads from Hugging Face. Set HF_TOKEN for gated repos.
  • A .gguf file by the full path the server sees. In a container that is a path inside the container.

Empty sampler fields in the settings leave the server's flags in effect. #selftest after the address runs the page's checks.

The models tab sets --ctx, --kv, --cache-ram, --vram-margin, --mtp, --chunk, --parallel, --device and --auto-unload. "Apply and reload" loads the model again with them. They stay until the server restarts. --threads is not there: the thread pool is made once, at the first load. For a GPU model with no calibration file the page offers "calibrate".

POST /api/load does the same for a script, with the admin key only. It takes "path", "calibrate": true and "options": ctx, kv, cache_ram, vram_margin, mtp, chunk, parallel, device as a string such as "0,1", auto_unload in seconds (0 for never), status_interval, pretty and graph.

Tools (MCP)

The chat page can call the tools of Model Context Protocol servers. List them in a JSON file, in the format other MCP clients use. Pass it with serve --mcp FILE or STRATA_MCP. The default is mcp.json in the rusting_strata folder that holds the default models folder.

{"mcpServers": {
  "files": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/me/notes"]},
  "docs":  {"url": "https://example.com/mcp", "headers": {"Authorization": "Bearer ..."}}
}}
  • The tools switch beside think turns tools on. The tools tab in settings lists the servers and their tools, and says why a server did not start. Untick a server or a tool to keep it from the model.
  • Each call waits for your answer unless "run tools without asking" is on. The tab also limits the tool rounds per reply and the length of a tool result.
  • Tool definitions cost context and prefill time. The model needs a chat template with tool calls. The Qwen families have one.
  • Only text results work. Resources, prompts, sampling and OAuth sign-in are not supported.
  • STRATA_MCP_TIMEOUT (seconds, default 120) limits one answer from a server.
  • On Windows a command starts through cmd /c. This path is not tested yet.
  • API clients send their own tools and are not affected.

The routes are GET /api/mcp, POST /api/mcp/reload and POST /api/mcp/call. With keys set they need the admin key. Without keys they answer only requests from the same computer that name it localhost, 127.0.0.1 or [::1] and carry no proxy header (Forwarded, X-Forwarded-*, X-Real-IP). Behind a reverse proxy or a tunnel always set --api-key: a proxy that adds no such header looks like a local browser.

Flags

Flags apply to chat, generate, bench and serve unless noted. A load prints the values it uses and where each came from:

settings: ctx 32768, kv q8, chunk 2048 (calibration), mtp 1 (preset), short 32 (default), threads 6 (default), cache-ram 4096 MB

Model and device

Flag Default What it does
--gpu off Runs on the GPU. Experts that do not fit in VRAM run on the CPU.
--backend NAME cuda if it loads, else vulkan cuda, vulkan or hip (AMD through ROCm, see HIP.md).
--device LIST 0 GPU index, or several. See Several GPUs.
--fast-cpu off Without --gpu: a faster CPU path, for a machine without a usable GPU.
--threads N calibrated, else the cores CPU threads for expert work. Linux --gpu and --fast-cpu runs count physical cores, other runs logical ones.
--mmproj PATH an mmproj*.gguf next to the model Projector for image input. See VISION.md.
--lora PATH:SCALE none LoRA adapter at run time. See LORA.md.
--ple FILE below Qwen3.8 Flash-Next: the GGUF with the n-gram table. Or STRATA_PLE.
--preset FILE none Reads flags from a file. See Presets.
  • --fast-cpu: on an i5-8365U with UHD 620, Qwen3.5 2B IQ4_XS decodes 7.6 tok/s against 2.5 tok/s on Vulkan. Greedy text can differ from the CPU reference at a near tie.
  • DeepSeek, GLM, Hy4, Inkling 2, Kolibri and Gemma 4 ignore --fast-cpu. Models with multiple PLE layers and SenseNova-Loop (sensenova_loop) prefill token by token.
  • Q1_0, PQ2_0, Q8_1, Q8_K and MXFP4 files run only on the CPU. PTQ1_0 weights (Ternary Bonsai from PrismML) are copied at load: 34/28 of the file's size in RAM, 6.3 GB for the 27B.
  • --ple: a model file with no table (per_layer_token_embd.weight, a -noPLE file) takes the one .gguf next to it whose name has PLE in it. With none or several, the load stops and asks for --ple. The flag also names the shard of a split model that is in another folder. With your own table in --ple, the shard that held the old table can be deleted: the load skips the one missing shard. See MODELS.md.

Context and memory

Flag Default What it does
--ctx N 4096 KV cache size in tokens.
--vram-margin MB 512 VRAM left free. 512,256 is per device in --device order, 0:512,1:256 per GPU index.
--ram-margin MB, --max-ram MB 512, 0 Host RAM left free, or an absolute cap. See LORA.md.
--cache-ram MB 4096 Host memory for parked conversations. See Prompt caching.
--arena off Reads the model into RAM at load instead of mapping it, if it fits with 6 GB to spare.
--tail-skip R 0 (off) Skips low-ranked experts outside VRAM. Faster decode, other answers.
  • --ctx: for Inkling 2, Hy4, GLM, DeepSeek, Kolibri and Gemma 4 it limits prompt plus reply. Their default is the context the model was trained on.
  • --vram-margin 256 keeps more experts in VRAM on a GPU that drives no display (+1-2% prefill). 128 runs out of memory.
  • --arena drops the file from the page cache. Before a later run that maps the model, cat the file to /dev/null.
  • --tail-skip R: a token ranks its picked experts from 0 by routed weight. An expert outside VRAM at rank R or lower is not computed. With Qwen3.6's 8 picks a token, --tail-skip 6 drops at most the last two.
  • On a GTX 1660 SUPER with 1.7 GB of Qwen3.6-35B-A3B's experts in VRAM, --tail-skip 6 decodes 6% faster and changes the most likely next token at 5% of positions. The run ends with a tail skip: N of M CPU expert picks dropped line.
  • --tail-skip works on the main engine and Inkling 2, not with --parallel, and on Inkling 2 not with --fixed-experts. The idea is PolyStrata's route tail skip.

K/V cache

Flag Default What it does
--kv TYPE f16 f16, q8, q4, q2, turbo4, turbo4-3, turbo4-2, turbo3, turbo2 or turbo3-2.
--k TYPE, --v TYPE from --kv CUDA: one half alone, such as --k f16 --v q4. No turbo4-3, turbo4-2, turbo3-2.
  • q8 halves the KV cache (345 instead of 650 MB at 32K). 32K decode is about 6% slower, 32K prefill 14%.
  • q4 and q2 take about 28% and 19% of the f16 size, for very long contexts. q2 differs most from f16.
  • turbo4 (TurboQuant, CUDA only) takes about 28% of the f16 size. The other turbo types are narrower.
  • Every type but f16 rounds keys and values, so the output can differ.
  • The head size must be a multiple of 32. --llama-numerics needs the f16 cache.
  • Vulkan takes f16, q8, q4 and q2, the same type for K and V.
  • Give calibrate the --kv, --k and --v of the runs that will use the result.

Sampling

Decoding is greedy unless --temp is above 0. The penalties and DRY also need a temperature above 0. They count only the tokens of the reply, and not inside a tool call.

Flag Default What it does
--temp T 0 Sampling temperature.
--top-k K 0 (all) Samples only from the K most likely tokens.
--top-p P 1 Top-p.
--min-p P 0 (off) Drops tokens whose probability is below P times the best token's. 0 to 1.
--seed N from the clock Random seed.
--presence-penalty X, --frequency-penalty X 0 As in the OpenAI API, -2 to 2.
--repeat-penalty X 1 (off) Lowers every token among the last --penalty-last-n of the reply. 1.1 is usual.
--penalty-last-n N 64 Window of the three penalties. 0 turns them off, -1 takes the whole reply.
--dry-multiplier X 0 (off) The DRY sampler, against repetition loops.
--dry-base X, --dry-allowed-length N 1.75, 2 DRY base, and the repeat length that stays free.
--force-sampling off serve: ignores the sampling fields of requests.

Thinking

Flag Default What it does
--think false on Turns thinking off (chat and serve).
--thinking-budget N 0 (no limit) Ends thinking after N tokens by inserting </think> (chat and serve).
--reasoning-effort LEVEL none serve: the reasoning_effort of a request that sends none.
--preserve-thinking false on Follows the template. See Prompt caching.

--reasoning-effort takes none, off, minimal, low, medium, high, xhigh, max, or a number from 0 to 0.99 (Inkling 2). Any other value stops the start. none turns thinking off. The levels act only on models whose template reads one. Qwen4 takes xhigh, high and low.

Speed

Flag Default What it does
--chunk N calibrated, else 4096 Prefill chunk in tokens (GPU).
--short N calibrated, else 32 Prompts shorter than N tokens go token by token.
--mtp [N] calibrated, else 0 Drafts N tokens a step with the model's MTP head.
--mtp-model PATH none Takes the MTP head from a companion GGUF.
--draft-model PATH none Drafts with a separate model. Needs --gpu. Not with --parallel.
--spec-type LIST none Drafts from text already in the context, with no draft model.
--spec-draft-n-max N 16 --spec-type: most draft tokens checked per step.
--spec-ngram-size-n N, --spec-ngram-size-m N, --spec-ngram-min-hits N 12, 48, 1 --spec-type: key length, draft window, hits before drafting.
--lookup-cache-static FILE, --lookup-cache-dynamic FILE none --spec-type: lookup cache files.
--prefill-cpu, --cpu-frac F off, adapts Prompt chunks run a share of the experts outside VRAM on the CPU. --cpu-frac fixes the share, 0 to 1. Output can differ slightly.
--pin off Pins the CPU expert threads to physical cores. Measured on one machine only.
--host-share N 0 (off) Needs --arena, CUDA. It was slower in every measurement.
--no-fused off Uses the two-pass CPU expert path.
--fixed-experts off Never moves experts, for runs that repeat. Or STRATA_FIXED_EXPERTS=1.
--llama-numerics off Matches llama.cpp's numerics for parity runs. Slower.
  • --chunk: without the flag, a GPU load that runs out of VRAM halves the chunk down to 512 and says so. With the flag the load fails.
  • --mtp needs a GGUF with an MTP head, such as the Qwen3.6-35B-A3B MTP files. MODELS.md says which models have one and which need --mtp-model.
  • Drafts pay only when most experts are in VRAM. With CPU experts on most tokens, --mtp 1 decodes slower than no drafts.
  • Drafts keep the sampling distribution. Greedy output can differ at a near tie. A request with a grammar or a logit bias runs without drafts.
  • --draft-model takes a DFlash or DFlash2 draft made for this target, or a smaller model with the same vocabulary. It replaces the target's own MTP head. A DFlash file that does not fit the target is refused. --mtp N caps the drafts per step (default 4, or the block size minus one for DFlash).
  • PATH is a .gguf file, a Hugging Face .safetensors file with its config.json next to it, or a directory holding either. A safetensors DFlash checkpoint is converted once, to model-dflash-q4_0.gguf next to the source.
  • --spec-type takes a comma-separated list of suffix, ngram-simple, ngram-map-k, ngram-map-k4v, ngram-mod and ngram-cache. It pays on output that repeats the prompt: code edits, quoting, structured data.
  • Inkling 2 drafts with --draft-model (a DSpark file) and --spec-type, on the GPU only. It ignores --mtp and --mtp-model with a warning.

Server

Flag Default What it does
--model PATH none The model to load. Without it the client or the chat page picks one.
--addr ADDR 127.0.0.1:8080 Address to listen on.
--models-dir DIR the models folder Folder of .gguf models the chat page offers.
--api-key KEY none The admin key: Authorization: Bearer KEY on every request.
--parallel N 1 Requests answered at once (GPU). See Parallel requests.
--max-tokens N what the context leaves Most reply tokens a request may ask for, and the default.
--auto-unload SECONDS never Frees the model after this time without a chat request.
--alias NAME the file name Model name in /v1/models and in the replies.
--no-webui off Serves only the API. / answers 404.
--cors-origin LIST none Origins whose pages may call the server from a browser, or *.
--allowed-hosts LIST STRATA_ALLOWED_HOSTS Allows a LAN name such as ai-server.lan when bound to 0.0.0.0.
--mcp FILE STRATA_MCP See Tools (MCP).
--slot-save-path DIR, --prompt-cache FILE none See Prompt caching.
--api-keys FILE, --usage-log FILE none Customer keys and the request log. See HOSTING.md.
  • --auto-unload 600 frees the VRAM and the process memory after 600 seconds. The next chat request loads the model again and prefills its whole prompt. Meanwhile the model stays in /v1/models, and /health answers 200 {"status": "ok", "unloaded": true}.
  • --cors-origin http://127.0.0.1:9999 answers a preflight OPTIONS with 204 before the key check. Set --api-key with it: without a key any page the browser opens may use the server.

Presets

--preset FILE goes after the command. The file has one name = value line per flag, named with - or _.

# qwen-32k.toml
model = "/models/Qwen3.6-35B-A3B-UD-Q2_K_XL.gguf"
ctx = 32768
kv = "q8"
fixed_experts = true
device = [0, 1]
rustingstrata serve --preset qwen-32k.toml --ctx 8192   # a flag on the command line wins
rustingstrata calibrate --preset qwen-32k.toml          # writes the tuned chunk, mtp and short into the file
  • A key that only another command takes is skipped, so one file serves serve, chat and calibrate.
  • A key that is no flag at all is an error. A flag can be set to true but not turned off from the file.
  • calibrate --preset replaces the lines the file had and keeps the comments.

Calibration

rustingstrata calibrate --model model.gguf
rustingstrata calibrate --model ~/models     # every model in the folder and its subfolders

calibrate measures the best chunk, draft count and short-prompt threshold. Later runs read them unless flags override. The options and the file names are in CALIBRATION.md.

The result goes to ~/.cache/rusting_strata, to $XDG_CACHE_HOME/rusting_strata when that is set, or to %LOCALAPPDATA%\rusting_strata on Windows. In a container, set XDG_CACHE_HOME to a mounted path: docker run --rm otherwise discards the file on exit.

Server API

curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" \
  -H "Authorization: Bearer secret" -d '{"messages": [{"role": "user", "content": "Hello"}], "stream": true}'

# Claude Code. OpenCode and other agents use the OpenAI address.
ANTHROPIC_BASE_URL=http://127.0.0.1:8080 ANTHROPIC_API_KEY=secret ANTHROPIC_MODEL=local \
  ANTHROPIC_SMALL_FAST_MODEL=local claude
Route What it does
POST /v1/chat/completions OpenAI chat completions, streamed or not.
GET /v1/models The loaded model first, then every other model the chat page offers.
POST /v1/messages Anthropic Messages API: text, tool_use and tool_result blocks, the key in x-api-key.
POST /v1/messages/count_tokens Token count of a Messages request.
GET /props As llama-server: default_generation_settings.n_ctx, n_ctx_train, model_alias, total_slots.
POST /tokenize, POST /detokenize As llama-server.
POST /slots/0?action=save Also restore and erase. See Slot save and restore.
POST /v1/vram See Lend VRAM.
POST /api/load See Chat page.
GET /health See HOSTING.md.

Request fields

Field What it does
model A name from /v1/models: the file name without .gguf. Another name than the loaded one switches the model.
temperature, top_k, top_p, min_p, seed Sampling. Greedy when left out.
presence_penalty, frequency_penalty, repeat_penalty, penalty_last_n As the flags in Sampling.
dry_multiplier, dry_base, dry_allowed_length The DRY sampler.
max_tokens, max_completion_tokens Reply limit. Without it and --max-tokens, a reply runs until the model stops or the context is full.
stop, n stop takes up to 16 strings. n must be 1.
logit_bias -100 to 100, added to the logits. -100 and false ban the token.
grammar llama.cpp's GBNF as a string, such as root ::= "yes" | "no" or grammars/json.gbnf.
response_format Makes the reply JSON.
tools, tool_choice As in the OpenAI API. tool_choice: "required" does not force a call.
chat_template_kwargs.enable_thinking Thinking on or off. Anthropic: thinking: {"type": "enabled"} or {"type": "disabled"}.
reasoning_effort "none" turns thinking off on every model. It has priority over enable_thinking.
thinking_budget, chat_template_kwargs.thinking_budget Overrides --thinking-budget. Anthropic: thinking.budget_tokens.
chat_template_kwargs.preserve_thinking Overrides --preserve-thinking.
  • model: replies in progress end first, and the request is answered after the load. An unknown name is answered by the loaded model. A failed load gets 503 with the reason, and the next chat request loads the model that was there before. With API keys only the admin key sees the other models and switches.
  • logit_bias takes the OpenAI object {"15339": -100} and llama.cpp's list [[15339, -100], ["hello", 5], ["hello", false]]. A text applies to each of its tokens. An unknown token id is a 400.
  • grammar: the reply ends only once the grammar is complete. Thinking is off unless enable_thinking turns it on. Then the grammar holds from </think> on. A grammar that does not parse is a 400 with the reason.
  • response_format: {"type": "json_object"} takes any JSON object. {"type": "json_schema", "json_schema": {"schema": {...}}} or llama.cpp's {"type": "json_object", "schema": {...}} takes JSON that fits the schema. {"type": "text"} is the default. With grammar in the same request it is a 400.
  • A schema may use type (one or a list), properties, required, items, enum, const, anyOf/oneOf, allOf of one schema and local $refs (#/$defs/...). Lengths, counts, pattern, format and number bounds are not checked.
  • /v1/messages takes neither grammar nor logit_bias.
  • A request whose last message has role assistant and no tool calls continues that message. The reply holds only the new text.
  • A prompt longer than the context gets 400 with prompt is too long: N tokens, the limit is M (the request exceeds the available context size; raise --ctx). Agents such as Pi start their compaction on it.
  • The prompt follows the model's own chat template, rendered like llama.cpp's --jinja.
  • Inkling 2 with thinking off makes the reply start with the answer, except in a request that declares tools. Per-model thinking levels are in MODELS.md.
  • POST /tokenize takes {"content": "text", "add_special": false, "with_pieces": false} and gives {"tokens": [...]}. With pieces each entry is {"id", "piece"}. POST /detokenize takes {"tokens": [...]} and gives {"content": "text"}.

Replies

  • The reasoning is reasoning_content on /v1/chat/completions, and a thinking block before the text block on /v1/messages. Streamed, its pieces are thinking_deltas, and it stops after an empty signature_delta.
  • Tool calls come back as tool_calls with finish_reason: "tool_calls". A streamed chat sends each call's name as soon as the model writes it. Models with <function=..> calls (Qwen3.5, Qwen3.6, Qwen3 Coder) also stream a string argument as it is written. Other formats and the Messages API send the arguments when the call is complete.
  • Each reply carries usage and llama-server's timings block: prompt_n, prompt_ms, prompt_per_second, predicted_n, predicted_ms, predicted_per_second, cache_n. llama-swap shows the speeds from it.
  • A streamed reply sends its response head before the prompt runs. While the prompt runs, and while a tool call is held back, it sends the SSE comment : keep-alive every 15 s.

Parallel requests

The server answers one request at a time. serve --parallel N (GPU) decodes up to N together. Measured speeds are in HOSTING.md.

  • MTP drafts are off with --parallel. --parallel is lowered to the slots that fit in VRAM.
  • For a model without experts each slot's KV cache starts at 512 tokens and doubles when needed, up to --ctx. A request whose cache cannot grow for lack of VRAM fails alone.
  • From 4 requests decoding at once (16 for a model with experts), one batched forward runs them. Greedy output under load can then differ at near-ties from the same request run alone.
  • An image request (--mmproj) takes a slot too. See VISION.md.

Models outside the main engine

Inkling 2, Hy4, GLM, DeepSeek, Kolibri and Gemma 4 run on their own code path, with these limits. Per-model detail is in MODELS.md.

  • One request at a time. A streamed chat that waits gets its response head after 10 s in the queue, then : keep-alive every 15 s. A refusal after that head is one data: {"error": ...} line.
  • Greedy. logit_bias and grammar work. Inkling 2 also samples (temperature, top_k, top_p, min_p, seed). A seed repeats its text only with STRATA_FIXED_EXPERTS=1.
  • /v1/chat/completions only, no /v1/messages. Tool calls are sent at the end.
  • The slot endpoints and /v1/vram answer 501. calibrate measures their prefill chunk only.

Prompt caching

When a request repeats the previous request's messages and adds new ones, only the new part is prefilled. The reply reports it as usage.prompt_tokens_details.cached_tokens.

  • Qwen3.6's template drops the think block of earlier replies, which forces a full prefill on each new user message. RustingStrata keeps those blocks by default. --preserve-thinking false follows the template.
  • A request with another history, such as an agent's side request for a title, parks the conversation in host memory (--cache-ram). The next request that continues it takes it back.
  • --prompt-cache FILE keeps the last conversation and the newest 4 parked ones over a restart. The file is only read by the same model, --kv and device split, so give each model its own file. With --cache-ram 0 it parks up to 2048 MB.
  • With customer keys, each key reuses only its own cached conversations. See HOSTING.md.

Slot save and restore

serve --slot-save-path DIR turns on llama-server's slot endpoints. They need the admin key and the main engine on the GPU. Without the flag they answer 501.

Request Result
POST /slots/0?action=save with {"filename": "a.bin"} Writes slot 0's cached prompt to DIR/a.bin. Answers n_saved, n_written, timings.save_ms.
?action=restore with the same body Reads it back. Answers n_restored, n_read, timings.restore_ms.
?action=erase Drops it. Answers n_erased.

The next request whose prompt starts with the restored tokens prefills only the rest, even after a restart. A file is only read by the same model, --kv and device split. A file name is letters, digits, -, _ and ., with no folder. Under --parallel the slot ids are 0 to N-1, and a slot that is answering a request is refused.

Lend VRAM

POST /v1/vram with {"reserve_mib": N} shrinks or grows the expert cache until N MiB of the card are free, counting what every program holds. It needs the admin key and the main engine. null or {} goes back to the --vram-margin the model loaded with.

  • Experts that lose their slot run on the CPU, so answers go on, slower.
  • The answer has status, reserve_mib, expert_slots, expert_slots_full, expert_cache_mib, expert_cache_full_mib, vram_free_mib and a devices list, or 400 with the reason.
  • The cache never goes below its floor, so check vram_free_mib against the reserve.
  • An error after the old slots are freed leaves the cache unusable. Load the model again.
  • The request follows PolyStrata's POST /v1/vram.

Several GPUs

rustingstrata serve --model model.gguf --gpu --device 0,1 --split 30,70

--device 0,1 splits the layers over the cards in proportion to their free VRAM, so more experts stay in VRAM. The cards run one after the other: one request gets more memory, not twice the speed of one card.

  • --split 30,70 (or STRATA_SPLIT) sets the share of the layers per card by hand, in --device order. Use it when one card is slower or sits on a slow PCIe link. The load prints each card's layers and its host-to-VRAM copy rate.
  • An index is the same card on both backends. NVIDIA cards come first, as CUDA counts them: by default the fastest first, which is not the order of nvidia-smi. Then the other Vulkan devices, dedicated before integrated. The load prints the card of every index (cuda device 1: ... or vulkan device 1: ...).
  • The MTP head runs on the last device. EAGLE3 heads decode without drafts on a split.
  • --backend hip runs one device and refuses --device 0,1.
  • calibrate ignores --split with a note. Each device order has its own file (strata-<model>-dev0-1.json, -dev1-0.json), so calibrate --device 1,0 too to compare orders.
  • AMD cards clock down while the other card works. The fix is in AMD.md. It took a two-card split from 44 to 57 tok/s in one report.

Inkling 2 on several GPUs

--device 0,1 is opt-in for Inkling 2: the default is one card, even on a machine with two. With two cards the 24 expert layers are placed as whole slabs, and the load line says how many and where. The attention and the tail stay on GPU 0. The kernel switches are in the variable table.

Page cache

Experts that do not fit in VRAM are read from the GGUF through the page cache.

Case What to do
ZFS with primarycache=metadata Every run reads the experts from disk again. Use a file system that caches data, or a tmpfs copy.
btrfs with compress (the CachyOS default) A model larger than RAM had about double the CPU expert time per token against XFS. The load prints a note. Copy the model into a folder marked chattr +m or chattr +C first, or onto another file system.
Network file system (SMB, NFS, a FUSE mount) The file is not read ahead. STRATA_PRELOAD=1 reads it ahead all the same.
Docker inside an LXC container The memory limit is not visible. Give the Docker container its own --memory, or set STRATA_PRELOAD=0 and, on ZFS, STRATA_DIRECT_ROWS=1.
  • Model files that fit in RAM with 4 GiB to spare are read into the page cache in the background from the start. On Linux the RAM is the cgroup's memory limit when that is lower: a container, or a systemd unit with MemoryMax.
  • A file that holds only the Qwen3.8 Flash-Next n-gram table (27 GB) does not count toward the size. On ZFS, when the model does not fit in RAM, the rows of that table are read with O_DIRECT.
  • A model that does not fit is not read ahead, so serve runs one untimed 512-token prefill at load for every model with routed experts. The log says warm-up: ... s.
  • STRATA_HUGEPAGE=1 made decode slower on a model larger than RAM (about 69-78 against 115 tok/s). Leave it off there.

Test and tuning variables

Variable What it does
STRATA_CPU_PREFILL_CHUNK Tokens per --fast-cpu prefill chunk (default 32).
STRATA_CPU_SHARED_INT=1 --fast-cpu: the shared integer path also for the Q and IQ types with their own kernels.
STRATA_PTQ1_REPACK=0 Keeps the file's PTQ1_0 layout: no RAM copy, slower.
STRATA_AVX512=1 AVX-512 kernels for CPU experts, in a build for a CPU with AVX-512 VNNI and VBMI. Not in the release binaries. Greedy output can change at a near tie.
STRATA_TQ_F32=1 f32 kernel for the CPU experts of trellis files (Gyro TQ2_T, TQK6, TQK7). Slower, and greedy output differs.
STRATA_DFLASH_Q8=1 Writes and reads model-dflash-q8_0.gguf for a converted DFlash draft.
STRATA_DFLASH_RECONVERT=1, STRATA_DFLASH_BLOCK=N Converts the DFlash checkpoint again. Fixes the DFlash block size.
STRATA_BATCH_MIN Requests decoding at once from which --parallel uses the batched forward.
STRATA_VISION_CPU=1 Keeps the image encoder on the CPU with --gpu. See VISION.md.
STRATA_VERBOSE=1 Prints the developer lines: what the driver offers, memory details, worker counters. Add them to a bug report.
STRATA_WARMUP=0 Skips the warm-up prefill of serve.
STRATA_PRELOAD 1 forces the background read of the model files, 0 turns it off.
STRATA_DIRECT_ROWS 1 reads n-gram table rows with O_DIRECT on any file system, 0 never.
STRATA_HUGEPAGE=1 Asks for huge pages on the model map.
STRATA_COLD_KEEP=1 Marks bytes copied to VRAM reclaimable instead of dropping them from the page cache.
STRATA_ADAPT_EVERY, STRATA_ADAPT_SWAPS How serve learns the expert placement from the reply. Default: 16 swaps every 16 tokens.
STRATA_PREFILL_PROTECT=0 Lets a prompt place experts freely. By default a prompt in serve moves at most 10% of the expert slots.
STRATA_RESET_COUNTS=1 Turns that serve behaviour on for other commands.
STRATA_INKLING2_MODEL Path to the GGUF for tests/inkling2_forward.rs only.

Inkling 2:

Variable Default What it does
STRATA_DS_FAST_KERNELS auto auto: fast kernels only with more than one device. 1 forces them on one card, 0 off on two.
STRATA_DS_PLAIN_FIRST unset; chat/serve/bench set 1 Keeps the plain weights on GPU 0.
STRATA_DS_PF_TOKENS 2048 one card, 512 two Tokens of one prompt chunk (at most 2048).
STRATA_DS_KV_TOKENS --ctx KV rows GPU 0 must still be able to take before it gives up a slab.
STRATA_DS_PROF unset Prints inkling2: preloaded N/24 ... and the per-chunk profile.
STRATA_DS_NO_AFFINITY unset Picks the GPU per expert instead of per stacked tensor.
STRATA_DS_NO_SEG_GRAPH unset Does not capture the segmented decode graph.
STRATA_CTRL_TILE follows FAST_KERNELS 0 forces the per-token controllers.
STRATA_DS_ATTN_OLD, STRATA_DS_ATTN_KP4 off 1 selects the old, or the four-query, attention kernels. OLD wins over the Q8 switches.
STRATA_DS_ATTN_Q8_SHARED, STRATA_DS_ATTN_Q8_HD128 on CUDA Q8 attention kernels for head dimension 128, prefill and decode. 0 turns one off.