Documentation
¶
Overview ¶
Package containment provides resource boundary accounting, slot capacity attribution, and hybrid cgroup vs parameter metadata max-pooling for unified memory APU inference.
Package containment is a tier-primitive leaf (describe its single responsibility).
Tier: primitive (1) - see internal/architest. This package may import only packages whose tier is <= 1; an upward import fails the architest gate. See AGENTS.md and internal/architest for the layering contract.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArbitrateAPUHeadroom ¶
func ArbitrateAPUHeadroom(totalApertureBytes int64, allocations []APUAllocationRecord) (consumedBytes int64, freeBytes int64, hasCapacity bool)
ArbitrateAPUHeadroom calculates total attributed memory consumption across multiple model instances and reports remaining free headroom in the APU's unified memory aperture.
func EstimateAPUResidentMemory ¶
func EstimateAPUResidentMemory(cgroupBytes int64, meta ModelMetadata, isAPU bool) int64
EstimateAPUResidentMemory implements hybrid capacity attribution max-pooling:
resident_bytes = max(cgroup_bytes, model_metadata_estimate_bytes)
On Linux APU architectures (such as AMD Strix Halo, Hawk Point, Phoenix), model allocations in GTT/TTM memory apertures can bypass container cgroup v2 memory.current counters. When cgroup telemetry is accurate, cgroup_bytes governs; when GTT allocations bypass the counter, model metadata acts as an unforgeable capacity floor.
Types ¶
type APUAllocationRecord ¶
type APUAllocationRecord struct {
InstanceID string `json:"instance_id"`
ModelMeta ModelMetadata `json:"model_meta"`
CgroupBytes int64 `json:"cgroup_bytes"`
MetadataEstimateBytes int64 `json:"metadata_estimate_bytes"`
AttributedResidentBytes int64 `json:"attributed_resident_bytes"`
APUUnderreportedBytes int64 `json:"apu_underreported_bytes"`
GTTBypassDetected bool `json:"gtt_bypass_detected"`
}
APUAllocationRecord details the hybrid capacity attribution for a model runner instance.
func EvaluateAPUAllocation ¶
func EvaluateAPUAllocation(instanceID string, cgroupBytes int64, meta ModelMetadata, isAPU bool) APUAllocationRecord
EvaluateAPUAllocation evaluates an instance's resident memory against cgroup telemetry and metadata.
type ModelMetadata ¶
type ModelMetadata struct {
ModelName string `json:"model_name"`
ParameterCount int64 `json:"parameter_count"`
WeightBytes int64 `json:"weight_bytes"`
ContextTokens int `json:"context_tokens"`
KVBytesPerToken int `json:"kv_bytes_per_token"`
ScratchpadBytes int64 `json:"scratchpad_bytes"`
}
ModelMetadata declares deterministic model weight, context, and scratch geometry used to calculate an unforgeable capacity floor for APU memory attribution.
func (ModelMetadata) EstimatedMemoryBytes ¶
func (m ModelMetadata) EstimatedMemoryBytes() int64
EstimatedMemoryBytes returns the minimum expected memory footprint based on model parameters, active context window, and runtime scratchpad requirements.