servingcfg

package
v0.209.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 12 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 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

func IDs(path string) []string

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

func Pins(path string) (map[string]Pin, error)

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

func PinsOf(path, model string) ([]string, bool)

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

func SetNoteLogger(fn func(format string, args ...any)) (restore func())

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

type Pin struct {
	Pins []string
	Why  string
}

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

func Load(path string) (Snapshot, error)

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.

func Read

func Read(path string) (Snapshot, error)

Read parses the llama-swap config at path, every time (no memo).

func (Snapshot) IDs

func (s Snapshot) IDs() []string

IDs lists the model ids the config declares (sorted; aliases are not ids).

func (Snapshot) Pin

func (s Snapshot) Pin(name string) (Pin, bool)

Pin is the placement of the model id or alias name (case-insensitive). ok is false for a name the config does not list. The returned Pins are the caller's own copy.

Jump to

Keyboard shortcuts

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