Merge C22 MIG

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-05 00:01:51 +02:00
commit 330a421118
39 files changed
+2587 -327

No files matched your search

+58 -7
View File
@@ -228,7 +228,12 @@ type NodeView struct {
DiskFreeGB int `json:"disk_free_gb,omitempty"`
DiskTotalGB int `json:"disk_total_gb,omitempty"`
Classes []string `json:"gpu_classes,omitempty"`
Fabrics []string `json:"fabrics,omitempty"`
// ClassGPUs counts the node's devices by class, in the order of Classes.
// A node with a card in MIG mode has several classes — each profile its
// instances are cut to, and any whole card beside them — and GPUTotal
// alone would add 3g.40gb instances to 80 GB cards.
ClassGPUs []ClassGPUs `json:"gpus_by_class,omitempty"`
Fabrics []string `json:"fabrics,omitempty"`
// Unhealthy lists GPUs kept out of placement and why, which is usually the
// answer when a node looks idle but nothing will schedule onto it.
@@ -255,10 +260,34 @@ type NodeView struct {
IMEXChannels int `json:"imex_channels,omitempty"`
}
// ClassGPUs is how many of a node's devices are of one class, and how many
// of those are free or kept out of placement.
type ClassGPUs struct {
Class string `json:"class"`
Total int `json:"total"`
Free int `json:"free"`
Unhealthy int `json:"unhealthy,omitempty"`
// MIG marks a class of MIG instances, each of which takes a replica of
// its own and never joins a tensor-parallel group.
MIG bool `json:"mig,omitempty"`
}
// GPUView is one card as a node's page shows it.
type GPUView struct {
Index int `json:"index"`
Name string `json:"name"`
// Label is the device as people are shown it: "3" for a whole card,
// "0/mig2" for card 0's MIG instance 2.
Label string `json:"label"`
Class string `json:"class"`
// Card is the physical card's index: the device's own, or for a MIG
// instance its parent's, which is what the card's sensors are under.
Card int `json:"card"`
// MIGProfile is the instance's profile, like 3g.40gb; empty for a
// whole card.
MIGProfile string `json:"mig_profile,omitempty"`
MemoryTotalMB int `json:"memory_total_mb,omitempty"`
MemoryUsedMB int `json:"memory_used_mb,omitempty"`
// ComputeCapability is what decides which engine builds run on the card:
// CUDA 13 builds need 7.5, so a V100 (7.0) runs only older ones.
ComputeCapability string `json:"compute_capability,omitempty"`
@@ -556,15 +585,25 @@ func (a *API) Nodes() []NodeView {
for _, w := range n.Weights {
v.Models = append(v.Models, w.Path)
}
seen := map[string]struct{}{}
seen := map[string]int{}
free := inv.FreeGPUs(n.ID)
for _, g := range n.GPUs {
if _, dup := seen[g.Class()]; !dup {
seen[g.Class()] = struct{}{}
k, dup := seen[g.Class()]
if !dup {
k = len(v.ClassGPUs)
seen[g.Class()] = k
v.Classes = append(v.Classes, g.Class())
v.ClassGPUs = append(v.ClassGPUs, ClassGPUs{Class: g.Class(), MIG: g.IsMIG()})
}
if !g.Health.OK() {
c := &v.ClassGPUs[k]
c.Total++
switch {
case !g.Health.OK():
c.Unhealthy++
v.Unhealthy = append(v.Unhealthy,
fmt.Sprintf("gpu %d: %s", g.Index, g.Health.Problems[0]))
fmt.Sprintf("gpu %s: %s", discovery.DeviceLabel(g.Index), g.Health.Problems[0]))
case slices.Contains(free, g.Index):
c.Free++
}
}
if !n.LastSeen.IsZero() {
@@ -574,7 +613,12 @@ func (a *API) Nodes() []NodeView {
v.NVLinkDomain, v.IMEX, v.IMEXChannels = n.NVLinkDomain(), n.IMEX.State, n.IMEX.Channels
for _, g := range n.GPUs {
gv := GPUView{Index: g.Index, Name: g.Name, ComputeCapability: g.ComputeCapability,
NUMA: g.NUMANode, NVLinkPeers: g.NVLinkPeers}
NUMA: g.NUMANode, NVLinkPeers: g.NVLinkPeers,
Label: discovery.DeviceLabel(g.Index), Class: g.Class(), Card: g.CardIndex(),
MemoryTotalMB: g.MemoryTotalMB, MemoryUsedMB: g.MemoryUsedMB}
if g.MIG != nil {
gv.MIGProfile = g.MIG.Profile
}
for hca, rel := range g.NICPaths {
if gv.NearestNIC == "" || discovery.PathRank(rel) < discovery.PathRank(gv.NICPath) ||
(discovery.PathRank(rel) == discovery.PathRank(gv.NICPath) && hca < gv.NearestNIC) {
@@ -1619,6 +1663,13 @@ func (a *API) PoolNodes() []modelplan.PoolNode {
p.Class = n.Classes[0]
p.GPUMemGB = modelplan.MemFromClass(p.Class)
}
// By class, with each class's own count of devices: a node with a
// card in MIG mode is several, and its first class alone would
// count every instance and card as that one.
for _, c := range n.ClassGPUs {
p.Kinds = append(p.Kinds, modelplan.PoolKind{Class: c.Class,
GPUMemGB: modelplan.MemFromClass(c.Class), GPUs: c.Total, FreeGPUs: c.Free})
}
if len(n.Fabrics) > 0 {
p.Fabric = n.Fabrics[0]
}