The pieces / weirdnet-backends

weirdnet-backends

The model-node wrapper: llama.cpp, vLLM, vLLM-Omni and MLX-LM adapters, LoRA adapters on a base model with live changes and per-request scale, node reservations, uploads and node-to-node copies of models under a write policy, per-model capabilities with limits measured at load, speech-to-text (with a plain-JSON retry for servers that refuse verbose_json) and text-to-speech models and native video served over infer/2, per-model engine environment variables, a supervisor with swap groups, idle unload with a keep-warm countdown and crash backoff, raw infer/2 serving, /weirdnet-backends/node/1 with signed capability records, lost-group reports and placement-lease fencing on load and unload, and owner-only model downloads over /weirdnet-backends/models/1.

v0.4.15 GitHub crates.io docs.rs weirdnet-backends = "0.4.15"

What it brings

Use weirdnet-backends on a machine that runs models for the user's other devices. It wraps llama.cpp's llama-server, vllm serve and, on Apple silicon, MLX-LM's mlx_lm.server (or a stock OpenAI-compatible server already running on loopback) and keeps them healthy, so inference nodes only have to say what should be loaded and send requests.

  • Engines handled: loopback-only ports, a per-process API key in the environment, readiness probes, logs.
  • Memory handled: swap groups so models that share a GPU never load together, and idle unload.
  • Failures handled: restarts with backoff, crash loops reported rather than retried forever.
  • One protocol: signed capability records and commands over weirdnet-net, inference over infer/2.

What it is

A model node runs models and takes requests, like a llama.cpp, vLLM or MLX-LM server; it can even be one, a stock server it only wraps. weirdnet-backends starts and stops the engines and serves them to inference nodes. It decides nothing beyond the node: what to load, and where, is the caller’s decision. It has no app-specific types.

Requests and errors are weirdnet-agent 0.5 infer/2 types, so a model node serves raw /weirdnet-agent/infer/2 through ModelHost, an InferHost. The node feature adds /weirdnet-backends/node/1 over weirdnet-net 0.8: inference nodes subscribe to signed capability records and send Load, Unload, Drain, GroupUp/GroupDown and Health.

How it works

The supervisor

Supervisor::new(engines, models, options) knows every model the node may run (ModelLaunch: id, engine, GGUF path or Hugging Face id, context, slots, GPU layers, swap group, idle timeout, extra flags, or a Wrap). load picks a free loopback port and a random API key, starts the engine in its own process group, and polls /health until it answers; loading a model in a swap group first drains and stops the group's other models. Load and unload are serialized, so swaps never interleave. unload waits for requests under way (up to drain_timeout), then stops the engine: SIGTERM, then SIGKILL after stop_grace. A crash while serving restarts the engine after a backoff that doubles per crash; max_crashes within crash_window is a crash loop, and only a forced load starts it again. Everything that happens is a SupervisorEvent.

Serving infer/2

ModelHost is a weirdnet-agent InferHost. Each request names a model (or gets the default); the request becomes an OpenAI streaming body for the engine (an assistant prefix becomes a trailing assistant message, with continue_final_message on vLLM), and the engine's server-sent events become infer/2 text, reasoning and tool-call frames. Cancelling the request drops the engine stream. Model nodes serve raw infer/2 only: the inference node has already assembled the messages. Since 0.1.1 raw prompts go to the engine's /v1/completions.

Images and audio (0.2.0)

weirdnet-agent 0.5 content parts (image_url with a data: URL, input_audio) go to llama.cpp unchanged, in the OpenAI shape. ModelLaunch::capabilities derives what a model takes: llama.cpp models launched with a multimodal projector (--mmproj) take images and audio, vLLM and MLX-LM models are text only, and embedding models only embed. ModelHost refuses parts the model's Capabilities lack (Unsupported, so a pool tries another node) and remote image URLs (BadRequest). An inference node puts Capabilities::inputs() in the model's catalog entry (CatalogModel::with_inputs), so the pool routes image and audio requests to it.

Its own protocol id (0.1.1)

An inference node serves /weirdnet-agent/infer/2 to apps, so a machine that is both an inference node and a model node could not also take raw infer/2 for its models on the same id. 0.1.1 gives raw inference its own id, /weirdnet-backends/infer/1 (RAW_INFER_PROTOCOL), with the same infer/2 framing. NodeServer always serves it and lists it in the weirdnet-backends-node announcement; it keeps serving infer/2 too, for 0.1.0 inference nodes, unless NodeServer::start_with(.., NodeServerOptions::default().with_legacy_infer2(false)) leaves infer/2 to the inference role. On the inference node, wrap the dialer of the model-node Pool in RawInferDialer: infer/2 opens try the new id first and fall back to infer/2 on a node that doesn't accept it, remembering that node. Inference nodes on 0.1.0 keep working against 0.1.1 model nodes as they are.

node/1

A Capability record lists the hardware and memory budget (weirdnet-model hw), the engines, every configured model with its state, revision, quantization, context and slot limits, load-time estimate and measured speed, the load (queued, active, slots, in flight), warm prefix hashes, swap groups, and the draining and group-job flags. The node signs the CBOR record with its own key; the record carries the user's NodeCert for that node, an increasing sequence number and a 90 second expiry. Subscribers get one at once, every 15 seconds and on every change; Verifier checks the signature, that the signer is the peer on the stream, the expiry and the user's certificate, and Subscription rejects a sequence that goes backwards. Withdrawal ends subscriptions.

