mediaseat

package
v0.207.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mediaseat is the tier schema's declaration of the ALIAS-backed media capabilities a hardware tier serves: a vision (VLM) seat, a speech-to-text seat, and an OCR-specialist seat — each rendered into the node's llama-swap config AND into the harness config binding that routes to it.

One declaration, two artifacts, on purpose. Before this existed the two were authored separately and drifted immediately: config.Default() bound stt_model="whisper-stt" while not one of the six serving templates defined a whisper seat, so every freshly installed node advertised `stt` to the fleet dispatcher and failed its own acceptance gate at the same time. A binding is now DERIVED from a seat — a tier that serves STT declares the seat and gets the binding; a tier that does not declares neither and the route honestly defers. The state "bound to a seat that does not exist" is no longer representable from the tier table.

FILE-backed media (image/video/music generation) is deliberately NOT here. Those routes are spawn-per-job subprocesses arbitrated by internal/gpulease, not llama-swap seats — there is no sd-server client anywhere in this repo, and hosting one inside llama-swap would put two residency authorities over one card. internal/mediacap derives those; this package derives their counterpart.

Index

Constants

View Source
const (
	KindVision = "vision"
	KindSTT    = "stt"
	// KindOCR is a llama-server VLM seat specialized for document OCR, bound to
	// `ocr_model` so it can coexist with the tier's general vision seat. Added for
	// PaddleOCR-VL-class models (measured blackwell-8 2026-08-23: crops-driven,
	// ~2 s answers at 1.8 GB), which need a shipped chat template file and temp 0 —
	// the two knobs this kind carries that plain vision does not.
	KindOCR = "ocr"
	// KindRKLLM is an LLM/VLM seat served by the Rockchip RKLLM runtime on the NPU
	// (accelerators/rknpu/rkllm_server.py behind a launcher script) rather than by
	// llama-server. The rockchip-rk3588 tier declares one beside the llama.cpp Vulkan GPU
	// entry its own template serves: two accelerators, one shared RAM budget. It is a
	// CHAT seat first; with a vision_encoder it also answers image questions and binds
	// vision_model. See Seat.VisionEncoder / Seat.CPUMask.
	KindRKLLM = "rkllm"
	// KindForecast is the Timestral time-series forecaster: a Python server the harness
	// binary itself launches (`<bin> forecast-serve ...`) behind llama-swap, bound to
	// `forecast_model`. It runs on the GPU, so it is a media seat and not an accelerator
	// (ADR 0024). It is not a chat model and answers only POST /v1/forecast.
	KindForecast = "forecast"
)

The kinds a seat may declare. A closed set: each one has a distinct binary, a distinct flag grammar and a distinct config binding, so an unrecognized kind is refused rather than rendered into something that looks plausible.

View Source
const (
	TaskVQA         = "vqa"
	TaskOCR         = "ocr"
	TaskAssessImage = "assess_image"
	TaskClassify    = "classify"
	TaskExtract     = "extract"
)

The task names a seat may declare in Seat.Tasks. The first three are the fleet vision lane's single-image tasks; classify and extract are the text tasks the fleet text lane serves. Bindings writes the vision subset as vision_tasks and the text subset as text_tasks. summarize and triage are not declarable: the RKLLM runtime returns no logprobs, so the decision-margin gate cannot run, and blind quality on the reference seat was 0/4 for each.

View Source
const (
	// DefaultRKLLMBin is the launcher the rknpu accelerator ships beside its sidecar. It rides
	// __RKNPU_HOME__, the token the sidecar's own command uses, so one RKNPU_HOME moves both.
	DefaultRKLLMBin = "__RKNPU_HOME__/rkllm-serve.sh"
	// DefaultRKLLMCPUMask is the RK3588's A55 cluster (cpu0-3): the runtime's host
	// threads stay off the A76 cores until the operator chooses otherwise, which is
	// what keeps the box's other workload responsive.
	DefaultRKLLMCPUMask = "0x0f"
)

What an rkllm seat runs when the tier names no launcher or CPU mask.

View Source
const (
	// Swappable: a seat big enough that only one of its residency class should be
	// on the card at a time.
	Swappable = "swappable"
	// Resident: a small seat that stays co-loaded alongside whatever else is up.
	Resident = "resident"
)

