Discovery reports a card in MIG mode as its instances instead of the whole card, on both paths: nvidia-smi (-L names them, -q -x gives their memory, ids and processes) and NVML (GetMigMode, GetMaxMigDeviceCount, GetMigDeviceHandleByIndex, behind an interface so it is tested with a fake). Each instance has its MIG UUID, its own memory, and a class from the card's and the profile: a100-80g-mig-3g.40gb. Placement numbers instances 1000 + 100 x card + instance and every view shows them as card/migN. A replica on MIG runs on exactly one instance: a process opens one MIG device and instances have no NVLink between them, so tp, pp, gpus or nodes above one on a MIG class are refused in catalog validation and again in placement, and the planner offers one instance or none. The agent gives the engine CUDA_VISIBLE_DEVICES=MIG-<uuid> (no Vulkan device variable on MIG). Memory and processes are per instance; heat, power and wear the card's; utilisation is left out rather than reported as zero. A card in MIG mode with nothing carved stays out of placement with the reason, and llmgw doctor reports each card's mode and instances and warns of the states in which nothing can run. ctl nodes, ctl status, the console and the plan count devices by class. docs/install.md has a MIG section. Written against fakes of nvidia-smi and NVML output; not yet run on MIG hardware. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
79 lines
2.7 KiB
Go
79 lines
2.7 KiB
Go
package discovery
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestGPUProcessesOfEveryKindAreListedByIndex(t *testing.T) {
|
|
report := `<?xml version="1.0" ?>
|
|
<nvidia_smi_log>
|
|
<driver_version>580.65.06</driver_version>
|
|
<gpu id="00000000:17:00.0"><product_name>Tesla V100-SXM2-32GB</product_name>
|
|
<processes></processes>
|
|
</gpu>
|
|
<gpu id="00000000:65:00.0"><product_name>Tesla V100-SXM2-32GB</product_name>
|
|
<processes>
|
|
<process_info><pid>4100</pid><type>C</type><process_name>llama-server</process_name></process_info>
|
|
<process_info><pid>4300</pid><type>G</type><process_name>llama-server</process_name></process_info>
|
|
</processes>
|
|
</gpu>
|
|
<gpu id="00000000:B3:00.0"><processes>
|
|
<process_info><pid>4200</pid><type>C+G</type></process_info>
|
|
</processes></gpu>
|
|
</nvidia_smi_log>`
|
|
got, err := parseGPUProcesses([]byte(report))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// A Vulkan engine is a graphics process ("G") and is on its GPU all the
|
|
// same; a compute-only query would have missed it.
|
|
want := map[int][]int{1: {4100, 4300}, 2: {4200}}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("got %v, want %v", got, want)
|
|
}
|
|
if _, err := parseGPUProcesses([]byte("not xml")); err == nil {
|
|
t.Error("a report that does not parse was read as no processes")
|
|
}
|
|
}
|
|
|
|
func TestGPUMemoryIsReadPerProcess(t *testing.T) {
|
|
report := `<?xml version="1.0" ?>
|
|
<nvidia_smi_log>
|
|
<gpu id="00000000:01:00.0"><product_name>Quadro RTX 6000</product_name>
|
|
<fb_memory_usage><total>24576 MiB</total><used>14514 MiB</used><free>10062 MiB</free></fb_memory_usage>
|
|
<processes>
|
|
<process_info><pid>71315</pid><type>C</type><used_memory>4932 MiB</used_memory></process_info>
|
|
<process_info><pid>4100</pid><type>C</type><used_memory>9500 MiB</used_memory></process_info>
|
|
</processes>
|
|
</gpu>
|
|
<gpu id="00000000:02:00.0">
|
|
<fb_memory_usage><used>N/A</used></fb_memory_usage>
|
|
<processes></processes>
|
|
</gpu>
|
|
</nvidia_smi_log>`
|
|
got, err := parseGPUMemory([]byte(report))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := []GPUMemory{
|
|
{Index: 0, UsedMB: 14514, Procs: []GPUProcess{{PID: 71315, UsedMB: 4932}, {PID: 4100, UsedMB: 9500}}},
|
|
{Index: 1},
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("got %+v, want %+v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestForeignMemoryBelowTheToleranceIsNoProblem(t *testing.T) {
|
|
// A CUDA context that has let go of its model still holds a few hundred
|
|
// MiB: ComfyUI after /free held 324.
|
|
if p := ForeignMemoryProblem(330); p != "" {
|
|
t.Errorf("330 MiB is a problem: %q", p)
|
|
}
|
|
p := ForeignMemoryProblem(5014)
|
|
if !IsForeignMemoryProblem(p) || IsForeignMemoryProblem("2 uncorrected ECC errors") {
|
|
t.Errorf("%q is not recognised as the foreign memory problem, or ECC is", p)
|
|
}
|
|
}
|