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>
50 lines
1.7 KiB
Go
50 lines
1.7 KiB
Go
package engines
|
|
|
|
import "testing"
|
|
|
|
const migUUID = "MIG-c6d4f1ef-42e4-5de3-91c7-45d71c87eb3f"
|
|
|
|
func TestAShardOnAMIGInstanceIsGivenItByUUID(t *testing.T) {
|
|
// Placement numbers card 0's instance 1 as 1001, which CUDA has never
|
|
// heard of: CUDA_VISIBLE_DEVICES=1001 is no device at all, and =1 would
|
|
// be the wrong card.
|
|
s := singleNodeSpec()
|
|
s.GPUIndices, s.GPUUUIDs = []int{1001}, []string{migUUID}
|
|
s.Profile.TP = 1
|
|
|
|
env := envMap(buildOne(t, &VLLM{}, s).Env)
|
|
if env["CUDA_VISIBLE_DEVICES"] != migUUID {
|
|
t.Errorf("vLLM: CUDA_VISIBLE_DEVICES=%q, want the instance's UUID", env["CUDA_VISIBLE_DEVICES"])
|
|
}
|
|
|
|
l := llamaSpec([]int{1001})
|
|
l.GPUUUIDs = s.GPUUUIDs
|
|
cmds, err := (&LlamaCpp{}).Commands(l)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
env = envMap(cmds[0].Env)
|
|
if env["CUDA_VISIBLE_DEVICES"] != migUUID {
|
|
t.Errorf("llama.cpp: CUDA_VISIBLE_DEVICES=%q, want the instance's UUID", env["CUDA_VISIBLE_DEVICES"])
|
|
}
|
|
// Vulkan does not see MIG instances, and an index for it would name
|
|
// some other card.
|
|
if v, set := env["GGML_VK_VISIBLE_DEVICES"]; set {
|
|
t.Errorf("GGML_VK_VISIBLE_DEVICES=%q on a MIG instance", v)
|
|
}
|
|
if v, _ := flagValue(cmds[0].Args, "--n-gpu-layers"); v != "999" {
|
|
t.Errorf("the model was not offloaded to the instance: --n-gpu-layers %q", v)
|
|
}
|
|
}
|
|
|
|
func TestAShardOnWholeCardsIsStillGivenThemByIndex(t *testing.T) {
|
|
env := envMap(buildOne(t, &VLLM{}, singleNodeSpec()).Env)
|
|
if env["CUDA_VISIBLE_DEVICES"] != "0,1,2,3" {
|
|
t.Errorf("CUDA_VISIBLE_DEVICES=%q", env["CUDA_VISIBLE_DEVICES"])
|
|
}
|
|
cmds, _ := (&LlamaCpp{}).Commands(llamaSpec([]int{2}))
|
|
if env := envMap(cmds[0].Env); env["GGML_VK_VISIBLE_DEVICES"] != "2" {
|
|
t.Errorf("GGML_VK_VISIBLE_DEVICES=%q", env["GGML_VK_VISIBLE_DEVICES"])
|
|
}
|
|
}
|