Documentation
¶
Overview ¶
Package gpu derives the GPU Offerings present on a cluster from its node labels and advertised extended resources (ADR-0002). The same derivation feeds both the WorkspaceDeployment gate (live, against the target Child Cluster) and the Colony GPU Inventory poll, so the offering vocabulary the API advertises and the vocabulary the gate matches are identical by construction.
Index ¶
- Constants
- func AvailableForModel(nodes []corev1.Node, pods []corev1.Pod, model string, opts Options) (free int64, found bool)
- func BuildSelector(model string, raw map[string]string, opts Options) map[string]string
- func NodeSelectorForModel(model string, opts Options) map[string]string
- func ResourceForVendor(vendor workspacesv1.GPUVendor) string
- type Offering
- type Options
- type SelectorAvailability
Constants ¶
const ( // DefaultModelLabel is the well-known node label, set by provisioning, // that carries an offering's canonical short model name (memory baked in, // e.g. "H100", "A100-80GB"). It is the offering's identity AND the label a // chart's nodeSelector places on, so deriving offerings from it guarantees // "passes the gate" implies "is placeable" (ADR-0002). DefaultModelLabel = "exalsius.ai/gpu-model" // DefaultVendorLabel optionally overrides the inferred vendor. DefaultVendorLabel = "exalsius.ai/gpu-vendor" // ResourceNvidiaGPU is the whole-GPU extended resource for NVIDIA. ResourceNvidiaGPU = "nvidia.com/gpu" // ResourceAMDGPU is the whole-GPU extended resource for AMD. ResourceAMDGPU = "amd.com/gpu" )
Variables ¶
This section is empty.
Functions ¶
func AvailableForModel ¶
func AvailableForModel(nodes []corev1.Node, pods []corev1.Pod, model string, opts Options) (free int64, found bool)
AvailableForModel returns how many GPUs of the given canonical model are free to schedule right now (CONTEXT.md: Available Capacity): the allocatable units of the model's GPU resource on its nodes, minus the units already requested by pods running on those nodes. `found` is false when no schedulable node carries the model at all (i.e. the offering is absent) — callers distinguish "absent" (a gate failure) from "present but 0 free" (a wait). Counting is discrete-unit, so it covers whole GPUs and MIG slices alike; fractional/HAMi sharing is out of scope (ADR-0002).
func BuildSelector ¶
BuildSelector composes the GPU Selector from the gpuType convention (which maps to the model label) and a raw exact-match label override, both optional (ADR-0002). Raw entries win on key collision. The result is the one selector the gate validates and the chart applies.
func NodeSelectorForModel ¶
NodeSelectorForModel returns the node-label requirements that pin a pod to the given canonical model — the GPU Selector the chart applies and the gate validates (one identical selector, ADR-0002).
func ResourceForVendor ¶
func ResourceForVendor(vendor workspacesv1.GPUVendor) string
ResourceForVendor returns the whole-GPU extended resource name a pod must request for the given vendor, or "" if unknown. Used for coarse "any GPU of this vendor" requests where no concrete offering is resolved.
Types ¶
type Offering ¶
type Offering struct {
// --- identity ---
Vendor workspacesv1.GPUVendor
Model string // best-effort short name: canonical model label, else a vendor product label, else empty
Profile string // partition/MIG profile; empty for whole GPUs (reserved for later phases)
ResourceName string // extended resource a pod must request (e.g. nvidia.com/gpu)
// --- attributes ---
Total int64 // total GPUs of this offering across the cluster
Nodes int32 // number of nodes carrying it
// Selector is the exact node-label requirement that reproduces this
// offering — the GPU Selector a workspace uses to pick it, and the one the
// gate validates (ADR-0002: "passing the gate implies placeable"). It is
// {canonical-label: model} when provisioning labelled the node, else
// {product-label: value} when derived from a vendor label, else nil when the
// node carried no usable GPU label (callers then compose one from Labels).
Selector map[string]string
Labels map[string]string // representative raw vendor labels (data retention)
}
Offering is a distinct kind of GPU available on a cluster (CONTEXT.md: GPU Offering). Identity is (Vendor, Model, Profile, ResourceName); the remaining fields are attributes aggregated across the cluster's nodes.
func DeriveOfferings ¶
DeriveOfferings aggregates the GPU Offerings present on the given nodes (ADR-0002, revised). Every schedulable node advertising a supported GPU extended resource produces an offering — a node is no longer dropped for lacking the canonical model label. The model is best-effort (canonical label, else a vendor product label, else empty) and each offering carries the Selector that reproduces it, so discovery stays faithful to the hardware while "passing the gate implies placeable" still holds. Offerings are keyed on (vendor, profile, resourceName, selector) and returned in a stable order.
type Options ¶
type Options struct {
ModelLabel string
VendorLabel string
// ProductLabels overrides the per-vendor fallback model labels. Zero value
// uses defaultProductLabels.
ProductLabels map[workspacesv1.GPUVendor][]string
}
Options controls how offerings are derived. Zero value uses the defaults.
type SelectorAvailability ¶
type SelectorAvailability struct {
// Found is true when at least one schedulable node matches the selector and
// advertises a GPU resource.
Found bool
// Free is the number of GPUs free to schedule across matching nodes
// (allocatable minus pod requests).
Free int64
// ResourceName is the GPU extended resource on the matching nodes.
ResourceName string
// Vendor is the GPU vendor of the matching nodes.
Vendor workspacesv1.GPUVendor
}
SelectorAvailability summarizes a GPU Selector against a cluster's nodes.
func AvailabilityForSelector ¶
func AvailabilityForSelector(nodes []corev1.Node, pods []corev1.Pod, selector map[string]string) SelectorAvailability
AvailabilityForSelector evaluates a GPU Selector against the cluster: whether any schedulable GPU node matches it, how many GPUs are free across those nodes, and the GPU resource/vendor they carry. This is the generalization of AvailableForModel to arbitrary node-label selectors (ADR-0002): a gpuType request and a raw-label request are both just selectors.