Residency is a ROLE, not a group name. Group names are a per-TEMPLATE namespace — heavy/support in linux-cuda, offload-family in the win-cuda, win-vulkan and win-cpu templates, architect/editor in win-dual-cuda, and none at all in win-cuda-resident — while a tier is a HARDWARE class that renders into several of them. A tier naming "heavy" would therefore be simultaneously valid and invalid for itself. The tier declares what a seat NEEDS; each template maps that need onto one of its own groups.

Variables

This section is empty.

Functions

func Bindings

func Bindings(seats []Seat) map[string]any

Bindings is the config fragment a tier's seats produce. This is the ONLY writer of these keys — a seed that also sets them by hand is refused, because two writers is exactly how the seat and its binding drifted apart before.

vision_tasks rides with vision_model: the seat that binds the vision route also says which of the three vision tasks it serves, and only when it declares a vision subset (a seat that declares none leaves the key absent, so the node serves all three).

Every rkllm seat, bound to a route or not, also writes unconstrained_seats (its model ids): the runtime cannot constrain decoding, so the node's own pipeline must not send it a grammar. text_tasks is the seat's declared text subset (classify, extract); absent = no fleet text lane.

func BoundKeys

func BoundKeys() []string

BoundKeys is every config key seats may write, for the seed validator.

func Validate

func Validate(seats []Seat, tier string) error

Validate rejects a seat set at AUTHORING time — in a test over the committed tier table — rather than on someone's machine, where the symptom is a service that will not start or a route that quietly defers.

Types

type Seat

