Files
leleka/engine/strata/apps/host/tests/windows-gpu.test.mjs
T
Pavlo RatushnyiandClaude Sonnet 5.5 87e2633afe engine/strata: bring the Strata subtree to upstream 41cf05a0 (engine 0.1.50) with the local patches re-applied
Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree
(570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base =
the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main).

Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR
experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details,
conflict table and left-out files are in docs/upstream.md.

Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61),
docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out.

scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run").
Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR
macros on. No GPU run, no quality gate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 12:49:15 +01:00

48 lines
2.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { EventEmitter } from 'node:events';
import { luidName, parseDxAdapters, windowsOtherGpus, parseGpuCounterLine, createWindowsGpuReader } from '../server/windows-gpu.mjs';
const dxRaw = JSON.stringify([
{ Description: 'AMD Radeon RX 9070 XT', VendorId: '4098', Luid: '90370', Dedicated: '17094934528', Software: '0' },
{ Description: 'Microsoft Basic Render Driver', VendorId: '5140', Luid: '1', Dedicated: '0', Software: '1' },
]);
test('the LUID is spelled as the performance counters spell it', () => {
assert.equal(luidName('90370'), 'luid_0x00000000_0x00016102');
assert.equal(luidName(String(0x12n * 2n ** 32n + 5n)), 'luid_0x00000012_0x00000005');
assert.equal(luidName('nope'), null);
});
test('an AMD card on Windows gets its real memory size and a LUID, virtual monitors are not cards (#3727, #3836)', () => {
const dx = parseDxAdapters(dxRaw);
const cards = windowsOtherGpus([
{ Name: 'AMD Radeon RX 9070 XT', PNPDeviceID: 'PCI-A' },
{ Name: 'Meta Virtual Monitor', PNPDeviceID: 'ROOT-1' },
{ Name: 'Virtual Desktop Monitor', PNPDeviceID: 'ROOT-2' },
], dx);
assert.equal(cards.length, 1);
assert.equal(cards[0].vendor, 'amd');
assert.equal(cards[0].vramGb, 15.9);
assert.equal(cards[0].luid, 'luid_0x00000000_0x00016102');
});
test('without the registry list an AMD card is still listed, with no size', () => {
const cards = windowsOtherGpus([{ Name: 'AMD Radeon RX 7900 XT', PNPDeviceID: 'PCI-B' }], parseDxAdapters('garbage'));
assert.deepEqual(cards.map(c => [c.vendor, c.vramGb, c.luid]), [['amd', 0, null]]);
});
test('counter lines are read, and the load and VRAM in use reach the card by its LUID', () => {
assert.equal(parseGpuCounterLine('nonsense'), null);
const line = parseGpuCounterLine('G luid_0x00000000_0x00016102 37 4294967296');
assert.equal(line.utilizationPct, 37);
assert.equal(line.memoryUsedGb, 4);
const procs = [];
const reader = createWindowsGpuReader({ spawnFn: () => { const p = new EventEmitter(); p.stdout = new EventEmitter(); p.kill = () => {}; procs.push(p); return p; }, now: () => 5 });
assert.equal(reader.read('luid_0x00000000_0x00016102'), null, 'nothing before the first line');
procs[0].stdout.emit('data', 'G luid_0x00000000_0x00016102 37 4294967296\nG luid_0x00000000_0x00000001 0 0\n');
assert.equal(reader.read('LUID_0x00000000_0x00016102').utilizationPct, 37);
assert.equal(reader.read('luid_0x00000000_0x00099999'), null);
assert.equal(procs.length, 1, 'one process for every read');
});