Commands are one per stream: Load (waits until ready), Unload, Drain (stops new requests and waits for those under way), GroupUp/GroupDown and Health. Who may send them is an Authorize hook; RosterAuth admits the user's linked devices.

Managing models (0.3.0)

Supervisor::add_model and remove_model serve a new model, or stop serving one, without restarting the node (SupervisorEvent::Added, Removed). With the node feature, models::ModelsService serves /weirdnet-backends/models/1 to the node's owner only: it takes an Authorize such as RosterAuth (the owner's linked devices, narrowed with require_roles). Commands are Search (GGUF repos on the Hugging Face Hub), Files (a repo's models, each measured against the node's memory budget), Pull (download with progress, resuming a partial file, split GGUFs too; with no file named, the largest that fits), which can hand the model to the supervisor to serve or load, List and Remove. Closing a pull's stream cancels it. The Hugging Face token is the node's own (weirdnet-model HfToken) and never crosses the wire. ModelsServer::start serves it on a weirdnet-net node; ModelsClient is the owner's side.

LoRA adapters (0.4.0)

A LoraAdapter (an id, a path and an optional scale) is served on a base model: ModelLaunch::with_adapters adds them, served_ids lists the base and adapter ids, and check_adapters checks them before a load: on llama.cpp it reads each file's GGUF header through weirdnet-model and takes only LoRA adapters with the base's architecture; on vLLM an adapter is a PEFT LoRA directory or a Hub id. A request names either the base or an adapter; openai::Target is Base or Adapter, and chat_body_for and completion_body_for write the engine body for it. llama.cpp starts with one --lora per adapter and --lora-init-without-apply, and each request carries a lora list that turns on only its adapter; vLLM starts with --enable-lora, one --lora-modules list and --max-loras. Supervisor::add_adapter and remove_adapter return an AdapterChange: Live when it applies now, NextLoad when it waits for the next load. ModelStatus::base names the base model, and each adapter gets its own status row. On models/1, Pull::adapter_for downloads an adapter for a base and RepoFits::adapters lists a repo's adapters.

0.4.0 is breaking: ModelLaunch is #[non_exhaustive], so build it with ModelLaunch::new and the with_ methods; StoredEntry::model is an Option, with new adapter and base fields; StoredEntry and RepoFits are no longer Eq; and weirdnet-model is always a dependency.

Live adapters and scale (0.4.1)

On vLLM, add_adapter_live and remove_adapter_live load and unload an adapter in the running engine (the supervisor sets VLLM_ALLOW_RUNTIME_LORA_UPDATING), within ModelLaunch::lora_slots. On llama.cpp, set_adapter_scale changes an adapter's strength without a restart, and a request can set its own with Request::adapter_scale (weirdnet-agent 0.5.2; complete_scaled), capped at MAX_ADAPTER_SCALE. vLLM applies adapters at full strength and refuses a scale. The owner's models/1 adds ServeAdapter, UnserveAdapter and AdapterScale.

Readiness (0.4.2)

An engine counts as ready only when its /v1/models answers with the launch's API key and lists the launch's model id, so another process that took the port first is never mistaken for it. A launch that lost its port starts again on a new one, up to 3 times, without counting as a crash.

Reservations (0.4.3)

Supervisor::reserve(holder) stops the node's engines and holds its accelerators for one holder, returning a Reservation; while it lasts every load is refused, forced ones too, until release(holder). reservation_changes watches it. On node/1, Command::Reserve and Release (NodeClient::reserve and release) do the same remotely, and Capability::reserved and Health::reserved tell routers to skip the node.

Uploads and copies (0.4.4)

The owner can send local files to a model node over models/1. ModelsClient::upload takes what weirdnet-model's artifact::inspect read and sends ModelsCommand::Upload with the file list, sizes, SHA-256s and a Provenance. The node checks names, size, quota, free disk, the engine and, for adapters and projectors, the base, then answers UploadReady with the bytes it already holds of each file; the client sends UploadFrame::Chunks of at most 48 KiB (CHUNK) from there. Each GGUF or safetensors header is checked as soon as it arrives, so a wrong file is refused early. At the end the node checks every size, SHA-256 and header, places the entry with ModelStore::import_files, serves it when asked (adapters go live on their base) and answers Uploaded. Closing the stream cancels, and the received parts stay in a staging directory outside the store for a resume until WritePolicy::part_ttl (a week by default); AbandonUpload drops them.

Nodes copy from each other with ModelsCommand::Fetch: Pull::from_peer (PullSource::Peer) pulls an upload or a stored entry from another node, once ModelsService::with_peer_dialer lets the node dial out, and ModelsClient::replicate has several nodes pull an upload from the node it landed on at the same time.

Every write (uploads, removes, peer copies) follows the WritePolicy: an optional separate write Authorize, max_upload, a quota on uploaded bytes, and KeepFree, the space never filled (10 percent or 20 GiB by default, the larger). Without a write Authorize, any caller the service admits may write. Since 0.4.7, WritePolicy::with_uploads(false) turns uploads off alone: they are refused with not-allowed, while pulls, peer copies and removals keep working. ModelsCommand::Disk returns a DiskReport (free and total bytes, the limits, uploaded and staged bytes). List includes safetensors and MLX models and projectors, with provenance (StoredEntry::provenance()). StoredEntry::list(&store) (0.4.7) lists a ModelStore the same way without a running service, and StoredEntry::from_model, from_adapter and from_projector, with with_served and with_base, build entries without serde. Refusals carry stable reasons in refusal (exists, too-big, no-space, quota, wrong-engine, wrong-arch, no-base, checksum and others), read with refusal_reason. Nodes before 0.4.4 refuse the new commands.