type Seat struct {
	Kind    string   `json:"kind"`
	Name    string   `json:"name"` // the llama-swap model id AND the config binding value
	Aliases []string `json:"aliases,omitempty"`
	// Model is relative to the node's models dir, matching how every existing
	// seat in the serving templates names its weights.
	Model string `json:"model"`
	// MMProj is the multimodal projector (vision only). A "vision" seat without
	// one is just a chat model that silently answers image questions blind.
	MMProj string `json:"mmproj,omitempty"`
	// VADModel enables voice-activity detection (stt only); empty = no VAD flags.
	VADModel string `json:"vad_model,omitempty"`
	// Bin is the seat's executable when it is NOT llama-server (stt only —
	// whisper.cpp ships its own server). May carry the __OFFLOAD_HOME__ and
	// __EXE__ tokens so one row renders on every OS.
	Bin string `json:"bin,omitempty"`
	// LibDir is the directory holding the seat binary's shared objects. A
	// self-built whisper-server links its own, and without it the process dies at
	// exec with a loader error that reads nothing like a config problem. POSIX
	// only; ignored on Windows.
	LibDir string `json:"lib_dir,omitempty"`
	// CtxSize is the seat's own served window. Vision runs a much smaller window
	// than the chat tier on the same card, so it is per-seat, not inherited.
	CtxSize int `json:"ctx_size,omitempty"`
	// ImageMaxTokens caps the tokens one image may expand into (vision only). This is
	// a VRAM bound, not a quality knob: on the measured 8 GB tier it is what keeps a
	// large screenshot from pushing the seat past the card. 0 = leave it to the server.
	ImageMaxTokens int `json:"image_max_tokens,omitempty"`
	// NoContextShift disables llama-server's context shifting for this seat (vision
	// only). Shifting a window that holds image embeddings is not meaningful.
	NoContextShift bool `json:"no_context_shift,omitempty"`
	// NoFlashAttn passes whisper.cpp's -nfa (stt only). Flash attention is default-ON
	// in whisper.cpp since v1.8.0 and DEGRADES non-English and noisy audio
	// (whisper.cpp #3020), so a tier serving Spanish or field recordings wants it off.
	NoFlashAttn bool `json:"no_flash_attn,omitempty"`
	// NoMmprojOffload keeps the multimodal projector (CLIP) on CPU while the LLM runs
	// on the GPU (vision only). llama.cpp #20081: mmproj on the Vulkan backend is
	// "extremely degraded" for some images, so a Vulkan vision tier decodes the LLM on
	// the GPU but keeps the vision encoder on CPU where it is correct. A no-op on CUDA.
	NoMmprojOffload bool `json:"no_mmproj_offload,omitempty"`
	// GPUEnv is env vars added to THIS seat's env list — a per-seat device pin. The
	// tier-level gpu_env applies to EVERY model uniformly; this is for a seat that must
	// sit on a SPECIFIC device the tier's other models do not (the dual-gpu media seats
	// pin to the editor card; a Vulkan seat pins its ICD).
	GPUEnv    []string `json:"gpu_env,omitempty"`
	Residency string   `json:"residency"`
	TTL       int      `json:"ttl,omitempty"`
	// Extra marks a REGISTERED EXTRA: a seat the tier renders into llama-swap and serves by
	// its name and aliases, but that is NOT the route's binding. BindingKey() answers ""
	// for it, so Bindings writes no config key for it and the one-writer check does not
	// count it: a tier can serve a second vision-class model (a small screenshot reader, a
	// general VLM beside the OCR specialist) while the first vision seat keeps
	// vision_model. Nothing routes to an extra by default; a caller reaches it by naming
	// the seat or one of its aliases. Allowed on vision, ocr and stt seats (an rkllm seat
	// writes unconstrained_seats and text_tasks that this flag would not suppress), and
	// it takes no Tasks (they are read only through the vision binding the extra lacks).
	Extra bool `json:"extra,omitempty"`
	// ChatTemplate names a template file in the models dir, rendered as
	// --chat-template-file (vision/ocr only). PaddleOCR-VL ships its own
	// chat_template.jinja and produces degraded transcription without it —
	// exactly the silent-quality-loss shape that must be declared, not hand-wired.
	ChatTemplate string `json:"chat_template,omitempty"`
	// Temp pins the seat's server-side sampling temperature (vision/ocr only).
	// A POINTER so an explicit 0 — PaddleOCR-VL's vendor-required value — survives
	// JSON omitempty; nil = no --temp flag, the server's default stands.
	Temp *float64 `json:"temp,omitempty"`
	// TopP and TopK complete a vendor sampler recipe (vision/ocr only). Pointers for
	// the same reason as Temp. Qwen3-VL ships an official 0.7 / 0.8 / 20 recipe, and
	// a VLM run off its own sampler is a quality change nobody measured.
	TopP *float64 `json:"top_p,omitempty"`
	TopK *int     `json:"top_k,omitempty"`

	// SplitMode is llama.cpp's -sm for a seat too large for one card: "layer" or
	// "tensor". Empty = no flag, which is right for every single-card seat.
	//
	// The two are NOT interchangeable. Measured on the reference 5060 Ti pair
	// (2026-09-05 CUDA-X): moving Qwen3-VL-32B from -sm layer to -sm tensor at the
	// same --tensor-split produced BYTE-IDENTICAL output on a fixed image+prompt 5/5
	// while raising generation 19.6 -> 34.1 t/s; prefill went 995 -> 926. Identical
	// output is what makes it a free win rather than a quality trade.
	SplitMode string `json:"split_mode,omitempty"`
	// TensorSplit is llama.cpp's --tensor-split proportion list ("25,25"), in the
	// order of the seat's own visible devices. It is meaningless without SplitMode,
	// and the proportions are a per-BOX measurement: they encode which card is
	// already carrying residents or a desktop, so copying a ratio between tiers with
	// different layouts is how a seat ends up lopsided.
	TensorSplit string `json:"tensor_split,omitempty"`
	// ImageMinTokens is llama-server's --image-min-tokens (vision/ocr only): the
	// FLOOR an image expands to, where ImageMaxTokens is the ceiling. A large VLM
	// given too few visual tokens answers confidently off a thumbnail; the reference
	// vision seat pins 1024.
	ImageMinTokens int `json:"image_min_tokens,omitempty"`

	// VisionEncoder is the separate vision model an rkllm seat pairs with its LLM (a
	// .rknn under the models dir), rendered as --vision-encoder. With one the seat is a
	// VLM and binds vision_model; without, it is text-only. rkllm only.
	VisionEncoder string `json:"vision_encoder,omitempty"`
	// CPUMask is the hex mask of CPUs the RKLLM runtime may use ("0x0f" = cpu0-3, the
	// RK3588's A55 cluster; the default). The mask is per seat because it is a
	// measured trade on a big.LITTLE part: on the reference board (Qwen3.5-0.8B W8A8, a
	// 1,256-token prompt, mainline kernel) 0x0f prefills at 44.5 tok/s and decodes at
	// 9.07, 0xf0 (the A76 cluster) at 174.5 / 16.67 — while the box's other workload
	// keeps whichever cores are left. At least 3 bits must be set (rkllmMinCPUs). rkllm
	// only.
	CPUMask string `json:"cpu_mask,omitempty"`
	// RepeatPenalty is the repeat penalty an rkllm seat applies to a request that names none
	// (rendered as --repeat-penalty; rkllm only). A POINTER so the tier can tell "not set" (the
	// server's 1.0 = off stands, and no flag renders) from a value. It is a seat default, not a
	// lock: a request that sends its own repeat_penalty wins. Measured on the reference RK3588
	// board (2026-09-30): greedy decoding at 1.0 loops on VQA until the 256-token
	// cap (the vision lane defers "vision output truncated"), while 1.1 answered 3 of 4 blind VQA
	// questions. Range 0.01..10, the range the server accepts per request.
	RepeatPenalty *float64 `json:"repeat_penalty,omitempty"`

	// Tasks is the task set this seat declares it serves: any of vqa, ocr, assess_image (the
	// fleet vision lane's tasks) and classify, extract (text tasks, accepted now for the door
	// that will read them). Empty = unrestricted, which is today's behaviour. The declaration is
	// honest about what the RUNTIME can do: the RKLLM runtime cannot constrain sampling, so a
	// grammar-carrying task (assess_image always sends one) would be refused with a 400 after
	// the node had already taken the job. Bindings writes the vision subset as the node's
	// vision_tasks, which the node enforces at ack time and publishes in health, and which the
	// delegator's placement reads to keep such a task off the seat. Valid on vision and rkllm
	// seats only; a vision task needs a seat that reads images.
	Tasks []string `json:"tasks,omitempty"`

	// Measured records what measured this seat -- the box, the build, the bake-off and
	// the numbers -- so a reader never has to take the roster on faith and a future
	// edit can see what it would be overturning. It is data, not configuration: it
	// renders nothing. Tiers carried the key before the field existed, so the records
	// were parsed and silently dropped.
	Measured string `json:"measured,omitempty"`
}

