Runtimes
A runtime runs a model's forward pass: llama.cpp, MLX, the baseRT engine, or the built-in mock. Superfluid ships an adapter per runtime and installs the runtime itself from its own project's releases. Each model runs in its own worker process, so a runtime crash restarts that worker, not the daemon.
| id | aliases | serves | comes from |
|---|---|---|---|
llamacpp | llama.cpp, llama-cpp | GGUF files | llama.cpp's release builds |
mlx | MLX directories (Apple silicon) | a private CPython with mlx and mlx-lm | |
basert | native | .base bundles | the baseRT engine library, loaded at run time |
mock | nothing real | built in; used by the test suite |
llamacpp and mlx are primitive runtimes: Superfluid's generic executor implements batching, the prefix cache, sampling, grammars and park/resume on top of them. basert is a full engine that implements all of that itself.
Managing installs
superfluid runtimes # state of every runtime, and the newest version each installs here superfluid runtime versions llamacpp # every version the adapter installs on its own: which install here, which are installed superfluid runtime install llamacpp --dry-run # print the plan, fetch nothing superfluid runtime install llamacpp superfluid runtime install llamacpp --backend vulkan superfluid runtime update llamacpp superfluid runtime use llamacpp b11284-vulkan # pin the default install superfluid runtime use llamacpp --auto # unpin superfluid runtime repair llamacpp superfluid runtime remove llamacpp b11284-vulkan superfluid runtime remove llamacpp@b11284-vulkan # the same, as `superfluid runtimes` lists the install superfluid runtime remove llamacpp --all # every install
| command | what it does |
|---|---|
versions <id> | list the versions the adapter installs on its own (the ones it was tested with), newest first: which install on this machine and as what, with the size, and which are installed; an install of another version (--untested, or an archive of your own) is listed as not one the adapter lists. basert installs a release it does not pin without --untested when the release states this build's engine ABI, and with no version the newest such release: an install of one newer than the pins is listed as installable when a build for the same engine ABI installed it, and the line below the list says so. --json for scripts. Answered from the adapter's recipe and the installs, with no network |
install <id> | plan, fetch, verify and place an install. Options: --version V, --backend B (no fallback), --from <archive> (a URL or path to your own archive or, for MLX, package index), --sha256 H, --untested, --dry-run |
update <id> | install the newest tested build for the default install's backend beside it and make it the default. basert learns the newest from its release listing: when that cannot be fetched, the newest it installs on its own is a pinned release, and an install that is not older than it is left alone with exit 1 and the fetch's error, rather than reported up to date |
repair <id> [<install>] | reinstall the same version and backend; what a daemon updated with superfluid self update asks for when an install's worker is too old |
remove <id> [<install>] / --all | remove one install, or every one with --all; the id alone removes the only install and refuses a runtime that has more |
use <id> <install> / --auto | pin the default install / return to ranking |
repair, remove and use take the install as <id>@<install> too, as the RUNTIME column of superfluid runtimes shows one that is not the default.
serve installs a runtime on first use; --offline prevents it. A runtime's worker starts without credential-named variables (*_TOKEN, *_API_KEY, *PASSWORD, *SECRET, ...) in its environment; a pull keeps them, since it fetches with your Hugging Face token.
An install fetches over https:// only, checks each asset against a SHA-256 known before the fetch (the adapter's pinned one, or --sha256), stages it, and runs the staged worker's check. An archive from elsewhere with no SHA-256 to check is refused; a local file without one installs with a warning. An archive member that would land outside the install (an absolute path, .., a symlink out) fails the install. If the runtime finds no device of the planned backend, the next plan is tried (CUDA, then Vulkan, then CPU). One install of a runtime runs at a time across processes; a failed install leaves the existing ones as they were.
Where installs live
~/.superfluid/runtimes/<id>/
<install>/ b11284-metal, 0.3.1-cuda, 0.32.2-metal
bin/superfluid-worker-<id>
lib/ libraries and tools
python/, env/ (mlx) private CPython and environment
runtime.json version, backend, sources with SHA-256
current -> <install> the default install
pinned set by `runtime use`
The default install is the pinned one, else the best-ranked: a GPU backend (metal, cuda, rocm, vulkan, sycl, openvino) before cpu, then the newest version. A running daemon keeps the install it started with until it restarts.
Per-runtime installs
llama.cpp. The tested builds are the ones superfluid runtime versions llamacpp lists; another needs --untested, and the refusal says whether it lies between two tested builds, whose C API it very likely shares, or past the newest or oldest, where it may differ. The backend is chosen from the machine:
| machine | build | falls back to |
|---|---|---|
| macOS, Apple silicon | metal | |
| macOS, Intel | cpu | |
| Linux with an NVIDIA driver | newest CUDA the driver runs (cuda-13.x from driver 580, cuda-12.x from 525) | ROCm, Vulkan, CPU |
| Linux x86-64 with ROCm | rocm | Vulkan, CPU |
| Linux with a Vulkan loader | vulkan | CPU |
| any Linux | cpu | |
| Windows x86-64 with an NVIDIA driver | newest CUDA the driver runs, by the same rule | Vulkan, CPU |
| Windows x86-64 with a Vulkan driver | vulkan | CPU |
| any Windows x86-64 | cpu |
SYCL and OpenVINO builds are installed only with --backend. So is the ROCm build on Windows: it carries its own HIP runtime, and nothing on the machine says whether the display driver serves it, so --backend rocm names it and the install is kept only if it finds the GPU. Of the tested builds, only b11284 has an OpenVINO build, so --backend openvino needs --version b11284.
MLX. Apple silicon only. Fetches CPython 3.12.14 (python-build-standalone) and, from PyPI, mlx, mlx-metal, mlx-lm and their dependencies, every wheel pinned by hash (tested: mlx 0.32.4 with mlx-lm 0.32.2, and mlx 0.32.2 with mlx-lm 0.31.3; superfluid compat lists them). Installs with pip --require-hashes --no-deps --only-binary=:all:; your own Python and PYTHON*/PIP_* settings are not used (pip's network settings excepted).
basert. Engine bundles from baseRT's releases for macos-arm64 (Metal), linux-arm64-cuda (an NVIDIA GPU) and linux-x64-rocm (from baseRT 0.5.0); other machines are refused. The ROCm bundle is one engine for AMD's Strix Halo (gfx1151) and Strix Point (gfx1150), which the install reads from the GPU driver (/sys/class/kfd); it runs on AMD's ROCm 10 runtime at /opt/rocm/core-10.0, and a release's engine is not installed without it. A release is tested when the engine ABI number it publishes beside its bundles (basert-engine-abi-<N>.txt) is the one this daemon was built for, or, for a 0.3.x release, which states none, by its line; another needs --untested and may not load. With no --version, the newest tested release on baseRT's release page is installed, checked against the SHA-256 GitHub lists for its engine (the digest baseRT also publishes beside it as <engine>.sha256); the adapter also pins releases with their digests, which install the same way offline, when the release page cannot be read. A release GitHub lists no digest for, and that is not pinned, installs only with --version V --sha256 H. Instead of installing, you can name an existing library with --basert-lib or BASERT_LIB.
How a worker is found
For each runtime, first match wins:
SUPERFLUID_WORKER_<ID>- a runtime linked into this build (
superfluid-workerd --engine <id>) superfluid-worker-<id>beside thesuperfluidbinary (a source build)- the installed runtime,
$SUPERFLUID_HOME/runtimes/<id>/current/bin/ - the adapter a release ships in
libexec/superfluid/(can only say "not installed" and install)
--runtime llamacpp@b11284-vulkan uses exactly that install's worker.
How a runtime is chosen
--runtime <model>=<id>for one model, else--runtime <id>for all; the later selector wins.automeans "by format".- Otherwise a path goes to the runtime that reads its format, and an id is inferred from its name (
gguf→llamacpp,mlx→mlx, elsebasert). - A pick is validated against the model's format before anything loads:
runtime llamacpp cannot serve model.base: it reads a GGUF file, and this is a .base bundle (pass --runtime basert, or convert the model)
superfluid runtimes <path> shows the decision without serving.
Capability records
Every loaded model is described by one JSON capability record its runtime reports. Each leaf is true, or a string saying why not. The daemon uses it to refuse unsupported requests, check startup flags, and fill the capabilities object in /v1/models.
Startup flags a runtime cannot honour are refused before the worker starts:
| flag | llamacpp / mlx say |
|---|---|
--park-lossy | the <id> runtime exports no lossy encoding |
--kv-bits <n> (non-zero) | the <id> runtime keeps its KV type per context and exposes no such knob |
--speculate <strategy> (not auto/off) | on llamacpp/mlx: any strategy but prompt-lookup, or prompt-lookup on a model whose state cannot cut a rejected draft |
--speculate auto is never refused; a model that cannot speculate decodes plainly and the log says so.
Requests a model cannot serve are refused with a 400:
{"error": {"message": "model 'Qwen3-4B-Q4_K_M' on runtime llamacpp does not accept images: the llamacpp runtime has no media path",
"type": "invalid_request_error", "param": "messages", "code": "unsupported_input"}}
| code | when |
|---|---|
unsupported_input | an image or audio part |
unsupported_model | embeddings, transcription or translation on a model that does not serve them |
unsupported_runtime | a load the runtime cannot serve as asked |
unsupported_parameter | a request parameter the path does not support |
Per-runtime options
A knob of one runtime is given to serve as --<runtime>-<name> <value>, for example --llamacpp-n-gpu-layers 20. The adapter declares its options with the shape of each value; superfluid serve checks a value against that declaration before a worker starts and forwards it to the runtime's worker as --<name> <value> from its first check on, in process or not, so --llamacpp-lib can be what makes the runtime usable here; and superfluid runtime options <id> lists them, before an install too. Each is given once: a second --llamacpp-lib is a usage error (exit 2), not an override. A flag every runtime takes stays a flag of serve: the context window (--max-context), the lanes (--max-batch), the KV precision (--kv-bits), parking and speculation.
llamacpp options
The knobs of llama.cpp's model and context parameters that keep their meaning under Superfluid, named as llama.cpp's own tools name them. The window, the sequence count, the KV layout and sampling are Superfluid's.
| option | value | default | meaning |
|---|---|---|---|
--llamacpp-lib | path | the install's | A llama.cpp build of your own: the libllama file or its directory (as SUPERFLUID_LLAMA_LIB). |
--llamacpp-n-gpu-layers | N | -1 | Layers kept on the device; -1 is all of them, 0 runs the model on the CPU. |
--llamacpp-main-gpu | N | 0 | The device that takes the whole model under split-mode none, and small tensors otherwise. |
--llamacpp-split-mode | none, layer, row, tensor | layer | How a model is spread over several devices. |
--llamacpp-tensor-split | f,f,... | even | The share of the model each device takes (3,1 gives the first three quarters). |
--llamacpp-load-mode | auto, none, mmap, mlock, mmap-mlock, direct-io | auto | How weights are read: mmap maps the file, mlock pins them in RAM, direct-io bypasses the page cache. |
--llamacpp-lazy-mode | off, auto, on | auto | Read the rows of tensors the architecture marks (experts) on demand; needs mmap. |
--llamacpp-repack | on, off | on | Repack weights into the device's extra buffer types (llama.cpp's --no-repack turns it off). |
--llamacpp-threads | N, 0 to 512 | 0 | Threads for decoding; 0 is every core. |
--llamacpp-threads-batch | N, 0 to 512 | 0 | Threads for prompt batches; 0 is as many as threads. |
--llamacpp-batch-size | N, 1 to 1048576 | 2048 | Tokens per decode call (n_batch). |
--llamacpp-ubatch-size | N, 1 to 1048576 | 512 | Tokens per micro-batch (n_ubatch), at most batch-size. |
--llamacpp-flash-attn | auto, on, off | auto | Flash attention; auto lets llama.cpp decide for the device. |
--llamacpp-cache-type-k | f16, bf16, f32, q8_0, q4_0, q4_1, q5_0, q5_1, iq4_nl | f16 | The KV cache's K type. |
--llamacpp-cache-type-v | the same | f16 | The KV cache's V type; a quantized V needs flash attention on. |
--llamacpp-kv-offload | on, off | on | Keep the KV cache on the device (llama.cpp's --no-kv-offload turns it off). |
--llamacpp-op-offload | on, off | on | Offload operations on host tensors to the device. |
--llamacpp-swa-full | on, off | on | A full-size cache for sliding-window layers; off keeps only the window and saves memory. |
--llamacpp-rope-scaling | none, linear, yarn, longrope | model's | RoPE scaling for a context past the trained one. |
--llamacpp-rope-freq-base, --llamacpp-rope-freq-scale | F, at least 0 | model's | RoPE base frequency and frequency scale; 0 takes the model's, as in llama.cpp. |
--llamacpp-yarn-ext-factor, --llamacpp-yarn-attn-factor, --llamacpp-yarn-beta-fast, --llamacpp-yarn-beta-slow | F | model's | YaRN extrapolation mix, magnitude scale, low and high correction dimensions; a negative value takes the model's, as in llama.cpp. |
--llamacpp-yarn-orig-ctx | N | model's | YaRN original context size; 0 takes the model's. |
KV state saved from a run (a parked session) is keyed by the weights and by the RoPE, YaRN and cache-type settings in effect, so a run with other settings never reads it. A setting given as llama.cpp's default (--llamacpp-cache-type-k f16) or as its "the model's" (--llamacpp-rope-freq-base 0) runs as a plain run does and reads a plain run's state.
Not options, by design: --ctx-size and --parallel are --max-context and --max-batch; --kv-unified is the adapter's choice of KV layout; metadata and tensor overrides (--override-kv, --override-tensor, --cpu-moe) and --device take backend handles the worker does not expose yet.
mlx options
The worker drives mlx-lm's model classes with an executor of its own, so its knobs are the executor's.
| option | value | default | meaning |
|---|---|---|---|
--mlx-venv | path | the install's | A Python environment of your own with mlx and mlx-lm (as SUPERFLUID_MLX_VENV). |
--mlx-prefill-chunk | N, 1 to 1048576 | 2048 | Prompt tokens fed to the model per step. |
--mlx-cache-limit-mb | N | 1024 | MLX's buffer cache limit (mx.set_cache_limit). |
mlx-lm's own --max-kv-size, --kv-bits and --adapter-path are not options: a rotating or quantized cache changes the executor's cache, and a LoRA adapter is a load-time change the worker does not make yet.
basert options
| option | value | default | meaning |
|---|---|---|---|
--basert-neural-engine | on, off | on | Run part of each prefill on the Neural Engine where that is faster (Apple silicon); off runs every prefill on the GPU alone. It needs an engine that has the switch: with one that has none (BaseRT 0.4.6 and earlier, which prefill on the GPU alone), off fails the load. |
--basert-npu | on, off | on | Run part of each prefill on the XDNA NPU where the machine has one and its runtime (AMD Strix on Linux); off runs every prefill on the GPU alone. The same switch as --basert-neural-engine: the engine has one for whichever of the two its backend uses, and either option off turns it off. |
Its other knobs are flags every runtime may take (--kv-bits, --prefix-blob-budget-mb) and --basert-lib.
An engine that can compile a model's Neural Engine programs ahead has them compiled after a pull, by the worker that will load the model, since macOS keeps the compiled programs for each executable: once per Mac, macOS version and Superfluid build. A load that finds them uncompiled compiles them in the background while the GPU runs the prefill alone. Nothing is compiled with --basert-neural-engine off.
On an AMD Strix machine (Strix Halo, Strix Point) an engine whose bundle carries the NPU module (baseRT_rocm_npu.so and npu-designs/ in the install's lib/) splits the prefill of a prompt of 1024 tokens or more between the GPU and the XDNA NPU. Nothing is configured in Superfluid for it. The machine needs three things, and without one of them the engine serves on the GPU alone and prints which is missing in one [npu_ffn] line at each load:
| what | how |
|---|---|
the NPU's kernel driver and firmware (/dev/accel/accel0 exists) | the in-tree amdxdna driver and linux-firmware; Ubuntu 26.04 has both |
| XRT, the NPU's runtime | Ubuntu 26.04: sudo apt install libxrt2 libxrt-npu2 |
| an unlimited locked-memory limit for the server's process (XRT locks a 64 MiB heap) | a shell: ulimit -l unlimited; a systemd unit: LimitMEMLOCK=infinity. /etc/security/limits.d reaches only logins that pass through PAM, not a service |
The NPU's part of a prefill is int8, so its logits are close to the GPU's and not bit-identical; --basert-npu off serves on the GPU alone. If an NPU job fails during a request, the engine fails that request with a GPU fault rather than answer from an output the NPU never wrote, and serves the following ones on the GPU alone.
How an upstream release becomes a tested one
Each adapter installs on its own only the upstream versions it was built and tested against, listed in its recipe.json; another installs with --untested and is still checked at load. A nightly job (.github/workflows/nightly-runtimes.yml) keeps those lists current: it installs the newest upstream release untested (for MLX the newest mlx with the newest mlx-lm, so a release of either is tested; an mlx-lm alone replaces its mlx's entry), runs the adapter's tests on it, and records the result. A release that passes arrives as a PR adding it to the recipe (scripts/nightly_runtimes.py <runtime> append): for llama.cpp with the size and SHA-256 GitHub lists for each of its assets, for MLX with the environment pip resolved for it on the runner, every wheel with the size and SHA-256 PyPI lists for it. A runtime's PRs come from one branch (nightly/llamacpp, nightly/mlx), one open at a time, which a newer release that passes takes over; a release whose PR was closed unmerged is not proposed again. One that fails opens an issue with the run attached (one that does not finish, cancelled or expired in the queue, records nothing); an MLX that needs a newer Python than the adapter ships fails that way, since it changes the worker's build rather than a pin. A newest llama.cpp build that fails is walked back from: the run starts another on the next-newest build the recipe does not list, at most five below the one the night began on, and the first to pass is the one proposed, with a note on the issue, so an upstream build fixed a few builds later does not hold the recipe until the next night. workflow_dispatch tests a named release instead of the newest, a declined one too, and that release alone: no walk-back.
Per-runtime limits
llamacpp
-
superfluid compatlists the llama.cpp builds this adapter was built and tested against, which it installs on its own; another build installs with--untested, and is still checked at load for the functions and parameter layouts the adapter drives. -
A build whose C API differs from the tested one is refused by name at load.
SUPERFLUID_LLAMA_LIBor--llamacpp-libloads your own build instead of an install. -
With no
--max-context, the window is sized for the device on Metal, and on CUDA with a dedicated GPU; elsewhere it is 8192. A shared pool is sized by what its context takes on the device, which is more than its KV: llama.cpp reserves working memory that grows with the pool (on Metal since b12059, room to gather one layer's K and V rows for each of the pool's sequence ids, which for a shallow model is more than the KV itself). The adapter measures it on two small contexts before it makes the pool, and the two together keep to 60% of the memory the weights leave free; the startup line gives what a token takes. Neither of the two is larger than the pool the KV alone would be given, and where the device holds neither, at any size down to a batch, the pool is priced by its KV as before: the measurement never keeps a model from opening. Once a context exists, one that left the device short of its reserve is made again with fewer cells; a pool cut below one sequence serves that model at the shorter window. -
Plain-attention models get a KV buffer per sequence (lanes plus two, at least 4, at most 256), so a decode step attends only over its own sequence. Recurrent, hybrid and sliding-window models (Qwen3.5/3.6-class, gemma) use one shared pool and reuse prefixes only at a sequence's head.
-
The prefix cache keeps at most one lane's context in a shared pool, where every step attends over the cells up to the highest one in use. The rest of the cache, and any entry that gives up its sequence to a lane, is held in host memory as llama.cpp's own state export and imported when a request reuses it: as many tokens as the pool has cells, within 8 GiB and 60% of the memory the model and its context leave free. On a host without an accelerator, or with the model on the CPU, the 8 GiB alone bounds it.
-
On Metal, a prompt batch on a shared pool is filled to a multiple of 8 tokens: the attention kernel computes a last group short of 8 queries against every cell in use.
-
No lossy park, no media, no batch invariance. Greedy rounds take llama.cpp's argmax; sampled rounds are sampled on the host.
-
llama.cpp's own log is silenced unless
SUPERFLUID_LLAMA_LOG=1. Its error lines are read either way: a step during which llama.cpp logs one fails and returns no token, with what it said on the worker's stderr. On Metal a decode returns before the device has run it, and an error line is the only word of a device that then refuses the work.
mlx
-
superfluid compatlists the MLX versions this adapter installs on its own and the Python they run on. -
Apple silicon only. Python runs in the worker, so a Metal fault kills the worker, never the daemon.
-
Greedy and sampled rounds run on the device, one step ahead.
-
A joining request's prompt runs between decode rounds; lanes already decoding pause for it.
-
With no
--max-context, the window is sized for the device from what the worker reads off the model without loading it (superfluid-worker-<id> check --model <path>shows it assizing). -
Recurrent models reuse prefixes only at a sequence's head, and from copies of the state kept where each prompt of 128 tokens or more ends (one token short) and where requests queued behind a prefilling lane stop sharing its prompt (1024 tokens or more), so a resent prompt, a next turn that repeats it, or a burst on one long prefix starts there. No lossy park, no media, no batch invariance.
-
A directory whose
config.jsonnames its own code is refused unlessSUPERFLUID_MLX_TRUST_MODEL_CODE=1. -
A load is refused unless weights plus a tenth plus 1 GiB fit in available memory while leaving the larger of 4 GiB and a tenth of RAM free.
SUPERFLUID_MLX_SKIP_FIT_CHECK=1overrides.
basert
- The engine library is loaded at run time. A library of baseRT 0.4.0 or later states an engine ABI number, which must equal the one the daemon was built against, whatever the versions say; a 0.3.x library states none and is accepted as the line that carried that ABI before it was numbered.
superfluid compatprints what the daemon drives.superfluid runtime install basertpicks an engine by the number baseRT publishes beside each bundle. - What a bundle supports (speculation, media, embeddings, lossy parking) is known only once it is loaded.
- Serving
.basebundles needs a daemon built with the defaultbasertfeature; only the engine tokenizes them. - Pulling by id needs the
baserttool (BASERT_CLI, beside libbaseRT, or onPATH).