Media limits (0.4.8): Capabilities::limits carries a model's media and request limits (a weirdnet-agent 0.5.7 MediaLimits). The operator sets numbers the node can't measure with ModelLaunch::with_limits; they reach every ModelStatus and capability record, and ModelStatus::limits() reads them back. Capabilities::intersect keeps the stricter limits. Capabilities::apply_to and ModelStatus::apply_to fill a catalog/1 entry's inputs, limits and context window. Records without limits read as before.

Measured limits (0.4.9)

When a model loads (started or wrapped), the supervisor measures what it can and never fills in the rest. For a llama.cpp model whose source is a GGUF file it reads the model's and the projector's headers with weirdnet-model 0.5.4 limits::measure: what one image costs (fixed, or per patch up to a cap; --image-max-tokens in the engine's or the model's extra arguments caps a size-dependent projector) and what audio costs. For every engine that says, it asks for the context per sequence it actually runs (llama-server /props, per slot; vLLM /v1/models max_model_len). Supervisor::capabilities and every ModelStatus carry the operator's ModelLaunch::limits over the measured ones, field by field; a figure nobody knows, such as images per request or the longest audio, stays absent. Supervisor::measured_limits returns the LimitsRecord, and ModelStatus::context_tokens the context per sequence, which ModelStatus::apply_to puts in the catalog entry instead of the configured --ctx-size. Supervisor::set_limits_store keeps records next to the model files in a ModelStore and reads them back for models not loaded yet (without the context, which belongs to the run that measured it), so an unloaded model still reports its image and audio figures after a restart. Changing a model's projector clears its measurement.

Transcription (0.4.9)

ModelLaunch::with_transcribe(true) gives a model the transcription role. Capabilities::transcribe says the node can serve it: llama.cpp with an audio projector (Voxtral, say) or vLLM (Whisper, say); never MLX-LM or an embedding model. ModelLaunch::purpose, ModelStatus::purpose and ModelStatus::catalog_model(state) give catalog/1 Purpose::Transcribe (weirdnet-agent 0.5.8), so Catalog::route_transcribe finds it. ModelHost serves infer/2 Transcribe (InferHost::open_transcribe): a named model must transcribe on the node (otherwise Unsupported, so a pool tries elsewhere); with none named it takes the loaded transcriber, or with load on demand the first one. Supervisor::transcribe sends llama.cpp a greedy chat request with the clip as a base64 input_audio part (llama-server takes WAV and MP3) and an instruction to answer with the transcript only, naming the language and the prompt when given; the duration comes from a WAV header, and there are no segments. vLLM gets /v1/audio/transcriptions, with timed segments when timestamps are asked for. A vLLM server that refuses verbose_json (Qwen3-ASR) with an HTTP 400 naming it gets one more request with response_format=json (0.4.15): the transcript is the text alone, with the duration from a WAV clip's header and the language that was asked for, and no segments. Any other 400 comes back as it is, and a request that did not ask for timestamps never retries.

Per-model environment (0.4.15)

ModelLaunch::with_env(name, value) sets an environment variable on that model's engine process only, and with_envs takes several; ModelLaunch::env (a LaunchEnv) reads them back. They are set when the engine starts, for llama.cpp, vLLM, vLLM-Omni and MLX-LM, and reach no other launch and not the node itself. The node's own variables are set after them, and ModelLaunch::check_env (which Supervisor::add_model and loading run) refuses LLAMA_API_KEY and VLLM_API_KEY, an empty name, and a name with = or a NUL byte. Values can be secrets, so Debug shows the names only. A launch with none serializes as before.

use weirdnet_backends::{EngineKind, ModelLaunch};

// One transcriber without vLLM's Rust frontend; every other model on the node keeps it.
let asr = ModelLaunch::new("qwen3-asr-1.7b", EngineKind::Vllm, "Qwen/Qwen3-ASR-1.7B")
    .with_transcribe(true)
    .with_env("VLLM_USE_RUST_FRONTEND", "0");
asr.check_env()?;

Native video (0.4.10)

vLLM can read whole clips with models such as Qwen2.5-VL and Qwen3-VL, but the engine doesn't say so, so the operator does: ModelLaunch::with_video(true) on a vLLM model (a wrapped mistral.rs server is declared as vLLM). Capabilities::video and Capabilities::inputs() then put video in the catalog entry's inputs, and the video fields of MediaLimits (video_max_seconds, video_max_bytes, video_frames_per_minute, from the operator or a measured record) travel in capability records and catalog entries. video_url parts (weirdnet-agent 0.5.11 ContentPart::VideoUrl, a data:video/ URL) reach vLLM unchanged. On llama.cpp, MLX-LM or a model not marked, the request is Unsupported with weirdnet-agent's VIDEO_FALLBACK (send frames instead), so a pool tries a node that reads video; a clip over video_max_bytes is a BadRequest naming the limit.

Speech out (0.4.10)

ModelLaunch::with_speak(true) gives a model the speech role. It runs on llama.cpp (a speech GGUF with its projector, such as Kokoro, VoxCPM2 or Fish Audio Drama 3) or on vLLM-Omni (EngineKind::VllmOmni, EngineConfig::vllm_omni, started as vllm serve MODEL --omni, never with local media paths; Qwen3-TTS CustomVoice, VoiceDesign and Base). EngineKind::install_hint, supported_here and EngineConfig::version help an app offer the engine. A speaker speaks and does nothing else: Capabilities::speak and catalog/1 Purpose::Speak, so Catalog::route_speak finds it.