Seat is one alias-backed media capability a tier serves.

func (Seat) BindingKey

func (s Seat) BindingKey() string

BindingKey is the harness config field this seat writes, "" when it writes none. A vision, stt or ocr seat binds the field of its kind. An rkllm seat is a chat model first — model and triage_model stay the tier's config_seed to name, as for any tier — and binds vision_model only when it carries a vision encoder, because only then can it answer an image question; binding it without one would advertise a route the seat cannot serve. A registered extra (Seat.Extra) binds nothing whatever its kind: it is rendered and reachable by name, never the route's default.

func (Seat) EffectiveBin

func (s Seat) EffectiveBin() string

EffectiveBin is the executable the seat runs: its own bin, or for an rkllm seat that names none the launcher the rknpu accelerator ships. The renderer and the "does this seat need the install home" check both read it, so a default that carries __RKNPU_HOME__ can never render without a home to expand it against.

func (Seat) EffectiveCPUMask

func (s Seat) EffectiveCPUMask() string

EffectiveCPUMask is the mask an rkllm seat is started with: its own, or the A55 cluster default. "" for every other kind, which has no CPU mask.

func (Seat) TextTasks

func (s Seat) TextTasks() []string

TextTasks is the text subset of the seat's declared Tasks, in canonical order (classify, extract) and de-duplicated. nil when the seat declares no text task, which the node reads as "no text lane": unlike the vision lane the text lane is dark unless declared.

func (Seat) UnconstrainedNames

func (s Seat) UnconstrainedNames() []string

UnconstrainedNames is every model id an rkllm seat answers to (its name and its aliases): the ids the node's unconstrained_seats lists, because a cascade model configured by alias reaches the same runtime, which refuses a grammar whichever name it was asked by. nil for any other kind.

func (Seat) VisionTasks

func (s Seat) VisionTasks() []string

VisionTasks is the vision subset of the seat's declared Tasks, in canonical order (vqa, ocr, assess_image) and de-duplicated. nil when the seat declares no vision task, which the node reads as "serves all three" — today's behaviour.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL