project-nomad/admin/tests/unit/gpu_model.spec.ts
Chris Sherwood bf7e4b3b48 fix(system): resolve a placeholder GPU name on the System page too
#1165 taught the benchmark path to reject an unresolved PCI id as a GPU
model, but isUnresolvedGpuModel lived inside benchmark_service.ts and the
Settings > System display path never learned the same thing. It still shows
whatever lspci handed back.

The two symptoms of a stale pci.ids database are independent, which is why
the existing guard misses this. system_service already re-probes when a
discrete-GPU controller reports an implausible BAR0 reading as VRAM, and
that happens to fix the name as a side effect. But lspci can return a
perfectly plausible VRAM figure alongside a name it could not resolve, and
then nothing fires.

Confirmed live on an AMD box. The Radeon 780M reports:

  model: "Device 1900", vram: 512

512 MiB clears the 256 MiB bogus-VRAM threshold, so no probe runs and the
System page renders "Device 1900". The same box's Ollama startup log carries
description="AMD Radeon 780M Graphics", so the probe the guard declined to
run had the real name available the whole time. NVIDIA hides this because
its path tends to be reached for other reasons; AMD has no equivalent.

Adds an unresolved-name trigger alongside the VRAM one, and moves
isUnresolvedGpuModel to app/utils/gpu_model.ts so the submission path and the
display path share one definition instead of diverging again. Tests cover
both placeholder shapes and, more importantly, a set of real product names
that must never be rejected.

Stacked on #1277, so the shared helper carries the WSL placeholders too.

Closes #1196

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-29 15:54:41 -07:00

58 lines
1.9 KiB
TypeScript

import * as assert from 'node:assert/strict'
import { test } from 'node:test'
import { isUnresolvedGpuModel } from '../../app/utils/gpu_model.js'
test('unresolved PCI ids are rejected', () => {
// The #1165 shape: a card newer than the container's pci.ids database comes
// back as its raw id. "Device 2d05" is a real RTX 5060 that reached the
// public leaderboard under that name.
for (const s of ['Device 2d05', 'device 2d05', 'DEVICE 1002', 'Device 2d05']) {
assert.equal(isUnresolvedGpuModel(s), true, s)
}
})
test('empty and unknown are rejected', () => {
for (const s of ['', ' ', 'Unknown', 'unknown', 'UNKNOWN']) {
assert.equal(isUnresolvedGpuModel(s), true, JSON.stringify(s))
}
})
test('WSL placeholder adapter names are rejected', () => {
// #1218: WSL reaches the GPU via /dev/dxg, so si.graphics() reports
// Microsoft's placeholder while CUDA runs on a physical card.
for (const s of [
'Microsoft Basic Render Driver',
'microsoft basic render driver',
'Microsoft Basic Display Adapter',
]) {
assert.equal(isUnresolvedGpuModel(s), true, s)
}
})
test('real product names are never rejected', () => {
// The one thing this function must not do. A false positive here discards a
// correct GPU name and sends "unknown" to the leaderboard instead.
for (const s of [
'NVIDIA GeForce RTX 5090',
'NVIDIA GeForce RTX 3090 Ti',
'AMD Radeon RX 6800',
'Navi 48 [Radeon AI PRO R9700]',
'Intel Iris Xe Graphics',
'Raphael',
'Phoenix1',
'Device Manager Graphics 5000',
'GeForce GTX 1080',
'Microsoft Basic Render Driver Pro',
]) {
assert.equal(isUnresolvedGpuModel(s), false, s)
}
})
test('a hex-like id that is not the placeholder shape is kept', () => {
// Guard the regex against over-reach: only a bare "Device <4 hex>" qualifies.
for (const s of ['Device 2d05x', 'Device 2d0', 'Device 2d055', 'My Device 2d05']) {
assert.equal(isUnresolvedGpuModel(s), false, s)
}
})