Its speech profile (weirdnet-agent's SpeechProfile: preset voices, voice design, instructions, clone mode, script speakers, raw input, speed, streaming, languages, formats, sample rate, limits and license) is ModelStatus::speech, which apply_to copies into the catalog entry. At load the supervisor asks the engine (llama-server /props voices; vLLM-Omni GET /v1/audio/voices and the sample rate of a one-word probe) and merges that over the GGUF headers and the weirdnet-model 0.5.5 catalog entry with SpeechProfile::or, keeping the result in LimitsRecord::speech. The operator can only narrow it (ModelLaunch::with_speech; check_speech refuses settings that widen it).

ModelHost serves infer/2 Speak (InferHost::open_speak) the way it serves transcription, through Supervisor::speak. A request the profile doesn't cover is a BadRequest naming what is missing; a format only another engine makes is Unsupported. Both engines get /v1/audio/speech: a preset voice; a designed voice (VoxCPM2's parenthesized prefix on llama-server, instructions on vLLM-Omni); a cloned voice from an inline clip only (llama-server speaker_ref_b64, vLLM-Omni ref_audio as a data: URL with ref_text and a per-request cache_salt); Drama 3 scripts as <|speaker:N|> tags; raw phonemes; speed, language, seed and format; and streaming with stream_format: "audio". Audio comes back whole or as it streams, with format, sample rate and channels when known and usage in characters and milliseconds. A field the model ignores is named in Meta::ignored. Capability records naming the vllm-omni engine are new in 0.4.10; older nodes don't know that engine.

Placement-lease fencing (0.4.11)

When one caller places models across nodes under a lease (such as a weirdnet-sync lease, whose term strictly increases with each new holder), a holder that was paused or cut off can wake up and keep sending loads and unloads after another has taken over. Fenced commands let the node stop it: NodeClient::load_fenced and unload_fenced send node/1 Command::LoadFenced and UnloadFenced with a fence::Fence, the lease name and the holder's term. The node checks the fence before it loads or unloads anything against a FenceGuard, the highest term seen per lease name (equal terms pass), and refuses an older term with the model left as it is.

The refusal travels as a Refused error with a fixed message, and FenceRefusal::from_error reads it back as Stale { lease, term, seen } or Required, so the caller can stop rather than retry. NodeService::with_fence_file keeps the guard on disk (saved before a newer term runs; a failed save refuses the command), so a restart keeps refusing old terms; its bytes are the same as weirdnet_sync::FenceGuard::export. with_fence_required(true) refuses unfenced Load/Unload; it is off by default, so an operator's unfenced commands still run. Capability records carry fencing (and fence_required when on), so a caller sends fenced commands only to nodes that check them: unfenced commands are the same bytes as in 0.4.10, and nodes before 0.4.11 fail fenced ones instead of running them unfenced.

Video models take images, Qwen-VL image cost (0.4.12)

A vLLM model marked video reads video as frames, so it reads single images the same way: Capabilities::vision and catalog/1 inputs.vision are on for it. For a vLLM model served from a Hugging Face directory whose preprocessor_config.json names a Qwen-VL image processor (image_processor_type Qwen2VLImageProcessor or Qwen2VLImageProcessorFast: Qwen2-VL, Qwen2.5-VL and Qwen3-VL), the image cost comes from that file: image_patch is patch_size × merge_size and image_tokens is max_pixels / image_patch², where max_pixels is vLLM's --mm-processor-kwargs value when set, else the file's max_pixels or the fast processor's size.longest_edge (a pixel count). It is measured at load and read from the directory before the first load (Supervisor::set_limits_store), so clients that size frames by the image cost can attach video. A video frame costs at most what an image of its size does; other processors stay unknown.

Keep-warm countdown (0.4.13)

ModelStatus::keep_warm_secs is how long a model stays loaded after its last request finishes (its ModelLaunch::idle_ttl; absent when it stays loaded), and ModelStatus::unload_in_secs is, for a ready model with nothing in flight, the seconds left before the idle reaper (Supervisor::reap_idle) stops its engine; absent when the model is unloaded, loading, busy or kept loaded. A node can show from them how long an idle model stays warm. Both are left out of records when unset, and older readers ignore them.

Lost groups (0.4.14)

A model spread over several machines runs as a group (GroupUp/GroupDown, carried out by the application's GroupWorkers). When a member's own part stops by itself, say a Ray worker or rpc-server crashes, the application calls NodeService::group_lost(group) after cleaning up what was left: the group leaves the record's groups at once and subscribers get a fresh record, so the inference node that started the group sees the loss on its next record, not only when a whole node goes away, and takes the other members down. It returns false when this node was not in the group.

Placement hooks, origin and license (0.4.5)

ModelsService::on_placed runs a callback (OnPlaced) after each upload, peer copy (including ModelsClient::replicate targets) or Hub pull is placed. It gets a Placed: the StoredEntry with its provenance, the Pulled answer with its revision, how it arrived (PlacedVia: Upload, Peer or Hub), and serve_error when the files were placed but serving them failed. ModelsService::with_node_info uses it to keep the node's capability record current (NodeService::set_model_info). Capability records also carry each model's origin and license (ModelEntry::origin and license: hub, upload or train, as in a weirdnet-model provenance record, and an SPDX license), set with NodeService::set_model_origin or, through with_node_info, from each placed entry's provenance (Placed::origin_and_license). They are left out of the record when unset.

Projectors (0.4.4)

ModelLaunch::with_mmproj gives a llama.cpp model a vision projector: the engine starts with --mmproj and capabilities() reports image input. Supervisor::set_projector_live sets or clears it; the capabilities change at once, and the running engine picks it up at the next load, so a served model is reloaded when its projector changes.

Link info and the roster (0.1.2)

Capability records carry the node's private links (Capability::links: address, AddrClass, interface, the NIC's nominal speed and an operator-declared one), set with NodeService::set_links; link::local_links() lists this machine's interfaces. Only loopback, link-local and private addresses are ever advertised, never public or CGNAT ones. Older verifiers ignore the field. Verifier::with_roster(roster) also checks the record's node against the roster, so a revoked model node is refused even when it presents its old certificate. Model nodes should admit callers with RosterAuth::require_roles (weirdnet-agent 0.4.4). 0.1.2 accepts weirdnet-sync 0.5 to 0.7; 0.4.6 accepts 0.5 to 0.8.

