Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- CUDA on integrated GPUs such as the GB10: every other synchronous device-to-host copy now stages through the same pinned buffer as `download` (54 copies in families, tools and tests); discrete cards keep the direct copy, and the bytes copied are unchanged (#2289, for #2102).

- Each native model discovery entry publishes loaded capability booleans, read through the same flag accessor as request admission (#2139, #2157).

- Tests: `tf-qwen27-reuse`'s yielded-pass check follows the host's lane loop on M5 chips, comparing state only where the rounds match and tokens always (#2343).
Expand Down
1 change: 1 addition & 0 deletions zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
if (host.result.os.tag != .windows) @import("h3_host.zig").targets(b, cuda, step);
b.step("test-gradient-host", "Gradient bounds through real wrappers with recorded CUDA launches").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = cuda, .filters = &.{"train launch bounds:"} })).step);
b.step("test-tp-id-host", "Bounded NCCL-ID TP fanout and independent wire controls without devices").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = cuda, .filters = &.{"tp id coverage:"} })).step);
@import("cuda_readback_host.zig").tests(b, cuda, step);
const runtime_host = b.step("test-runtime-host", "Shared CUDA runtime and graph host regressions");
runtime_host.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = cuda })).step);
const mods = family(b, host, .ReleaseSafe, cuda, draft_ids);
Expand Down
65 changes: 65 additions & 0 deletions zig/build/cuda_readback_host.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//! Runs every actual synchronous readback expression on a recording host driver.
const std = @import("std");
const cases = @import("cuda_readback_sites.zig");

pub fn tests(b: *std.Build, cuda: *std.Build.Module, all: *std.Build.Step) void {
var code: std.ArrayList(u8) = .empty;
code.appendSlice(b.allocator,
\\const std = @import("std");
\\const cuda = @import("cuda");
\\const Fake = @import("fake").Fake;
\\
) catch @panic("out of memory");
for (cases.sites) |site| {
for ([_]bool{ true, false }) |integrated| {
var expected: usize = 0;
for (cases.sites) |other| if (std.mem.eql(u8, other.path, site.path)) {
expected += 1;
};
const expression = readback(site.source, site.ordinal, expected);
const body = b.fmt(
\\test "staged copy: {s}:{d} {s}" {{
\\ const integrated = {};
\\ {{
\\ var rig = Fake.init(integrated);
\\ defer rig.deinit();
\\ {s}
\\ const read_at = {s};
\\ const read_bytes = {s};
\\ @memset(read_bytes, 0xaa);
\\ try {s};
\\ try rig.check(read_at, read_bytes);
\\ }}
\\}}
\\
, .{ site.path, site.ordinal, if (integrated) "integrated" else "discrete", integrated, site.setup, site.at, site.out, expression });
code.appendSlice(b.allocator, body) catch @panic("out of memory");
}
}
const fake = b.createModule(.{ .root_source_file = b.path("zig/tests/cuda/staged_copy_fake.zig"), .target = b.graph.host, .link_libc = true, .imports = &.{.{ .name = "cuda", .module = cuda }} });
const root = b.createModule(.{ .root_source_file = b.addWriteFiles().add("staged_copy_sites.zig", code.items), .target = b.graph.host, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = cuda }, .{ .name = "fake", .module = fake } } });
const run = b.addRunArtifact(b.addTest(.{ .root_module = root }));
const step = b.step("test-staged-copies-host", "Every synchronous readback site on integrated and discrete fake drivers");
step.dependOn(&run.step);
const lifetime = b.addRunArtifact(b.addTest(.{ .root_module = cuda, .filters = &.{ "an unowned device span", "an empty unowned readback", "closing a driver drops" } }));
step.dependOn(&lifetime.step);
all.dependOn(&run.step);
}

fn readback(source: []const u8, ordinal: usize, expected: usize) []const u8 {
var chosen: ?[]const u8 = null;
var lines = std.mem.splitScalar(u8, source, '\n');
var count: usize = 0;
while (lines.next()) |raw| {
if (std.mem.indexOf(u8, raw, "cuMemcpyDtoH_v2(") == null and
std.mem.indexOf(u8, raw, "cuda.memory.download(") == null) continue;
count += 1;
if (count != ordinal) continue;
var line = std.mem.trim(u8, raw, " \t;");
if (std.mem.indexOf(u8, line, "try ")) |at| line = line[at + 4 ..];
if (std.mem.indexOf(u8, line, " catch ")) |at| line = line[0..at];
chosen = line;
}
if (count != expected) @panic("readback source changed without updating its cases");
return chosen orelse @panic("readback case no longer has a source expression");
}
Loading
Loading