Documentation
¶
Overview ¶
Package gpucards is the per-card view of the GPU lease: the card table joined with the live leases, one row per card, the per-lease device sets and the queue. `gpu status`, `gpu cards` and offload_status render the SAME rows, so the surfaces a session reads cannot disagree about which card is held by whom (the same rule as gpulease.QueueHint).
Cards are keyed by UUID (plan invariant I2). A whole-node lease holds every card and the row says so. JSON keys are only ever added to.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QueueRows ¶
QueueRows is the queue with each entry's device set. The four keys status always had keep their types; devices and scope are new.
func Section ¶
func Section(cards []gpuprobe.Card, note string, leases []gpulease.Info, waiters []gpulease.Waiter, capPct int, floorGiB float64) map[string]any
Section is what `gpu status --json` adds for cards: the table (empty, with a note, when there is no card table), the per-lease list and the queue. Only keys are added; nothing existing changes type.
Types ¶
type DisplayCap ¶
type DisplayCap struct {
CapPct int `json:"cap_pct"`
BudgetGiB float64 `json:"budget_gb"`
UsedGiB float64 `json:"used_gb"`
UsedPct float64 `json:"used_pct"`
OverCap bool `json:"over_cap"`
OverByGiB float64 `json:"over_by_gb,omitempty"`
Closed bool `json:"closed,omitempty"`
Unknown string `json:"unknown,omitempty"`
}
DisplayCap is the live reading of the display card against gpu_display_cap_pct: the VRAM in use now (the desktop and every process counted, which is how the allocator counts it) against the share of the card the cap allows. It is the verdict the allocator would reach on an empty request, taken from the card as it is, so it covers memory the allocator never placed (a seat llama-swap loaded onto the card). It cannot say whose memory it is. The two states that are not a verdict say why: Closed (the cap is 0, the operator's "I need the card" switch) and Unknown (a reading that could not say which card the monitor is on, or a card with no total). OverByGiB is present exactly when the card is over, to four decimals of a GiB and never rounded to nothing.
type Holder ¶
type Holder struct {
Epoch uint64 `json:"epoch"`
Class string `json:"class"`
PID int `json:"pid"`
Scope string `json:"scope"` // "card" or "whole-node"
Group string `json:"group,omitempty"`
Command string `json:"command,omitempty"`
WrapperVersion string `json:"wrapper_version,omitempty"`
}
Holder is the lease that holds a card.
type HostView ¶
type HostView struct {
Read bool
Mem gpuprobe.HostMemory
// HeadroomGiB is the configured headroom (gpu_host_ram_headroom_gib).
HeadroomGiB float64
// Declared is the sum of the host memory the live leases declared; Pending the part of it their
// processes have not loaded yet, per quantity (TouchGiB the working set, CommitGiB the commit).
Declared, Pending gpuprobe.HostLoad
Verdict gpuprobe.HostVerdict
}
HostView is the host's memory as `gpu status`, `gpu status --json` and offload_status show it: the reading, the headroom, what the live leases declared (the working set they touch and the commit they are charged) and what of that is still to load, and ONE word for how it stands (OK / NEAR / OVER). All three surfaces build it here, the way they share the card rows, so a session reading one cannot be told something the other contradicts.
The word judges the lines the grant applies (gpuprobe.HostMemory.Verdict): the available physical memory, the commit charge against physical RAM (the line a commit nobody stated is held to, unless an enforced commit limit sits below it), and the commit limit where the OS enforces one. NEAR is inside the headroom of any of them, so a lease judged on that line waits: one that touches host RAM when the available memory is, one that states no commit when the room under physical RAM is, one that states its commit when the room under the commit limit is (a host that reads NEAR on the physical line alone still admits a lease that states its commit); OVER is one of them gone (nothing available, the commit charge above physical RAM, or at the limit), and when it rests on the physical line alone the lead says what a lease that states its commit is judged on instead (StatedCommitClause). It is a statement about room, not about paging: whether the box is paging now needs the page-file growth or the pages-out rate, which no surface here reads, so none of them says it. The grant's own rule (gpuprobe.HostRAMAdmitsLoad) is stricter for the load it is asked to admit (it holds a new declaring lease while its need plus what running leases have yet to load would pass either line less the headroom), but it compares a declaration, so a box can still read NEAR or OVER after a lane it admitted committed more than it declared (measured: gpu-lease.md, "Known limits") as well as after something the grant never saw (a process outside every lease).
func NewHostView ¶
func NewHostView(mem gpuprobe.HostMemory, ok bool, headroomGiB float64, declared, pending gpuprobe.HostLoad) HostView
NewHostView judges a reading. A reading that could not be taken is verdict "unknown".
func (HostView) Lead ¶
Lead is the clause that leads offload_status's one-line gpu_lease verdict when the host is over ("HOST RAM OVER ..."), or trails it when the host is near; "" otherwise. OVER is stated loudly and first because a session reading "free" at the head of that line would conclude the box has room.
func (HostView) StatedCommitClause ¶
StatedCommitClause is what the loud OVER lead adds when the verdict rests on the commit charge above physical RAM: the line a lease that states NO commit is held to. A lease that states its commit is not judged on that line (on the commit limit instead, or not at all where the OS enforces none), and the rule admits it, so a session reading the lead alone would hold off work the rule admits. It is "" for any other verdict, for an OVER that rests on something else (nothing available), and for a reading at or near an enforced limit, where a stated commit waits as well.
type Row ¶
type Row struct {
UUID string `json:"uuid"`
Index int `json:"index"`
Name string `json:"name"`
Display bool `json:"display"`
VRAMTotalGiB float64 `json:"vram_total_gb"`
VRAMFreeGiB float64 `json:"vram_free_gb"`
UtilPct int `json:"util_pct"`
UtilKnown bool `json:"util_known"`
ComfyOrder int `json:"comfy_order"` // -1 = not declared
State string `json:"state"` // "free" or "held"
Holder *Holder `json:"holder"`
// DisplayUnknown: the reading could not say which card the monitor is on (gpuprobe.Card.DisplayUnknown).
DisplayUnknown bool `json:"display_unknown,omitempty"`
// DisplayCap is the live verdict of gpu_display_cap_pct on this card; see DisplayCap.
DisplayCap *DisplayCap `json:"display_cap,omitempty"`
}
Row is one line of the card table.
func RowsWithCap ¶
RowsWithCap joins the card table with the live leases and the display card's cap. A card-scoped lease holds the cards it names; a whole-node lease holds every card, and says so. The display card's row carries its cap verdict (DisplayCap), computed here and nowhere else: capPct and floorGiB are the allocator's own inputs (gpu_display_cap_pct as the config file says now, and the display layer's declared floor), and this is the only constructor of rows, so no surface can print the table without them.