Skip to main content

Llama Cpp

@svendowideit/llama-cppv2026.10.22.1· MIT· 2d agoBEHAVIORSWORKFLOWSACCEPTED WARNINGS
01README

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-cpp

DEPENDENCIES

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 lc

UPGRADE

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-cpp

WHAT 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.

02Behaviors1
@svendowideit/llama-cppv2026.10.22.1llama_cpp.ts

Global Arguments

ArgumentTypeDescription
name?stringModel instance name (supplied by swamp).
installDir?stringDirectory the kernel build is extracted into (expanded for `~`).
downloadDir?stringDirectory the kernel build archive is staged in.
host?string`llama-server` bind host.
port?number`llama-server` bind port.
serviceName?stringsystemd unit name (without `.service`).
serviceScope?enumsystemd scope. `user` needs no root; `system` needs root/sudo.
unitDir?stringOverride the unit directory (advanced/testing).
ctx?numberDefault context window (`-c`).
ngl?numberDefault GPU layers (`-ngl`); -1 derives (0 on cpu, 999 otherwise).
threads?numberCPU threads (`-t`); 0 = server default.
keepAliveSec?numberKeep-alive: seconds of idleness after which the served model sleeps (freeing
extraArgs?stringExtra raw `llama-server` arguments.
sudo?stringEscalation command for system scope.
releaseRepo?stringOverride the kernel release repository (`owner/name`). Empty uses the kernel's.
releaseTag?stringOverride the kernel release tag. Empty uses the kernel's pinned tag.
caddyModelName?stringName of the @svendowideit/caddy model that owns this machine. Empty
caddyRouteHostname?stringOverride the Caddy route hostname for ensure-caddy-proxy. Empty derives
fn setup()
Resolve and persist this model's configuration (dirs, host/port,
fn plan(kernel?: string, os?: string, arch?: string, accel?: string, assetName?: string, assetUrl?: string)
Resolve the host platform, the kernel for a model architecture, and
ArgumentTypeDescription
kernel?stringKernel key (e.g. `kolibri1`). Empty plans only the host platform.
os?stringOverride the detected OS. Empty probes the host.
arch?stringOverride the detected arch. Empty probes the host.
accel?stringOverride the accelerator (cuda|rocm|vulkan|metal|cpu). Empty defaults to cpu.
assetName?stringSelect a specific asset by exact file name (e.g. a CUDA build), overriding
assetUrl?stringDownload URL to use directly (e.g. a locally built CUDA llama.cpp),
fn kernels()
List the built-in custom-kernel registry.
fn download(url: string, dir?: string, force?: boolean)
Download the kernel build asset at `plan.downloadUrl` into the download
ArgumentTypeDescription
urlstringAsset URL to download (from `plan.downloadUrl`).
dir?stringDownload directory. Empty uses the global `downloadDir`.
force?booleanRe-download even when the file already exists.
fn install(archivePath?: string, archiveName?: string, checksum?: string, version?: string, installDir?: string, force?: boolean)
Extract a downloaded kernel build archive into the install dir and
ArgumentTypeDescription
archivePath?stringPath to the downloaded kernel archive.
archiveName?stringArchive file name (for format + record).
checksum?stringExpected SHA-256 (hex). Empty skips verification.
version?stringRelease tag/version the archive came from.
installDir?stringOverride the install dir. Empty uses the global.
force?booleanRe-extract even when already installed.
fn build(sourceDir?: string, jobs?: number, force?: boolean)
Build the kernel from source when no prebuilt asset matches: clone
ArgumentTypeDescription
sourceDir?stringClone directory for llama.cpp. Empty uses `<downloadDir>/llama.cpp`.
jobs?numberParallel build jobs; 0 = nproc.
force?booleanRebuild even if already complete.
fn buildStatus(wait?: boolean, maxWaitSec?: number)
Await a source build started by `build`; on completion write the
ArgumentTypeDescription
wait?booleanPoll until the source build finishes (or `maxWaitSec` elapses).
maxWaitSec?numberMaximum seconds to wait when `wait` is set.
fn renderService(model: string, ctx?: number, ngl?: number, host?: string, port?: number, threads?: number, keepAliveSec?: number, extraArgs?: string, write?: boolean)
Render the `llama-server` systemd user unit for a GGUF (from the
ArgumentTypeDescription
modelstringAbsolute path to the GGUF to serve.
ctx?numberContext window. 0 uses the global.
ngl?numberGPU layers. -2 uses the global.
host?stringBind host. Empty uses the global.
port?numberBind port. 0 uses the global.
threads?numberThreads. -1 uses the global.
keepAliveSec?numberKeep-alive seconds. -1 uses the global.
extraArgs?stringExtra args. Empty uses the global.
write?booleanAlso write the unit file (user scope needs no root).
fn serve(enable?: boolean)
Place the rendered unit (user scope writes it directly), daemon-reload,
ArgumentTypeDescription
enable?booleanAlso `enable` the unit (start at login/boot).
fn stop(disable?: boolean)
Stop the server (optionally disabling the unit).
ArgumentTypeDescription
disable?booleanAlso disable the unit.
fn status()
Report the unit path, active/enabled state and `/health`.
fn run(model: string, prompt: string, numPredict?: number, ctx?: number, ngl?: number, threads?: number)
Run a one-shot completion with `llama-cli` against a GGUF.
ArgumentTypeDescription
modelstringAbsolute path to the GGUF.
promptstringThe prompt.
numPredict?numberMax tokens to generate (`-n`).
ctx?numberContext. 0 uses the global.
ngl?numberGPU layers. -2 uses the global.
threads?numberThreads. -1 uses the global.
fn verify()
Run a smoke prompt with the custom kernel and assert the model
fn print()
Log the last plan/install/verify summary.
fn ensure-caddy-proxy(model?: string, hostname?: string, serveModel?: string)
When @svendowideit/caddy is installed, ensure a reverse-proxy route
ArgumentTypeDescription
model?stringSource @svendowideit/caddy model. Empty auto-discovers the model that owns
hostname?stringOverride the proxied hostname. Empty derives `<serviceName>.<host>.<domain>`.
serveModel?stringDedicated caddy model that carries the route (unused). Empty runs against

Resources

config(infinite)— Persisted server/kernel configuration.
plan(infinite)— Resolved platform, kernel and build asset.
kernels(infinite)— The built-in custom-kernel registry.
download(7d)— The downloaded kernel build archive.
build(7d)— An in-progress source build of the kernel.
install(infinite)— The extracted kernel build and its binaries.
service(infinite)— The rendered llama-server systemd unit.
server(infinite)— The result of a serve/stop action.
status(infinite)— Live unit + health state.
run(7d)— One-shot llama-cli completion.
verify(7d)— Whether the model answered.
summary(7d)— A printed summary.
caddyProxy(infinite)— Status of the Caddy reverse-proxy route declared for this model.
03Workflows1
@svendowideit/llama-cpp-model-factory5122a9f1-f4dc-4630-a33b-3ccba319103d

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

mainFind a GGUF for the ask, install the custom kernel build for this host, serve the model with llama-server, and verify it answers.
1.facts— Read this host's accelerators, VRAM, RAM and CPU cores (so the recommendation fits, and `plan` knows the accelerator).
2.recommend— Search Hugging Face and rank GGUF candidates against this host's budget. Writes the `recommendation` resource on model `hf`.
3.has-candidates— Fail fast with a clear message when the ask yielded no candidates.
4.clarify-question— Emit the question + options when more than one candidate fits. Skipped when the choice is unambiguous.
5.wait-for-choice— Suspend until the user picks a candidate. Answer it with `swamp workflow signal --workflow @svendowideit/llama-cpp-model-factory --key hf-choice --payload '{"answer":"<repo>#<quant>"}'`, then resume. Skipped when the choice is unambiguous.
6.select— Record the chosen repo/quant (the signalled answer when ambiguous, else the top-ranked candidate). Writes the `selection` resource.
7.inspect— Read the chosen repo's context length and chat template. Writes the `model` resource on `hf`.
8.download— Download the chosen GGUF at a pinned revision. Writes the `download` resource with the local path.
9.plan— Resolve this host's platform and the kernel build asset for the requested kernel. Writes the `plan` resource on `lc`.
10.download-kernel— Download the patched kernel build at `plan.downloadUrl`. Writes the `download` resource on `lc`.
11.install— Extract the kernel build and locate `llama-server`/`llama-cli`. Writes the `install` resource.
12.render-service— Render (and write) the `llama-server` systemd user unit for the GGUF. Writes the `service` resource.
13.serve— Start/restart the llama-server unit and report it active.
14.verify— Run a smoke prompt with the custom kernel and assert the model answered. Writes the `verify` resource.
15.print— Log the plan / install / verify summary.
04Previous Versions1
2026.10.16.6MIT
05Stats
A
93 / 100
Downloads
4
Archive size
48.6 KB
  • 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

07Platforms