Documentation
¶
Overview ¶
Package memory is the daemon's model-memory accounting: the budget loaded models may use, the footprint estimate for a model before it is loaded, and the measured physical footprint of a running runtime process.
Measurement is deliberately *not* RSS. llama.cpp mmaps GGUF weights, so RSS counts clean file-backed pages the kernel can drop at will and double counts the page cache; the numbers that matter are what macOS calls the physical footprint (proc_pid_rusage ri_phys_footprint, the figure Activity Monitor's "Memory" column and `footprint` show) and what Linux calls the proportional set size (/proc/<pid>/smaps_rollup Pss).
Index ¶
- Constants
- Variables
- func AutoBudgetMB(hw *typesv1.CapabilityProfile, maxVRAMPercent int) int64
- func BudgetMB(configured int64, hw *typesv1.CapabilityProfile, maxVRAMPercent int) int64
- func Discrete(hw *typesv1.CapabilityProfile) bool
- func EstimateMB(fileBytes int64, minRAMMB int64, ctx, parallel int) int64
- func ProcessFootprintMB(pid int) (int64, error)
- func ResolveContext(override, model, maxCtx int) int
- func Unified(hw *typesv1.CapabilityProfile) bool
Constants ¶
const ( // DefaultContext is the context length assumed when neither the catalog // nor the operator sets one. llama-server's own default is 4096; the // larger figure errs on the side of not overfilling the machine. DefaultContext = 8192 )
Estimate parameters.
const MiB = 1024 * 1024
MiB is one mebibyte in bytes.
Variables ¶
var ErrUnsupported = errors.New("memory: footprint measurement not supported on this platform")
ErrUnsupported means footprint measurement is not implemented on this platform; callers keep the pre-load estimate.
Functions ¶
func AutoBudgetMB ¶
func AutoBudgetMB(hw *typesv1.CapabilityProfile, maxVRAMPercent int) int64
AutoBudgetMB derives the model-memory budget when budget.max_ram_mb is 0: half of physical RAM on unified-memory (and CPU-only) machines, and vram × max_vram_percent on discrete GPUs, where the weights live on the card and host RAM is not the constraint.
func BudgetMB ¶
func BudgetMB(configured int64, hw *typesv1.CapabilityProfile, maxVRAMPercent int) int64
BudgetMB resolves the configured budget: configured > 0 wins, else auto.
func Discrete ¶
func Discrete(hw *typesv1.CapabilityProfile) bool
Discrete reports whether the node has a discrete (non-unified) GPU, where weights live in VRAM that host-side footprint measurement cannot see.
func ProcessFootprintMB ¶
ProcessFootprintMB measures the physical footprint of a process in MiB. Returns ErrUnsupported where no implementation exists; callers then keep their estimate.
func ResolveContext ¶ added in v0.4.1
EstimateMB predicts the physical footprint of loading a model before it is loaded:
estimate = file_bytes × 1.15 + ctx × parallel × (file_bytes / 65536) + 256 MB
When the catalog states min_ram_mb the larger of the two wins: the catalog value is authoritative for the weights but was written for a specific context, so a much larger operator-configured context still raises the estimate. ctx <= 0 uses DefaultContext; parallel < 1 is 1. ResolveContext is the context window a runtime is launched with: the operator's explicit override if set, else the model's own length, then capped by maxCtx (0 = no cap). Both the llama.cpp adapter and the admission estimate go through it so they agree on the KV-cache size.
func Unified ¶
func Unified(hw *typesv1.CapabilityProfile) bool
Unified reports whether the node's GPU shares system memory (Apple Silicon). On such machines the RAM budget is the whole story: there is no separate VRAM to fill.
Types ¶
This section is empty.