Documentation
¶
Overview ¶
Package displaywatch is the display layer's guard AFTER admission (ADR 0075).
The layer's guards (presence, display_floor) decide once, at the moment of a placement. A twin that passed them then sits on the desktop's card until llama-swap's idle ttl (300 s) takes it down, however soon the operator is back at the desk or a game takes the card's memory, and a twin that ANOTHER llama-swap client loaded (the twins are ordinary llama-swap models once rendered) was never asked at all. This package closes that gap from the side that can see it: while a seat of the display layer is loaded, it re-asks the layer's own desktop guards (placement.ResidentVerdict) on a short period, and when either refuses it unloads the layer's seats through llama-swap's per-model route.
What it will and will not do, because a periodic unloader is a new posture for this harness (a read never unloads: internal/modelaffinity/seatyield.go):
- It unloads only models the display layer names (its router's model_map twins, and a seat's own model if one is declared). The pair seat, the memory stack and every other layer's seats are never its to touch, whatever the readings say.
- It unloads through the vendored llama-swap client's per-model route and never the total one: a route that is absent is an error, not a licence to unload everything.
- It does not drain. The reason it unloads is that the desktop needs the memory now, so a request in flight on the twin dies with llama-swap's 502. A mechanical cascade call answers that as a structured defer and the caller does the task itself; ADR 0066's wait and re-issue is the agent loop's recovery and the display layer declares no agent seat.
- It fails loud and recovers nothing: an unload that fails is logged, recorded and retried at the next check, with nothing else unloaded to make room.
- Every unreadable input is a refusal, as at admission.
It runs in fleet-serve, the one always-on process of a node, in the console session: the presence probe in `auto` mode reads the console session's idle time, which a process in another session cannot see. Its last action and a heartbeat go to a small state file under the machine-wide state root, because offload_status answers from another process (StatusView reads it).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatePath ¶
StatePath is where the watcher leaves its state: under the machine-wide state root, beside the GPU lease, never inside a cloud-synced folder.
func StatusView ¶
StatusView is the display_guard field of offload_status for this box: whether the watcher is alive, and the last thing it did. nil (omitted) when there is nothing to say: no display layer with a desktop guard, or one that is dormant and has never acted.
"Alive" is a heartbeat the watcher's process wrote recently. offload_status runs in another process from fleet-serve, so a box whose fleet-serve is not running (or was started before the layer was seeded) shows watching=false: an awake display layer with nothing re-checking it is the state this field exists to make visible.
Types ¶
type Action ¶
type Action = displaystate.Action
Action and State are the state file's shape (internal/displaystate), which the admission guard reads as well as offload_status.
type Deps ¶
type Deps struct {
// Running lists what llama-swap has loaded. An error means /running could not be read.
Running func(ctx context.Context) ([]Model, error)
// Unload takes one model down through llama-swap's per-model route.
Unload func(ctx context.Context, model string) error
// Devices is the latest per-card reading; !ok = none, or too old to trust.
Devices func() ([]gpuprobe.Device, bool)
// Presence reads the operator's presence for the config's mode.
Presence func() placement.Presence
Now func() time.Time
Logf func(format string, args ...any)
// StatePath is where the last action and the heartbeat are kept for offload_status and for the
// admission guard. "" keeps none.
StatePath string
// StatePathErr is why StatePath could not be resolved, when it could not. The watcher says so at
// start and in the status note: with no state file there is no heartbeat, and the display layer's
// admission (which asks whether a watcher is alive) will refuse for want of one.
StatePathErr error
}
Deps are the reads and writes a check makes, so a test assembles a box. A nil Now or Logf takes the production one; the rest are required.
func Production ¶
Production wires the watcher to this box: llama-swap's /running and its per-model unload route, the presence probe, and the device sample the caller already holds (fleet-serve's 2 s sampler), so the check execs no nvidia-smi of its own.
type Outcome ¶
type Outcome struct {
// Loaded are the watched models llama-swap has loaded.
Loaded []string
// Reasons is why they are being taken down; empty when every guard holds.
Reasons []string
Unloaded []string
// Failed lists the unloads that failed, as "model: error".
Failed []string
// ReadErr is set when /running could not be read, which unloads nothing.
ReadErr error
}
Outcome is what one check found and did.
type State ¶
type State = displaystate.State
Action and State are the state file's shape (internal/displaystate), which the admission guard reads as well as offload_status.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher is the post-admission guard of the display layer.
func New ¶
New builds the watcher for a config, or nil when there is nothing to watch: no display layer with a desktop guard, or display_watch_sec negative (the operator's switch).
func (*Watcher) Check ¶
Check runs one check. It reads /running first and touches nothing else while no watched model is loaded, so an idle display layer costs one local GET.