weirdnet-model
Local models for WeirdBrains apps: download a GGUF from Hugging Face (only after consent, with resume and a SHA-256 check), load it with llama.cpp, and stream tokens from a worker thread you can cancel. App-agnostic; the model is optional at build time.
catalog: Gemma 4 E2B (phones, small laptops) and E4B (desktop) GGUF defaults, with repo, file, size and checksum.catalog::default_for(Device)picks one.ModelStore,download,download_parts: a cache directory (WEIRDNET_MODELS_DIRoverrides it), aConsentthe user must give for exactly that model,Progresscallbacks,.partresume and verification, split models part by part;ModelStore::listandremove_localfor what is on disk.hf: search the Hub for GGUF repos, list a repo's models (split GGUFs grouped into one model, quantization read from the file name) and read a file's header for KV sizing.HfTokenfor gated and private repos, read on the downloading node only.fit: pick the largest file whose weights plus KV cache fit the node's memory budget.prompt: chat turns rendered through the model's own chat template, and a streaming parser that turns<tool_call>tags into tool calls.Worker: one thread owns the engine;Worker::generatereturns aGenerationthat streamsChunks and can be cancelled from any thread. TheEnginetrait lets tests use a mock.llamafeature:llama::LlamaEngine(llama.cpp, CPU).vulkanandmetaladd GPU offload. Building needs cmake and a C++ compiler.cpu-dispatchfeature: llama.cpp built for every CPU level and picked at run time (see below).cpu: whether this CPU can run the compiled-in llama.cpp. Loading a model checks it first.agentfeature:agent::LocalModelimplementsweirdnet_agent::ModelBackend, so the agent loop can run on a local model with streamed text and parsed tool calls (weirdnet-agent0.5; text only: messages with image or audio parts are refused).hw: hardware detection and model sizing, with a speech-to-text model (see below).limits: per-model media and request limits, read when a model loads and kept next to its files (see below).
= { = "0.5", = ["llama", "agent"] }
Tests never download a model. WEIRDNET_TEST_GGUF=/path/model.gguf cargo test --features llama -- --ignored
runs the real-model check.
Hardware and sizing
hw::detect() reports the OS, CPU threads, system memory and GPUs: NVIDIA through nvidia-smi,
AMD through sysfs, and Apple silicon. Devices that share system memory (Apple, GB10, AMD APUs) are
marked unified. It never fails; a missing tool means fewer devices.
hw::budget(&hw, memory_budget, reserve) is the memory models may use: 85% of VRAM, or of
unified memory after an OS reserve; both can be overridden. hw::plan(&hw, budget) picks a main
chat model, a smaller stand-in and an embedding model from hw::catalog(), a tiered catalog with
each model's footprint; the Gemma entries are this crate's pinned ModelSpecs, so they download
through the consent gate.
let hw = detect;
let plan = plan;
Speech to text
Each catalog entry has a Purpose, its role on a node: chat, embedding, transcribe or speak
(Purpose::as_str and Purpose::parse give the wire names). Audio goes in as an input_audio
part and the transcript comes back as text, so a soundtrack can become text for models without
audio. The transcribe entries:
| Id | Model | Engine | License |
|---|---|---|---|
voxtral-mini-3b |
Voxtral Mini 3B GGUF (Q4_K_M) | llama.cpp | Apache-2.0 |
qwen3-asr-1.7b |
Qwen3-ASR 1.7B, two shards | vLLM | Apache-2.0 |
whisper-large-v3-turbo |
Whisper large-v3-turbo | vLLM | MIT |
cohere-transcribe-03-2026 |
Cohere Transcribe 03-2026, gated, needs --trust-remote-code |
vLLM | Apache-2.0 |
Voxtral is hw::VOXTRAL_MINI_3B, which llama.cpp runs with its audio encoder:
CatalogEntry::projector() is that pinned mmproj file, downloaded through the same consent
gate and counted in footprint. The others are Hugging Face checkpoints for vLLM with
vllm[audio] (hw::QWEN3_ASR_1_7B, hw::WHISPER_LARGE_V3_TURBO,
hw::COHERE_TRANSCRIBE_03_2026; since 0.5.6): spec.repo is the repo vLLM serves,
CatalogEntry::revision() the commit their sizes and SHA-256 were read at (for vLLM's
--revision), and CatalogEntry::files() the weights files. Whisper-style models decode 30
second windows (limits::WHISPER_CHUNK_SECONDS).
hw::plan never proposes a transcriber, since transcription is optional;
hw::transcriber(&budget) returns the GGUF one when it fits (llama.cpp runs it, and
download fetches it), and hw::by_purpose(Purpose::Transcribe) lists all the entries.
Sharded checkpoints
An entry's spec is one file with one hash. A checkpoint in several files (Qwen3-ASR's two
safetensors shards) keeps its first shard in spec, the file the engine loads the checkpoint
from, and lists every shard, each with its own size and SHA-256, in CatalogEntry::files(). The
shards share the entry's id, so one Consent covers them and download_parts fetches them
together and checks each hash; an entry with one file lists just spec:
use ;
let asr = find.unwrap;
for shard in asr.files
assert!;
// After showing the user what will be fetched (`ModelSpec::consent_text`):
let store = from_env;
let consent = given;
download_parts?;
# Ok::
footprint counts every shard. Only the weights are pinned; the config and tokenizer files come
with the repo when vLLM loads it at revision().
Engine arguments and gated repos
CatalogEntry::engine_args() is what the entry needs on its engine's command line besides the
arguments an app sets for every model: vLLM arguments for a checkpoint, llama-server arguments
for a GGUF entry. An app appends them to the launch's extra arguments, after the operator's own.
Cohere Transcribe's repo ships its modeling code, so vLLM needs --trust-remote-code:
use hw;
let cohere = find.unwrap;
let mut extra_args: = Vecnew; // the operator's own
extra_args.extend;
assert_eq!;
CatalogEntry::gated() marks a repo whose terms must be accepted on the Hub; download then
needs a token on the downloading node (HF_TOKEN, read by ModelStore::from_env) and says so
before sending any request when there is none (hw::gated(&spec) asks about any file of the
repo). Entries that need nothing extra return an empty engine_args().
Chat models with their own launch values
caveling-2-mini (hw::CAVELING_2_MINI, since 0.5.6) is
Caveling 2 Mini, caveman-so's
Apache-2.0 fine-tune of Inkling 2 Mini (26B mixture of experts, 3.4B active, text and vision)
that spends about 43% fewer reasoning tokens. The entry pins the Q4_K_M GGUF and the Q8_0 vision
projector (CatalogEntry::projector); the repo also holds an NVFP4 file, a draft model for
speculative decoding and an importance matrix, which are not the chat model, so hf::parse_files
leaves the drafter (dspark-) and the matrix (imatrix) out and a pull picks a model file. It runs at
a context of 346112 tokens (launch_context(), the figure its footprint is sized at), with
launch_gpu_layers() of 99 and engine_args() of -fa on --jinja. hw::plan still prefers
the larger Qwen3 models that fit.
inkling-2-mini (hw::INKLING_2_MINI, since 0.5.7) is the model Caveling 2 Mini is fine-tuned
from: Inkling 2 Mini from Thinking
Machines (Apache-2.0), as ggml-org's GGUF.
It has the same shape and the same launch values (346112 tokens, 99 layers, -fa on --jinja),
pins the IQ4_NL file (17.6 GB; the repo also holds BF16, Q8_0 and NVFP4 files and an importance
matrix) and the Q8_0 vision projector. Both entries size the KV cache at eight full-context layer
caches (four attention layers, two of them in the looped core, which keeps a cache for each of
its three passes), so their footprint is larger than 0.5.6's for Caveling.
Chat checkpoints for vLLM
Two chat entries are Hugging Face checkpoints that vLLM serves, not GGUF files
(CatalogEntry::is_gguf() is false): qwen3-vl-8b (hw::QWEN3_VL_8B, four shards) is
Qwen3-VL 8B Instruct (Apache-2.0; text,
images and video), and qwen3.8-27b-nvfp4 (hw::QWEN3_8_27B_NVFP4, three shards) is
RadixArk's NVFP4 quantization of Qwen3.8 27B
(Apache-2.0; its card names SGLang and NVIDIA Blackwell GPUs). Like the speech-to-text
checkpoints they list every shard in files() with its own hash and carry the Hub commit in
revision(), and hw::plan never picks them: it proposes GGUF models only, and an app that
runs vLLM chooses one with hw::by_purpose(Purpose::Chat).
Text to speech
The speak role (Purpose::Speak) is text in, audio out. Each entry has a SpeechProfile
(CatalogEntry::speech()): its preset voices, whether it designs a voice from a description,
takes style instructions, clones a voice from a reference clip (and whether the clip's
transcript is used or required), speaks multi-speaker scripts, takes raw engine input or a
speed, streams; its languages, output formats and sample rate; and its limits. Every field is
cited to the model's card and its engine's documentation, or absent: nothing is defaulted, and a
model is never said to do what it doesn't.
| Id | Model | Engine | Does |
|---|---|---|---|
qwen3-tts-0.6b-customvoice |
Qwen3-TTS 0.6B CustomVoice | vLLM-Omni | nine preset voices |
qwen3-tts-0.6b-base |
Qwen3-TTS 0.6B Base | vLLM-Omni | voice cloning |
qwen3-tts-1.7b-customvoice |
Qwen3-TTS 1.7B CustomVoice | vLLM-Omni | nine preset voices, style instructions |
qwen3-tts-1.7b-voicedesign |
Qwen3-TTS 1.7B VoiceDesign | vLLM-Omni | a voice from a description |
qwen3-tts-1.7b-base |
Qwen3-TTS 1.7B Base GGUF | llama.cpp | voice cloning |
kokoro-82m |
Kokoro 82M GGUF | llama.cpp | 54 preset voices, phonemes, speed |
voxcpm2 |
VoxCPM2 GGUF | llama.cpp | voice design and cloning, 30 languages |
fish-audio-drama-3 |
Fish Audio Drama 3 GGUF | llama.cpp | scripts of up to 16 speakers |
GGUF entries (CatalogEntry::is_gguf) pin the model and its projector (CatalogEntry::projector,
the codec and voices), both counted in footprint. The others name the Hugging Face repo
vLLM-Omni serves and pin its main weights for sizing.
Fish Audio Drama 3 is under the Fish Audio Community License
(speech::FISH_AUDIO_COMMUNITY): CatalogEntry::restricted() is true, hw::speaker never
picks it, and download refuses its files (by id, or from its repos under any id) unless the
consent also accepts the license:
use ;
let drama = find.unwrap;
let consent = given.accepting_license;
hw::plan never proposes a speaker; hw::speaker(&budget) returns the largest unrestricted GGUF
one that fits, and hw::by_purpose(Purpose::Speak) lists them. A hand-placed GGUF speech model
gets its profile from its headers: speech::from_gguf(model, projector) (Qwen3-TTS, Kokoro with
the voices stored in its projector, VoxCPM2, Drama 3, as llama.cpp documents them), which
limits::measure puts in LimitsRecord::speech so it is kept with the model's limits. With the
agent feature SpeechProfile converts to and from weirdnet_agent::speech::SpeechProfile, with
the same form on the wire.
Model limits
A client fitting images, audio or a video's frames to a model needs that model's limits, and
there are no defaults: what isn't known stays absent. ModelLimits holds the context the model
runs with on the node, images per request, what an image costs (a fixed number, or one token per
image_patch pixels square up to image_tokens), the longest image edge, audio length and cost
(per minute, and per piece for encoders that work on 30-second pieces), video length, bytes and
frames per minute,
and the largest request. or puts an operator's settings over measured ones, tightest merges
copies, and image_cost and audio_cost price one input. With the agent feature it converts
to and from weirdnet_agent::MediaLimits for catalog entries.
When a node loads a model, limits::measure(model, projector, context) reads the GGUF and its
projector: what the projector's header says images and audio cost (for Gemma 3, Qwen-VL,
Voxtral, Ultravox and Qwen2 audio projectors, as llama.cpp computes it) and the context passed in,
never the trained context. ModelStore::record_limits keeps the result next to the model's
files and StoredModel::limits reads it back, until the model's files change.
use ;
let store = from_env;
let model = &store.list;
let first = store.dir.join;
let record = measure?;
store.record_limits?;
Hub search, fit and downloads
use ;
let store = from_env;
let hub = store.hub_client;
let hits = hub.search?;
let repo = &hits.id;
let models = hub.models?; // split GGUFs come back as one model with all its parts
let info = hub.gguf_info?; // header only, through a Range request
let hw = detect;
let opts = default.with_slots.with_info;
let best = choose.expect;
let parts = best.model.specs?;
// Show the user what will be fetched, then:
let path = download_parts?;
Search and files come from the Hugging Face Hub. The footprint is the weights plus the KV cache for every slot at the chosen context, plus 10% for compute buffers, the same as the tiered catalog's. Without a header the KV cache is guessed high from the file size.
The Hugging Face token comes from this node only: HF_TOKEN, HUGGING_FACE_HUB_TOKEN, or the
token file at HF_TOKEN_PATH, HF_HOME/token or ~/.cache/huggingface/token. ModelStore::from_env
sends it only to the public Hub, never to a WEIRDNET_HF_URL mirror (with_token sends it to
any Hub you pick). Redirects to other hosts don't carry it, its Debug output is redacted, and it
has no serde support, so it can't travel to another node in a message.
LoRA adapters
use ;
let store = from_env;
let hub = store.hub_client;
let adapters = hub.adapters?; // GGUF LoRA files and PEFT directories
let tune = &adapters; // id, format, files, size, architecture, base_model, rank, alpha
// Show the user what will be fetched, then:
let path = download_adapter?;
for a in store.adapters
A GGUF file is an adapter when its header says general.type = adapter; LoRA adapters also
have adapter.type = lora and adapter.lora.alpha, the keys
llama.cpp's convert_lora_to_gguf.py writes.
gguf::read_header reads any GGUF header (models and adapters; read_info still fails on
adapters, which have no blocks). A PEFT adapter is an adapter_config.json with peft_type
LORA next to adapter_model.safetensors (or .bin), the layout vLLM serves.
Adapters are never models: Hub::models reads the header of every file whose name hints at an
adapter (a lora or adapter word) and leaves real adapters out, so fits never rank one, and
ModelStore::list skips adapters/ and hinted GGUFs whose header says adapter. Hub searches
leave adapter repos out unless Search::with_adapters(true). Adapters download into
adapters/<id>/ under the store with the same consent, resume and SHA-256 checks as models, plus
an adapter.json with the repo, format and base model (no paths).
Your own model files
For weights a person brings themselves (a fine-tune made on another machine, a trainer's
output), artifact::inspect reads and hashes the files and ModelStore::import places them in
the store with a provenance record next to them.
use PathBuf;
use ;
use ;
let store = from_env;
// One directory, or files one by one (a GGUF, every part of a split GGUF).
let found = inspect?;
println!;
let record = for_artifact.with_license;
// `staged` holds the files under their artifact paths, outside the store (an upload's parts).
let staged = from;
match store.import?
println!;
What inspect accepts: GGUF models (split ones with every part), GGUF LoRA adapters and
multimodal projectors (GgufKind::Projector: general.type = mmproj or the clip
architecture), safetensors model directories (config.json with architectures, an index that
covers every shard), MLX directories (MLX-LM's format = mlx metadata or a quantization
block in config.json) and PEFT LoRA directories. Weights are data, never code: pickled weights
(.bin, .pt, .pth, .ckpt, .pkl), Python files and other code are refused, and so are
symlinks, hidden files given by name and anything that isn't a regular file. Headers are read
with size caps before anything is hashed; artifact::early_header checks a header from the
first bytes of a file still being received. The revision is sha256: and the first 16 hex
digits of the SHA-256 of the sorted path:sha256 lines.
import checks the staged files against the artifact (size, SHA-256 and headers), sets the
record's id, kind, files and revision from the bytes, moves the files into a work directory
next to the target and renames it into place last. Layout: a GGUF model in <id>/, an adapter in
adapters/<id>/ (with its adapter.json), a projector in projectors/<id>/, a safetensors
model in safetensors/<id>/ and an MLX model in mlx/<id>/. list keeps listing GGUF models
(an imported one under its id, with provenance); dir_models lists the safetensors and MLX
directories, projectors the projectors. An adapter's size leaves adapter.json and
provenance.json out. free_bytes and disk_space read the store's filesystem.
CPU support
llama.cpp's build turns on AVX, AVX2, BMI2, FMA and F16C by default, so a plain llama build runs
only on x86 CPUs that have them (Intel Haswell and AMD Excavator, 2013 to 2015, and later). Two
things keep older CPUs from crashing with an illegal instruction:
- The guard, always on.
build.rsworks out which instructions the linked llama.cpp contains (from the target features,target-cpu=native,GGML_*environment variables andSOURCE_DATE_EPOCH, the wayllama-cpp-sys-2configures it).LlamaEngine::loadcallscpu::check()before any llama.cpp code runs and returnsError::UnsupportedCpu { missing }on a CPU without them. Apps can callcpu::check()themselves to hide local models, or to offer another machine instead.examples/model.rs cpuprints the result. cpu-dispatch, for release binaries that should run local models on any CPU. It enables llama-cpp-2'sdynamic-backends(GGML_BACKEND_DLplusGGML_CPU_ALL_VARIANTS): ggml is built once per CPU level (x86: baseline x86-64, SSE4.2, Sandy Bridge, Haswell, AVX-512 levels up to Sapphire Rapids; ARM: armv8.0 to armv9.2, Apple M1 to M4) and asks each library at load time whether this CPU can run it, keeping the best. Speed on a modern CPU is the same as the static build, because the same AVX2 code runs.
cpu-dispatch makes llama.cpp shared libraries that the app has to ship:
libllama,libllama-common,libggml,libggml-base(.so,.dylibor.dll), which the executable links against. On Linux and macOS, point the executable's rpath at them (for example-C link-arg=-Wl,-rpath,$ORIGINon Linux); on Windows put the DLLs next to the.exe. Without them the app does not start at all, not just local models.- one
libggml-cpu-<level>library per CPU level (.soon Linux and macOS,.dllon Windows), pluslibggml-vulkanorlibggml-metalwith those features. They load fromllama::backends_dir(): the directory given tollama::set_backends_dir, elseWEIRDNET_GGML_BACKENDS_DIR, else the executable's directory (a development build falls back to wherellama-cpp-sys-2built them). The working directory is never searched. If none loads, loading a model fails withError::NoCpuBackend.
On x86-64 Linux (llama-cpp-sys-2 0.1.161, release, stripped) that is a 4.3 MB executable plus four
shared libraries (11 MB) and 14 CPU libraries (20 MB), 35 MB in all, against 9.4 MB for the static
example. Ship the versioned names the executable asks for (libllama.so.0 and so on).
llama-cpp-sys-2 0.1.161's shared-library build does not work with Rust 1.100's build directory
layout (its build script fails with "No such file or directory"), so build cpu-dispatch with Rust
1.99 for now. A second build in the same target directory can also fail with "File exists" on the
library symlinks it left there; deleting target/<profile>/{,deps/,examples/}lib*.so* symlinks
between builds avoids it. The static llama build has neither problem.
Without cpu-dispatch, a static build can still run everywhere at a speed cost by building ggml
for an older level, for example GGML_AVX=OFF GGML_AVX2=OFF GGML_BMI2=OFF GGML_FMA=OFF GGML_F16C=OFF in the build environment (SSE4.2, Nehalem and later). The guard follows those
variables. ARM builds need nothing: llama-cpp-sys-2 builds for armv8-a on Linux, and macOS uses
the compiler's Apple M1 baseline. Do not use target-cpu=native for anything you distribute.
License
BSD-3-Clause.