Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Benchmark: name ROCm GPUs from rocminfo
A ROCm receipt recorded no GPU, so a Strix Halo run could not say what it
ran on. The probe now reads rocminfo's GPU agents: vendor and marketing name,
first global pool and compute units, kept by HIP_VISIBLE_DEVICES (else
ROCR_VISIBLE_DEVICES) indices. An APU named "... Graphics" records unified
memory, a discrete card dedicated. The in-kernel amdgpu driver has no version,
so the driver stays unknown. Publishing ROCm is unchanged: still refused.
  • Loading branch information
ThinkOffApp committed Oct 18, 2026
commit bbcde958a87c8ca040ced48f3762df9daab51176
2 changes: 1 addition & 1 deletion docs/community-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ The parameter-versus-speed plot uses the selected parameter basis on a logarithm

## AMD (ROCm)

A ROCm build runs the same suite and saves its receipt locally, with backend `rocm` on platform `linux`. `--backend auto` picks `rocm` on that build; an attached run names it with `--backend rocm`. A managed ROCm run records the CPU and system memory, while GPU names and the driver version stay unknown. `inspect` shows a ROCm receipt as usual. The board accepts mlx and cuda receipts for now, so `--publish` with ROCm is refused before the run starts and `benchmark publish` refuses a ROCm receipt before any upload; publishing waits for the board to accept rocm.
A ROCm build runs the same suite and saves its receipt locally, with backend `rocm` on platform `linux`. `--backend auto` picks `rocm` on that build; an attached run names it with `--backend rocm`. A managed ROCm run records the CPU and system memory, and each GPU agent `rocminfo` lists: its vendor and marketing name (for example `AMD Radeon 8060S Graphics`), its first global memory pool and its compute units, kept by `HIP_VISIBLE_DEVICES` (else `ROCR_VISIBLE_DEVICES`) indices. An AMD APU, whose GPU is named "... Graphics", is recorded as `unified` memory; discrete cards as `dedicated`. The in-kernel amdgpu driver has no version, so the driver stays unknown. Without `rocminfo` the GPUs stay unknown, as before. `inspect` shows a ROCm receipt as usual. The board accepts mlx and cuda receipts for now, so `--publish` with ROCm is refused before the run starts and `benchmark publish` refuses a ROCm receipt before any upload; publishing waits for the board to accept rocm.
93 changes: 88 additions & 5 deletions zig/src/server/benchmark_facts_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,83 @@ test "/proc text gives the CPU name and memory" {
try std.testing.expectEqual(@as(?u64, null), host.meminfo("MemTotal: 5 MB\n"));
}

test "a rocm probe runs no nvidia-smi, names no GPU or driver, and passes the save rules" {
const rocminfo_strix =
\\ROCk module is loaded
\\HSA Agents
\\*******
\\Agent 1
\\*******
\\ Name: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S
\\ Uuid: CPU-XX
\\ Marketing Name: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S
\\ Vendor Name: CPU
\\ Device Type: CPU
\\ Compute Unit: 32
\\ Pool Info:
\\ Pool 1
\\ Segment: GLOBAL; FLAGS: FINE GRAINED
\\ Size: 127838212(0x79ea604) KB
\\*******
\\Agent 2
\\*******
\\ Name: gfx1151
\\ Uuid: GPU-XX
\\ Marketing Name: Radeon 8060S Graphics
\\ Vendor Name: AMD
\\ Device Type: GPU
\\ Chip ID: 5510(0x1586)
\\ Compute Unit: 40
\\ Pool Info:
\\ Pool 1
\\ Segment: GLOBAL; FLAGS: COARSE GRAINED
\\ Size: 125829120(0x7800000) KB
\\ Pool 2
\\ Segment: GROUP
\\ Size: 64(0x40) KB
\\ ISA Info:
\\ ISA 1
\\ Name: amdgcn-amd-amdhsa--gfx1151
\\
;

const rocminfo_two_dgpus =
\\*******
\\Agent 2
\\*******
\\ Marketing Name: AMD Radeon PRO W7800
\\ Vendor Name: AMD
\\ Device Type: GPU
\\ Compute Unit: 70
\\ Segment: GLOBAL; FLAGS: COARSE GRAINED
\\ Size: 50331648(0x3000000) KB
\\*******
\\Agent 3
\\*******
\\ Marketing Name: AMD Radeon PRO V620
\\ Vendor Name: AMD
\\ Device Type: GPU
\\ Compute Unit: 72
\\ Segment: GLOBAL; FLAGS: COARSE GRAINED
\\ Size: 31440896(0x1dfc000) KB
\\
;

test "a rocm probe names rocminfo's GPU agents, runs no nvidia-smi, reports no driver, and passes the save rules" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
try std.testing.expect(host.gpuQuery("rocm") == null and std.mem.eql(u8, host.gpuQuery("cuda").?[0], "nvidia-smi"));
const probe = host.linux(a, "AMD EPYC 9004", 128 << 30, "", null);
try std.testing.expect(probe.driver == null and probe.hardware.gpus.len == 0);
try std.testing.expect(std.mem.eql(u8, probe.hardware.source, "partial") and std.mem.eql(u8, probe.hardware.memory_type, "unknown"));
try std.testing.expect(std.mem.eql(u8, host.gpuQuery("rocm").?[0], "rocminfo") and std.mem.eql(u8, host.gpuQuery("cuda").?[0], "nvidia-smi"));
// Strix Halo's /proc/cpuinfo name has a "/", outside the board's name pattern, so the CPU stays unknown.
const cpu = host.cpuinfo(a, "model name\t: AMD RYZEN AI MAX+ 395 w/ Radeon 8060S\n");
try std.testing.expect(cpu == null);
const probe = host.rocm(a, cpu, 128 << 30, rocminfo_strix, null);
try std.testing.expect(probe.driver == null and probe.hardware.gpus.len == 1);
const g = probe.hardware.gpus[0];
try std.testing.expectEqualStrings("AMD Radeon 8060S Graphics", g.name);
try std.testing.expectEqual(@as(?u64, 125829120 * 1024), g.memory_bytes);
try std.testing.expectEqual(@as(?u64, 40), g.cores);
try std.testing.expect(std.mem.eql(u8, probe.hardware.source, "partial") and std.mem.eql(u8, probe.hardware.memory_type, "unified"));
try std.testing.expectEqualStrings("detected", host.rocm(a, "AMD EPYC 9004", 128 << 30, rocminfo_strix, null).hardware.source);
const runtime: receipt.Runtime = .{ .tensorfold_version = "0.0.0-test", .backend = "rocm", .python_version = "none", .platform = "linux", .driver = probe.driver };
const sample: suite.Sample = .{ .fixture_id = "code", .temperature = 0, .repeat = -1, .seed = 1, .status = .@"error", .error_code = .server_error };
const v = try receipt.value(a, "00000000-0000-4000-8000-000000000001", "2026-01-01T00:00:00Z", .{ .repo_id = "example-org/test-model", .local = false }, runtime, probe.hardware, .{ .tokens = 2, .repetitions = 1, .temperatures = &.{0}, .serial = false, .context_tokens = null, .managed = true }, &.{sample});
Expand All @@ -177,3 +246,17 @@ test "a rocm probe runs no nvidia-smi, names no GPU or driver, and passes the sa
}
try std.testing.expect(v.get("runtime").?.get("dependencies").?.object.count() == 0);
}

test "rocm GPUs: discrete cards are dedicated, visible-device indices select, and missing rocminfo leaves the GPUs unknown" {
var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
const both = host.rocm(a, "AMD EPYC 9004", 128 << 30, rocminfo_two_dgpus, null);
try std.testing.expect(both.hardware.gpus.len == 2 and std.mem.eql(u8, both.hardware.memory_type, "dedicated"));
try std.testing.expectEqualStrings("AMD Radeon PRO V620", both.hardware.gpus[1].name);
const second = host.rocm(a, "AMD EPYC 9004", 128 << 30, rocminfo_two_dgpus, "1");
try std.testing.expect(second.hardware.gpus.len == 1 and second.hardware.gpus[0].cores.? == 72);
for ([_][]const u8{ "-1", "", "x" }) |sel| try std.testing.expect(host.rocm(a, null, null, rocminfo_two_dgpus, sel).hardware.gpus.len == 0);
const none = host.rocm(a, "AMD EPYC 9004", 128 << 30, "", null);
try std.testing.expect(none.hardware.gpus.len == 0 and std.mem.eql(u8, none.hardware.source, "partial") and std.mem.eql(u8, none.hardware.memory_type, "unknown"));
}
79 changes: 76 additions & 3 deletions zig/src/server/benchmark_host.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! The hardware allowlist per OS: CPU and GPU names, memory, cores, and the CUDA driver version.
//! On ROCm the GPUs come from rocminfo's GPU agents; the amdgpu driver has no version to report.
const std = @import("std");
const builtin = @import("builtin");
const json = @import("json");
Expand All @@ -22,16 +23,88 @@ pub fn detect(a: Allocator, io: std.Io, env: *const std.process.Environ.Map, bac
}
const cpu = cpuinfo(a, readProc(a, io, "/proc/cpuinfo") orelse "");
const memory = meminfo(readProc(a, io, "/proc/meminfo") orelse "") orelse (std.process.totalSystemMemory() catch null);
const csv = if (gpuQuery(backend)) |argv| run(a, io, argv) orelse "" else "";
return linux(a, cpu, memory, csv, env.get("CUDA_VISIBLE_DEVICES"));
const out = if (gpuQuery(backend)) |argv| run(a, io, argv) orelse "" else "";
if (std.mem.eql(u8, backend, "rocm")) return rocm(a, cpu, memory, out, env.get("HIP_VISIBLE_DEVICES") orelse env.get("ROCR_VISIBLE_DEVICES"));
return linux(a, cpu, memory, out, env.get("CUDA_VISIBLE_DEVICES"));
}

/// The GPU query behind a backend's facts: nvidia-smi for cuda; none for rocm, whose GPUs and driver stay unknown.
/// The GPU query behind a backend's facts: nvidia-smi for cuda, rocminfo for rocm; none otherwise.
pub fn gpuQuery(backend: []const u8) ?[]const []const u8 {
if (std.mem.eql(u8, backend, "rocm")) return &.{"rocminfo"};
if (!std.mem.eql(u8, backend, "cuda")) return null;
return &.{ "nvidia-smi", "--query-gpu=name,memory.total,driver_version", "--format=csv,noheader,nounits" };
}

/// ROCm facts from the CPU and memory probes and rocminfo's GPU agents, kept by ``HIP_VISIBLE_DEVICES`` indices.
/// An AMD APU (a GPU named "... Graphics", such as Radeon 8060S Graphics) shares system memory: ``unified``.
pub fn rocm(a: Allocator, cpu: ?[]const u8, memory: ?u64, text: []const u8, visible: ?[]const u8) Probe {
const all = amdGpus(a, text);
const gpus = select(Gpu, a, all, visible) orelse return .{ .hardware = summarize(cpu, memory, &.{}, false) };
var h = summarize(cpu, memory, gpus, false);
if (gpus.len > 0) h.memory_type = for (gpus) |g| {
if (!std.mem.endsWith(u8, g.name, " Graphics")) break "dedicated";
} else "unified";
return .{ .hardware = h };
}

/// GPU agents from ``rocminfo``: the vendor-prefixed marketing name, the first GLOBAL pool size and the compute units.
pub fn amdGpus(a: Allocator, text: []const u8) []const Gpu {
var out: std.ArrayList(Gpu) = .empty;
var agents = std.mem.splitSequence(u8, text, "*******");
while (agents.next()) |block| {
var marketing: []const u8 = "";
var vendor: []const u8 = "";
var gpu = false;
var g: Gpu = .{ .name = "" };
var lines = std.mem.splitScalar(u8, block, '\n');
var segment_global = false;
while (lines.next()) |l| {
const colon = std.mem.indexOfScalar(u8, l, ':') orelse continue;
const key = std.mem.trim(u8, l[0..colon], " \t");
const value = std.mem.trim(u8, l[colon + 1 ..], " \t\r");
if (std.mem.eql(u8, key, "Marketing Name")) marketing = value;
if (std.mem.eql(u8, key, "Vendor Name")) vendor = value;
if (std.mem.eql(u8, key, "Device Type")) gpu = std.mem.eql(u8, value, "GPU");
if (std.mem.eql(u8, key, "Compute Unit") and g.cores == null) g.cores = std.fmt.parseInt(u64, value, 10) catch null;
if (std.mem.eql(u8, key, "Segment")) segment_global = std.mem.startsWith(u8, value, "GLOBAL");
if (std.mem.eql(u8, key, "Size") and segment_global and g.memory_bytes == null) g.memory_bytes = kib(value);
}
if (!gpu) continue;
const full = if (vendor.len > 0 and !std.mem.startsWith(u8, marketing, vendor))
std.fmt.allocPrint(a, "{s} {s}", .{ vendor, marketing }) catch return &.{}
else
marketing;
g.name = modelName(a, full) orelse continue;
out.append(a, g) catch return &.{};
}
return out.items;
}

/// rocminfo's ``125829120(0x7800000) KB`` in bytes.
fn kib(value: []const u8) ?u64 {
var end: usize = 0;
while (end < value.len and std.ascii.isDigit(value[end])) end += 1;
if (end == 0 or !std.mem.endsWith(u8, value, " KB")) return null;
const n = std.fmt.parseInt(u64, value[0..end], 10) catch return null;
return if (n > 0 and n < 1 << 43) n * 1024 else null;
}

/// Items kept by a comma-separated index list (``CUDA_VISIBLE_DEVICES`` rules); null when the list is malformed.
fn select(comptime T: type, a: Allocator, items: []const T, visible: ?[]const u8) ?[]const T {
const v = visible orelse return items;
const sel = std.mem.trim(u8, v, " \t\n\r");
if (sel.len == 0 or std.mem.eql(u8, sel, "-1")) return &.{};
var kept: std.ArrayList(T) = .empty;
var it = std.mem.splitScalar(u8, v, ',');
while (it.next()) |raw| {
const index = std.mem.trim(u8, raw, " \t");
for (index) |ch| if (!std.ascii.isDigit(ch)) return null;
const n = std.fmt.parseInt(usize, index, 10) catch return null;
if (n < items.len) kept.append(a, items[n]) catch return null;
}
return kept.items;
}

/// Linux facts from the CPU and memory probes and the nvidia-smi rows, empty when no query ran.
pub fn linux(a: Allocator, cpu: ?[]const u8, memory: ?u64, csv: []const u8, visible: ?[]const u8) Probe {
const rows = nvidiaRows(a, csv, visible);
Expand Down