Llama Cpp
Run GGUF models that need a customised llama.cpp kernel — the ones stock llama.cpp (and therefore Ollama) cannot load — by installing a patched build, serving them with llama-server, and verifying they answer.
WHAT IT DOES
Where @svendowideit/ollama-models covers everything Ollama can do, this
covers the models Ollama can't yet run. A kernel registry maps a model
architecture to a concrete prebuilt patched build for the host — e.g.
Aleph-Alpha Kolibri-1's kolibri1 MoE needs the kolibri1-llama.cpp.patch
applied on top of stock llama.cpp. plan picks the
asset for this OS/arch/accelerator, download fetches it, install extracts
it, renderService writes the llama-server systemd user unit, and
serve/verify run the model and prove it answers. Prefer it over
hand-building a patched llama.cpp and remembering the launch flags: the
registry, the asset selection and the unit are repeatable swamp data. The
kernel download is resumable (HTTP Range) and skip-if-complete, and the
served model is a systemd user service that runs independently of the worker
that set it up. The unit is a keep-alive server: it listens always and, after
keepAliveSec idle (default 1h), the model sleeps to free GPU/RAM and wakes
on the next request (--sleep-idle-seconds). plan selects the build for
this host's accelerator and can be pointed at a specific build with
assetName/assetUrl (e.g. a CUDA build), so re-running the flow is an
upgrade that re-detects the GPU and rebuilds for it. When no prebuilt build
matches the host (e.g. an aarch64+CUDA build that is not published), plan
falls back to a source build: build clones llama.cpp at the kernel's
pinned commit, applies the patch, cmake-configures for the accelerator and
builds — as a host-managed background job that outlives the run — and
buildStatus awaits it and records the binaries.
INSTALL
swamp extension pull @svendowideit/llama-cppDEPENDENCIES
For the methods alone: none (it runs local binaries). The bundled
@svendowideit/llama-cpp-model-factory workflow additionally uses
@svendowideit/gpu-facts (this host's budget) and
@svendowideit/huggingface (find + download the GGUF), declared in
dependencies: and installed by the single pull above.
RUN
# List the custom-kernel registry — which model architectures need a
# patched build, and where each comes from.
swamp model @svendowideit/llama-cpp method run kernels lc
# Resolve the build asset for this host for a kernel (e.g. kolibri1).
swamp model @svendowideit/llama-cpp method run plan lc --input kernel=kolibri1
# Download + extract the kernel, then render, start and verify the server
# for a GGUF (the factory workflow wires all of this; one call each here).
# No prebuilt build for this host (e.g. arm64 + CUDA)? Build from source,
# then await it; buildStatus records the built binaries for renderService.
swamp model @svendowideit/llama-cpp method run build lc
swamp model @svendowideit/llama-cpp method run buildStatus lc \
--input wait=true --input maxWaitSec=3600
swamp model @svendowideit/llama-cpp method run renderService lc \
--input model=/models/kolibri-Q2_K.gguf --input write=true
swamp model @svendowideit/llama-cpp method run serve lc
swamp model @svendowideit/llama-cpp method run verify lc \
--input model=/models/kolibri-Q2_K.gguf
# When @svendowideit/caddy is installed on this host, declare a
# reverse-proxy route for the served model without any extra input:
swamp model @svendowideit/llama-cpp method run ensure-caddy-proxy lc
# The whole loop in one run: find a GGUF, install the kernel, serve and
# verify it. Run it on the host that will serve the model.
swamp workflow run @svendowideit/llama-cpp-model-factory \
--input kernel=kolibri1 --input ask="a German reasoning model"CONFIGURE
Global arguments (set at creation with --global-arg, or per call with
--input):
installDir Where the kernel build is extracted (default ~/.local/llama-cpp)
downloadDir Where the kernel archive is staged (default ~/.cache/llama-cpp)
host / port llama-server bind (default 127.0.0.1:8080)
serviceName systemd unit name (default llama-cpp)
serviceScope user | system (user needs no root) (default user)
ctx / ngl context window / GPU layers (default 4096 / derive)
threads CPU threads (default 0 = server default)
keepAliveSec idle seconds before the model (default 3600 = 1h; 0 = never)
sleeps (frees GPU/RAM), waking
on the next request
extraArgs extra llama-server arguments (default "")
sudo escalation for system scope (default sudo)
releaseRepo / releaseTag override the kernel source (default: the kernel's)SETUP
setup resolves and persists the config (dirs, host/port, service, ctx/ngl),
reading any existing config resource back first so later runs reuse it:
swamp model @svendowideit/llama-cpp method run setup lcUPGRADE
This extension installs nothing until you run install; upgrade the code
alone and re-run install to pick up a newer kernel build:
swamp extension update @svendowideit/llama-cppWHAT IT INSTALLS
On the host: the extracted patched llama.cpp build under installDir
(llama-server, llama-cli, its shared libraries), a staged kernel archive
under downloadDir, and — for a served model — a systemd unit
(~/.config/systemd/user/<serviceName>.service for user scope). Nothing is
installed system-wide unless you choose serviceScope=system. It does not
touch Ollama or any other extension's files.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| name? | string | Model instance name (supplied by swamp). |
| installDir? | string | Directory the kernel build is extracted into (expanded for `~`). |
| downloadDir? | string | Directory the kernel build archive is staged in. |
| host? | string | `llama-server` bind host. |
| port? | number | `llama-server` bind port. |
| serviceName? | string | systemd unit name (without `.service`). |
| serviceScope? | enum | systemd scope. `user` needs no root; `system` needs root/sudo. |
| unitDir? | string | Override the unit directory (advanced/testing). |
| ctx? | number | Default context window (`-c`). |
| ngl? | number | Default GPU layers (`-ngl`); -1 derives (0 on cpu, 999 otherwise). |
| threads? | number | CPU threads (`-t`); 0 = server default. |
| keepAliveSec? | number | Keep-alive: seconds of idleness after which the served model sleeps (freeing |
| extraArgs? | string | Extra raw `llama-server` arguments. |
| sudo? | string | Escalation command for system scope. |
| releaseRepo? | string | Override the kernel release repository (`owner/name`). Empty uses the kernel's. |
| releaseTag? | string | Override the kernel release tag. Empty uses the kernel's pinned tag. |
| caddyModelName? | string | Name of the @svendowideit/caddy model that owns this machine. Empty |
| caddyRouteHostname? | string | Override the Caddy route hostname for ensure-caddy-proxy. Empty derives |
| Argument | Type | Description |
|---|---|---|
| kernel? | string | Kernel key (e.g. `kolibri1`). Empty plans only the host platform. |
| os? | string | Override the detected OS. Empty probes the host. |
| arch? | string | Override the detected arch. Empty probes the host. |
| accel? | string | Override the accelerator (cuda|rocm|vulkan|metal|cpu). Empty defaults to cpu. |
| assetName? | string | Select a specific asset by exact file name (e.g. a CUDA build), overriding |
| assetUrl? | string | Download URL to use directly (e.g. a locally built CUDA llama.cpp), |
| Argument | Type | Description |
|---|---|---|
| url | string | Asset URL to download (from `plan.downloadUrl`). |
| dir? | string | Download directory. Empty uses the global `downloadDir`. |
| force? | boolean | Re-download even when the file already exists. |
| Argument | Type | Description |
|---|---|---|
| archivePath? | string | Path to the downloaded kernel archive. |
| archiveName? | string | Archive file name (for format + record). |
| checksum? | string | Expected SHA-256 (hex). Empty skips verification. |
| version? | string | Release tag/version the archive came from. |
| installDir? | string | Override the install dir. Empty uses the global. |
| force? | boolean | Re-extract even when already installed. |
| Argument | Type | Description |
|---|---|---|
| sourceDir? | string | Clone directory for llama.cpp. Empty uses `<downloadDir>/llama.cpp`. |
| jobs? | number | Parallel build jobs; 0 = nproc. |
| force? | boolean | Rebuild even if already complete. |
| Argument | Type | Description |
|---|---|---|
| wait? | boolean | Poll until the source build finishes (or `maxWaitSec` elapses). |
| maxWaitSec? | number | Maximum seconds to wait when `wait` is set. |
| Argument | Type | Description |
|---|---|---|
| model | string | Absolute path to the GGUF to serve. |
| ctx? | number | Context window. 0 uses the global. |
| ngl? | number | GPU layers. -2 uses the global. |
| host? | string | Bind host. Empty uses the global. |
| port? | number | Bind port. 0 uses the global. |
| threads? | number | Threads. -1 uses the global. |
| keepAliveSec? | number | Keep-alive seconds. -1 uses the global. |
| extraArgs? | string | Extra args. Empty uses the global. |
| write? | boolean | Also write the unit file (user scope needs no root). |
| Argument | Type | Description |
|---|---|---|
| enable? | boolean | Also `enable` the unit (start at login/boot). |
| Argument | Type | Description |
|---|---|---|
| disable? | boolean | Also disable the unit. |
| Argument | Type | Description |
|---|---|---|
| model | string | Absolute path to the GGUF. |
| prompt | string | The prompt. |
| numPredict? | number | Max tokens to generate (`-n`). |
| ctx? | number | Context. 0 uses the global. |
| ngl? | number | GPU layers. -2 uses the global. |
| threads? | number | Threads. -1 uses the global. |
| Argument | Type | Description |
|---|---|---|
| model? | string | Source @svendowideit/caddy model. Empty auto-discovers the model that owns |
| hostname? | string | Override the proxied hostname. Empty derives `<serviceName>.<host>.<domain>`. |
| serveModel? | string | Dedicated caddy model that carries the route (unused). Empty runs against |
Resources
From an ask to a running model that needs a customised kernel, in one run. facts → recommend → (clarify → wait-for-choice) → select → inspect → download → plan → download-kernel → install → render-service → serve → verify → print. This is the sibling of @svendowideit/ollama-model-factory for the models Ollama cannot load — those needing a patched llama.cpp kernel (e.g. Aleph-Alpha Kolibri-1's `kolibri1` MoE). It reuses the same Hugging Face search/download and gpu-facts budget, then `plan` map
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit1/2partial
- @std/assert--jsr:@std/assert@1 is a range; audited 1.0.19, the version the registry resolved
- @swamp-club/swamp-testing--jsr:@swamp-club/swamp-testing@^0.3.0 is a range; audited 0.3.0, the version the registry resolved
2 dependencies found
- jsr:@std/assert@1 -- audited 1.0.19
- jsr:@swamp-club/swamp-testing@^0.3.0 -- audited 0.3.0
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned
Spawns a subprocess with Deno.Command().
- models/llama_cpp.ts:439 — run arbitrary local binaries (uname, cmake, etc.) by design.
- models/llama_cpp.ts:1608 — optional caddy peer discovered at runtime; args are fixed literals or globals of this model, never untrusted input.
- files/llama_cpp_test.ts:186 — build test fixture archive.