Documentation
¶
Overview ¶
Package servingcfg reads the llama-swap config a box serves (config key serving_config_path) for one fact: the cards each model is pinned to.
It is a leaf (standard library and YAML only) because two packages that cannot import each other both need the answer. internal/config arms the load fence from it (Config.ModelPins, which modelaffinity is armed with by Load) and internal/gpualloc places the models of a lease's unload list by it (LeaseScope.Locate), and gpualloc imports config. With one parser the fence and the unload list cannot place a model differently (registers F15 and C-86a).
The file is read again when it changes. The fence runs in processes that live for days (the MCP server, the fleet node) and a llama-swap config is edited and reloaded under them, so Load memoises on the file's modification time and size and Stats the file on every call; PinsOf, which the fence asks on every poll of a blocked load, costs one Stat while the file is unchanged.
The serving config (config key serving_config_path) is the llama-swap yaml the box actually runs. Nearly every llama.cpp model in it pins its cards with an env entry, `CUDA_VISIBLE_DEVICES=<uuid>[,<uuid>]` (GPU UUIDs, sometimes indices), and that pin is where the seat really runs, so it places a model when `layers` does not declare it.
ONLY THE ENV PIN COUNTS. A model whose entry names no device in env (an unpinned dual-card `-sm layer` / `--tensor-split` entry), a `proxy:` seat (a vLLM engine, whose cards are pinned in its own unit and not here), a pin that is not a literal device list (a macro), an alias two entries claim, and a bare index when the entry does not also set CUDA_DEVICE_ORDER=PCI_BUS_ID (without it a CUDA index is not an nvidia-smi index, and reading it as one could place a seat on the wrong card) are all UNKNOWN, with the reason. Device flags in cmd are never read. Unknown is the answer every caller reads as "on every card".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IDs ¶
IDs lists the model ids the serving config at path declares (aliases are not ids), for the candidate list of a lease whose llama-swap roster could not be read. Empty when it cannot be read.
func Pins ¶
Pins reads the llama-swap config at path and returns the pin of every model id and alias (lower-cased). It reads the file every time; Load is the memoised form. An error means no model is placed by it.
func PinsOf ¶
PinsOf is the placement the load fence uses: the pins the serving config at path gives model, as the caller's own copy. ok is false when the config places it nowhere (path unset or unreadable, the model not listed, a proxy: seat, an entry that pins nothing it can read), which every caller reads as "on every card".
func SetNoteLogger ¶
SetNoteLogger replaces where the unreadable-serving-config note goes and returns a function that puts the previous one back; nil restores the process log. A test installs its own so that the note is heard and the process-wide once-per-cause memory starts empty.
Types ¶
type Pin ¶
Pin is one model's placement as the serving config states it: its pin elements, or why it has none the harness can use.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is one reading of the serving config: the pin of every model id and alias (lower-cased) and the model ids it declares. The zero value places nothing.
func Load ¶
Load returns the serving config at path as it is now. The file is Stat-ed on every call and parsed again only when its modification time or size changed (or it was last changed within racyWindow of the reading), so a long-lived process sees a llama-swap config reload on its next call without a restart, and an unchanged file costs one Stat. A file that is not set, cannot be Stat-ed or cannot be read is an error and no snapshot: a memo is never served for a file that is gone.