Platforms

LinuxmacOSWindows
llama.cppyesyesyes
vLLMyesnono
Graceful stop (SIGTERM, then SIGKILL)yesyesno: killed outright
Own process groupyesyesno
Dies with the node processyesnono

Key types and modules

  • Per-model environment (0.4.15): ModelLaunch::with_env("VLLM_USE_RUST_FRONTEND", "0") (and with_envs for several) sets variables on that model’s engine process only, such as one transcriber rather than the whole node; ModelLaunch::env reads them back, and Debug shows the names and not the values. They are set on the launch’s command for llama.cpp, vLLM, vLLM-Omni and MLX-LM, never on another launch. ModelLaunch::check_env (run by Supervisor::add_model and on load) refuses an empty name, a name with = or a NUL byte, and LLAMA_API_KEY and VLLM_API_KEY, which the node sets itself. A launch with none serializes as before.
  • Transcription fallback (0.4.15): when a vLLM server answers a verbose_json transcription request with HTTP 400 naming verbose_json (Qwen3-ASR does), Supervisor::transcribe asks once more with response_format=json. The transcript is then the text alone, without segments; its duration comes from a WAV clip’s header and its language is the one asked for. Any other 400, and a request that did not ask for timestamps, is not retried.
  • Lost groups (0.4.14): NodeService::group_lost(group) drops a group whose processes on this node stopped by themselves (a Ray worker or rpc-server crashed) from the record’s groups at once and sends subscribers a fresh record, so the inference node that started the group sees the loss and takes the other members down; it returns false when the node was not in the group. The application’s GroupWorkers calls it after cleaning up its part.
  • Keep-warm countdown (0.4.13): ModelStatus::keep_warm_secs is how long a model stays loaded after its last request (its idle_ttl; absent when it stays loaded), and ModelStatus::unload_in_secs, for a ready model with nothing in flight, the seconds left before Supervisor::reap_idle stops its engine, so a node can show how long an idle model stays warm. Both are left out of records when unset, and older readers ignore them.
  • Video models take images, Qwen-VL image cost (0.4.12): a vLLM model marked video takes single images too (Capabilities::vision, catalog/1 inputs.vision), since it reads video as frames. For a vLLM model served from a Hugging Face directory with a Qwen-VL image processor (preprocessor_config.json with Qwen2VLImageProcessor or Qwen2VLImageProcessorFast: Qwen2-VL, Qwen2.5-VL, Qwen3-VL) the image cost comes from that file: image_patch is patch_size × merge_size and image_tokens is max_pixels / image_patch² (vLLM’s --mm-processor-kwargs max_pixels wins), measured at load and read from the directory before the first load. A video frame costs at most what an image of its size does; other processors stay unknown.
  • Placement-lease fencing (0.4.11): the lease holder sends Command::LoadFenced / UnloadFenced (NodeClient::load_fenced, unload_fenced) with a fence::Fence (lease name and term). The node keeps the newest term per lease in a FenceGuard (NodeService::with_fence_file keeps it across restarts) and refuses an older term, changing nothing, as a FenceRefusal the caller reads back with FenceRefusal::from_error and stops on. with_fence_required refuses unfenced Load/Unload; records say fencing. Unfenced commands are unchanged on the wire, and nodes before 0.4.11 fail fenced ones.
  • Native video (0.4.10): ModelLaunch::with_video marks a vLLM model that reads whole clips (Qwen2.5-VL, Qwen3-VL; a wrapped mistral.rs server is declared as vLLM); Capabilities::video and inputs().video publish it with the video MediaLimits. video_url parts reach vLLM unchanged; elsewhere they are Unsupported with weirdnet-agent’s VIDEO_FALLBACK (send frames), and a clip over video_max_bytes is a BadRequest. Since 0.4.12 such a model takes images too. Needs weirdnet-agent 0.5.11.
  • Speech out (0.4.10): EngineKind::VllmOmni (vllm serve MODEL --omni; EngineConfig::vllm_omni, EngineKind::install_hint, EngineConfig::version) and ModelLaunch::with_speak on llama.cpp (Kokoro, VoxCPM2, Fish Audio Drama 3) or vLLM-Omni (Qwen3-TTS); Capabilities::speak, catalog/1 Purpose::Speak, and ModelStatus::speech: the engine’s report merged over the GGUF headers or the weirdnet-model 0.5.5 catalog entry (SpeechProfile::or), narrowed by ModelLaunch::with_speech and kept in LimitsRecord::speech. ModelHost serves infer/2 Speak through Supervisor::speak and /v1/audio/speech: presets, voice design, instructions, cloning from inline clips, scripts, raw input, speed, language, format and streaming.
  • Measured limits (0.4.9): when a model loads, the supervisor reads what its GGUF and projector headers say images and audio cost (weirdnet-model 0.5.4 limits::measure; llama.cpp --image-max-tokens caps a size-dependent projector’s cost) and asks the engine for its context per sequence (llama-server /props, vLLM /v1/models). The operator’s limits win field by field and unknown figures stay absent. Supervisor::measured_limits, Supervisor::set_limits_store (records kept next to the model files and read back after a restart) and ModelStatus::context_tokens, which apply_to prefers over the configured context.
  • Transcription (0.4.9): ModelLaunch::with_transcribe gives a model the transcription role; Capabilities::transcribe (llama.cpp with an audio projector, such as Voxtral, or vLLM, such as Whisper) and ModelLaunch::purpose, ModelStatus::purpose and ModelStatus::catalog_model publish it as catalog/1 Purpose::Transcribe. ModelHost serves infer/2 Transcribe (InferHost::open_transcribe) through Supervisor::transcribe: a chat request with a base64 input_audio part on llama.cpp, /v1/audio/transcriptions (with timed segments when asked) on vLLM. Needs weirdnet-agent 0.5.8.
  • Media limits (0.4.8): Capabilities::limits, a weirdnet-agent 0.5.7 MediaLimits, set by the operator with ModelLaunch::with_limits and carried in every ModelStatus and capability record; intersect keeps the stricter limits, and Capabilities::apply_to and ModelStatus::apply_to fill a catalog entry’s inputs, limits and context window.
  • EngineConfig, ModelLaunch: how llama-server, vllm serve, vLLM-Omni and MLX-LM’s mlx_lm.server are launched: loopback only, a random port, a per-process API key in the environment (never the command line), context, slots and GPU layers. Wrap attaches to a stock OpenAI-compatible server on loopback without owning it.
  • mlx (0.1.3): EngineKind::Mlx runs mlx_lm.server on macOS on Apple silicon behind a proxy that checks the node’s API key, rewrites model to default_model, refuses image, audio and embedding requests, and reports ready only after a one-token completion; mlx::install puts a pinned mlx-lm (0.32.2) into a venv with uv or python3.
  • Capabilities (0.1.3): what each model takes (chat, embeddings, images, audio), from ModelLaunch::capabilities and in every ModelStatus and capability record, so routing keeps image, audio and embedding requests off models that can’t serve them.
  • Images and audio (0.2.0): weirdnet-agent 0.5 content parts (image_url with a data: URL, input_audio) reach llama.cpp unchanged, in the OpenAI shape. llama.cpp models with a multimodal projector (--mmproj) take images and audio; vLLM and MLX-LM models are text only. ModelHost refuses parts a model’s Capabilities lack (Unsupported, so a pool tries another node) and remote image URLs (BadRequest); Capabilities::inputs gives the Modalities for the inference node’s catalog entry.
  • Supervisor: load with a readiness probe, drain and unload; swap groups (loading one model of a group unloads the others); idle unload (reap_idle, spawn_reaper); crash restarts with exponential backoff and crash-loop detection (an explicit forced load clears it); SupervisorEvents and per-model logs; chat, completion and embedding forwarding. add_model and remove_model (0.3.0) serve a new model, or stop serving one, without a restart (SupervisorEvent::Added, Removed); launches lists the models.
  • models (feature node, 0.3.0): /weirdnet-backends/models/1 for the node’s owner only (ModelsService takes an Authorize such as RosterAuth): Hugging Face Hub search, a repo’s models measured against the node’s memory budget, pull with progress (split GGUFs too, the largest that fits by default) and serving it without a restart, list and remove. ModelsServer and ModelsClient. The node’s Hugging Face token stays on the node.
  • LoraAdapter (0.4.0): LoRA adapters served on a base model (ModelLaunch::with_adapters, served_ids, check_adapters, which reads llama.cpp adapters’ GGUF headers with weirdnet-model). A request names the base or an adapter id; openai::Target (Base or Adapter) picks the engine body. llama.cpp gets one --lora per adapter with --lora-init-without-apply and a lora list per request; vLLM gets --enable-lora, --lora-modules and --max-loras. Supervisor::add_adapter and remove_adapter return an AdapterChange (Live or NextLoad), and ModelStatus::base gives each adapter its own row.
  • Live adapters and scale (0.4.1): add_adapter_live and remove_adapter_live load and unload adapters on a running vLLM engine (ModelLaunch::lora_slots); set_adapter_scale changes an adapter’s strength on llama.cpp without a restart, and Request::adapter_scale (weirdnet-agent 0.5.2) sets it for one request, up to MAX_ADAPTER_SCALE. models/1 adds ServeAdapter, UnserveAdapter and AdapterScale.
  • Reservations (0.4.3): Supervisor::reserve stops the node’s engines and holds its accelerators for one holder (Reservation, reservation_changes), refusing every load until release; node/1 adds Command::Reserve and Release (NodeClient::reserve, release), and capability records and health carry reserved.
  • Uploads (0.4.4): ModelsCommand::Upload sends local files to a node in 48 KiB chunks (Upload, UploadFrame, CHUNK, ModelsClient::upload). The node checks names, size, free space, engine and base before the first byte, each header as it arrives and every SHA-256 at the end, then places the files with weirdnet-model 0.5.3 ModelStore::import and can serve them: GGUF, safetensors and MLX models, adapters (live on their base) and vision projectors. A closed upload resumes from its staged parts; AbandonUpload drops them.
  • Copies between nodes (0.4.4): ModelsCommand::Fetch, Pull::from_peer (PullSource::Peer, ModelsService::with_peer_dialer) and ModelsClient::replicate, which has several nodes pull an upload from the node it landed on, all at once.
  • WritePolicy (0.4.4): a separate write Authorize, an uploads switch (with_uploads, 0.4.7), max_upload, quota and KeepFree (10 percent or 20 GiB by default, the larger) for uploads, removes and peer copies. ModelsCommand::Disk returns a DiskReport; List shows provenance, safetensors and MLX models and projectors; refusals carry stable reasons (refusal, refusal_reason).
  • Placement hooks (0.4.5): ModelsService::on_placed (OnPlaced) runs after each upload, peer copy or Hub pull is placed, with a Placed (the StoredEntry, the Pulled answer, PlacedVia and serve_error); with_node_info keeps the capability record current from it. ModelEntry::origin and license in capability records, set with NodeService::set_model_origin or from provenance (Placed::origin_and_license).
  • Projectors (0.4.4): ModelLaunch::with_mmproj starts llama.cpp with --mmproj and reports image input; Supervisor::set_projector_live sets or clears it, applied at the next load.
  • ChunkDecoder, ToolCalls: OpenAI server-sent events decoded into Chunks: text, reasoning (reasoning_content or reasoning), tool-call fragments joined into calls, finish reason and usage with cached and reasoning tokens.
  • openai: engine request bodies from infer/2 requests: messages, sampling, seed, response format, tools, and assistant-prefix continuation (vLLM’s continue_final_message).
  • ModelHost: an InferHost serving raw infer/2, embeddings, transcription (0.4.9) and speech (0.4.10) from the supervisor’s models. Cancel aborts the engine request; prefixes resume; a model that is not loaded is refused unless the request waits for it; draining refuses new requests; prefill and decode speed and time to first token are measured.
  • node feature: NodeService, NodeServer (node/1 and raw inference on a weirdnet-net node, announced as weirdnet-backends-node), NodeServerOptions, RAW_INFER_PROTOCOL and RawInferDialer (0.1.1), NodeClient, Subscription, Verifier, and GroupWorkers for the application’s cross-machine group workers.

Feature flags

  • node: /weirdnet-backends/node/1 over weirdnet-net 0.8 and weirdnet-sync 0.5 to 0.8 (0.8 since 0.4.6), with weirdnet-model hardware in the records (0.5.3 since 0.4.4; 0.5.2 in 0.4.0 to 0.4.3; 0.5.1 in 0.3.0; 0.4 before), /weirdnet-backends/models/1 (0.3.0), and weirdnet-agent’s pool and serve features.

Usage

[dependencies]
weirdnet-backends = "0.4.15"
# Cargo.toml
weirdnet-backends = { version = "0.4", features = ["node"] }

// main.rs
use std::sync::Arc;
use weirdnet_backends::{EngineConfig, EngineKind, LoraAdapter, ModelHost, ModelLaunch, Supervisor, SupervisorOptions};
use weirdnet_backends::node::{NodeServer, NodeService};

let chat = ModelLaunch::new("qwen3-8b", EngineKind::Llamacpp, "/models/qwen3-8b-q4_k_m.gguf");
let sup = Supervisor::new(vec![EngineConfig::llamacpp("llama-server")], vec![chat], SupervisorOptions::default());
let _reaper = sup.spawn_reaper(std::time::Duration::from_secs(30));
// A LoRA adapter on the base (0.4.0): requests for "qwen3-8b-support" use it.
sup.add_adapter("qwen3-8b", LoraAdapter::new("qwen3-8b-support", "/models/support-lora.gguf"))?;
let host = Arc::new(ModelHost::new(sup, auth.clone())); // auth: weirdnet_agent::serve::RosterAuth
let service = Arc::new(NodeService::new(host, node_keypair, Some(node_cert), auth).with_hardware(hw, budget));
let _server = NodeServer::start(&node, service)?; // node/1 + raw inference on /weirdnet-backends/infer/1 and infer/2

// On the inference node: dial model nodes on the new id, falling back to infer/2 for 0.1.0 nodes.
let dialer = Arc::new(weirdnet_backends::RawInferDialer::new(net_dialer));

Where it fits

Version 0.4.15 is on crates.io (docs.rs, release). 0.4.12 to 0.4.15 need weirdnet-agent 0.5.11 and weirdnet-model 0.5.5, as 0.4.10 does. 0.4.15 is additive: ModelLaunch::with_env, with_envs, env (LaunchEnv) and check_env, and a transcription retry with plain json when a vLLM server refuses verbose_json; the new field is skipped when empty, so serialized launches are unchanged. 0.4.14 is additive: NodeService::group_lost takes a group whose processes stopped by themselves out of the record at once. 0.4.13 is additive: ModelStatus::keep_warm_secs and unload_in_secs, left out of records when unset; older readers ignore them. 0.4.12 fixes vLLM video models, which now take images too (before, a video model such as Qwen3-VL was published without image input or an image cost), and adds the Qwen-VL image cost from preprocessor_config.json. 0.4.11 is additive: placement-lease fencing (Command::LoadFenced and UnloadFenced, NodeClient::load_fenced and unload_fenced, the fence module, NodeService::with_fence_file and with_fence_required, Capability::fencing); unfenced Load/Unload are unchanged on the wire, and nodes before 0.4.11 fail fenced commands instead of running them unfenced. 0.4.10 is additive and needs weirdnet-agent 0.5.11 and weirdnet-model 0.5.5: native video on vLLM (ModelLaunch::video, Capabilities::video), the vLLM-Omni engine, the speech role with Purpose::Speak and speech profiles, and infer/2 speech through ModelHost; records from older nodes read as before, but nodes before 0.4.10 don’t know the vllm-omni engine name. 0.4.9 is additive and needs weirdnet-agent 0.5.8 and weirdnet-model 0.5.4: limits measured at load, the transcription role with Purpose::Transcribe, and infer/2 transcription through ModelHost; records from older nodes read as before (no transcription, no measured context). 0.4.8 is additive and needs weirdnet-agent 0.5.7: per-model media and request limits in Capabilities, ModelLaunch and ModelStatus; records without them read as before. 0.4.7 is additive: WritePolicy::uploads and with_uploads(false) refuse uploads alone with not-allowed while pulls, peer copies and removals keep working (uploads stay on by default), and StoredEntry::from_model, from_adapter, from_projector (and From), with_served, with_base and StoredEntry::list(&ModelStore) build and list entries without serde or a running service. 0.4.6 changes no API: the node feature accepts weirdnet-sync 0.8 (>=0.5, <0.9) and needs weirdnet-agent 0.5.5, which accepts it too. 0.4.5 is additive: placement hooks (ModelsService::on_placed, OnPlaced, Placed, PlacedVia, ModelsService::with_node_info) and a model’s origin and license in capability records (ModelEntry::origin and license, NodeService::set_model_origin, Placed::origin_and_license), left out of the record when unset. 0.4.4 is additive and needs weirdnet-model 0.5.3: models/1 uploads (ModelsCommand::Upload, Upload, UploadFrame, 48 KiB CHUNKs, UploadReady, Uploaded, ModelsClient::upload, resumable from staged parts, AbandonUpload), copies between nodes (ModelsCommand::Fetch, PullSource::Peer, Pull::from_peer, ModelsService::with_peer_dialer, ModelsClient::replicate), WritePolicy (write Authorize, max_upload, quota, KeepFree), ModelsCommand::Disk and DiskReport, stable refusal reasons (refusal, refusal_reason), StoredEntry::projector and provenance(), and projectors (ModelLaunch::with_mmproj, Supervisor::set_projector_live). Remove now follows the WritePolicy, a served model reloads when its projector changes, and nodes before 0.4.4 refuse the new commands. 0.4.3 is additive: node reservations (Supervisor::reserve, release, Reservation, reservation_changes; node/1 Command::Reserve and Release, NodeClient::reserve and release; Capability::reserved, Health::reserved). 0.4.2 fixes a port race: an engine is ready only when /v1/models answers with the launch’s key and model id, and a launch that lost its port to another process tries a new port up to 3 times without counting as a crash. 0.4.1 is additive: live adapter changes on vLLM (add_adapter_live, remove_adapter_live, ModelLaunch::lora_slots), adapter scale on llama.cpp (set_adapter_scale, Request::adapter_scale with weirdnet-agent 0.5.2, complete_scaled, MAX_ADAPTER_SCALE) and models/1 ServeAdapter, UnserveAdapter and AdapterScale. 0.4.0 adds LoRA adapters (LoraAdapter, ModelLaunch::with_adapters, openai::Target, Supervisor::add_adapter and remove_adapter, AdapterChange, ModelStatus::base, Pull::adapter_for, RepoFits::adapters); it is breaking: ModelLaunch is #[non_exhaustive] (build it with ModelLaunch::new and the with_ methods), StoredEntry::model is an Option beside new adapter and base fields, StoredEntry and RepoFits are no longer Eq, and weirdnet-model 0.5.2 is always a dependency. 0.3.0 adds /weirdnet-backends/models/1 and Supervisor::add_model; it is breaking for node users because the feature now needs weirdnet-model 0.5.1 and no longer takes 0.4 (hw::Hardware and hw::Budget in capability records are its types), so move to weirdnet-model 0.5.1 with it. The node/1 and raw inference protocols are unchanged. 0.2.0 needs weirdnet-agent 0.5 (content parts), which is breaking because its public API uses the agent types: move to agent 0.5 with it. Image and audio parts reach llama.cpp unchanged, and ModelHost refuses them for models without those capabilities; Capabilities::inputs and Capabilities::lacking are new. 0.1.3 is additive: an MLX-LM engine for Apple silicon (EngineKind::Mlx, EngineConfig::mlx, the mlx module), text only and without embeddings, and per-model Capabilities (chat, embeddings, vision, audio) in capability records; Supervisor::embed refuses MLX models. 0.1.2 is additive: capability records carry the node’s private links (Capability::links, NodeService::set_links, link::local_links; never public or CGNAT addresses), Verifier::with_roster refuses records from revoked or unknown nodes, and it needs weirdnet-agent 0.4.4 and accepts weirdnet-sync 0.5 to 0.7. 0.1.1 serves raw inference on its own protocol id, /weirdnet-backends/infer/1 (RAW_INFER_PROTOCOL, the infer/2 framing), so one node can be an inference node and a model node; infer/2 is still served by default for 0.1.0 inference nodes (NodeServerOptions::with_legacy_infer2(false) turns it off), and RawInferDialer tries the new id and falls back to infer/2. It also serves raw prompts and reports embedding tokens (agent 0.4.1) and depends on weirdnet-agent "0.4.1" and weirdnet-model "0.4". Extracted from Ymir’s ymir-backends. The supervisor runs on Unix and Windows; graceful stop, process groups and dying with the parent are Unix-only (see the platform table below), vLLM is Linux-only and MLX-LM runs on macOS on Apple silicon only. Ray and rpc-server group workers are not included: GroupUp goes to the application’s GroupWorkers. The API may change while Ymir moves onto it.