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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel
- Qwen3.8-27B on Metal: the startup line reports how many admitted streams DFlash2 can draft for, using `TF_Q27_DRAFT_SLOTS` and the loaded drafter (#2526). Thanks to MrV for the report.

- Tests: the Qwen4 and Dory RoPE word-table host tests print their tables only when a comparison fails, naming the first wrong word; a passing run writes nothing to stderr (#2519, refs #1852).
- Tests: thirteen host checks that no CI job ran build and pass again on main (`test-cluster-loader-host`, `test-exl3-prompt-host`, `test-gemma4-affine-host`, `test-gradient-serving`, `test-metal-residency-owners-host`, `test-qwen-serving-host`, `test-qwen27-prompt-rows-host`, `test-qwen35-draft-frame-host`, `test-qwen35-draft-trees-host`, `test-qwen35-frame-invalidation-host`, `test-qwen35-live-host`, `test-qwen35-shared-host` and `compile-qwen35-rounds-host`). Their fixtures and build wiring follow the engine's current imports and fields. The prompt-rows and shared-cache tests expect blank values as unset, #2527's floor message and the overlaid log and before block. The source pins take main's reviewed bytes, each naming its commit. No engine code changes (#2550).

- Nemotron on Macs: a non-finite value in a masked key no longer reaches prompt attention's output; finite prompts run the same kernels as before, and prefill is level (#2322, part of #1009).

Expand Down
2 changes: 1 addition & 1 deletion zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
const cuda_target = b.resolveTargetQuery(.{ .cpu_arch = host.result.cpu.arch, .os_tag = .linux, .abi = .gnu });
const check_cuda = runtime(b, cuda_target, .debug, &.{});
const check_mods = family(b, cuda_target, .debug, check_cuda, draft_ids);
@import("cuda_census.zig").steps(b, cuda_target, check_cuda, check_mods.qwen35, check_mods.core, flashnextModule(b, cuda_target, .debug, check_cuda, check_mods.core, check_mods.lanes, check_mods.qwen_vision, check_mods.api));
@import("cuda_census.zig").steps(b, cuda_target, check_cuda, check_mods.qwen35, check_mods.core, check_mods.lanes, flashnextModule(b, cuda_target, .debug, check_cuda, check_mods.core, check_mods.lanes, check_mods.qwen_vision, check_mods.api));
const compile_bolt = b.addObject(.{ .name = "bolt_host_compile", .root_module = b.createModule(.{
.root_source_file = b.path("zig/tests/bolt_compile.zig"),
.target = cuda_target,
Expand Down
4 changes: 2 additions & 2 deletions zig/build/cuda_census.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! The Linux compile census: the real checkers compiled for Linux, without images or execution.
const std = @import("std");

pub fn steps(b: *std.Build, cuda_target: std.Build.ResolvedTarget, check_cuda: *std.Build.Module, qwen35: *std.Build.Module, core: *std.Build.Module, flashnext: *std.Build.Module) void {
const rounds_tool = b.createModule(.{ .root_source_file = b.path("zig/tests/qwen35_cuda_main.zig"), .target = cuda_target, .optimize = .debug, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = check_cuda }, .{ .name = "qwen35", .module = qwen35 }, .{ .name = "core", .module = core } } });
pub fn steps(b: *std.Build, cuda_target: std.Build.ResolvedTarget, check_cuda: *std.Build.Module, qwen35: *std.Build.Module, core: *std.Build.Module, lanes: *std.Build.Module, flashnext: *std.Build.Module) void {
const rounds_tool = b.createModule(.{ .root_source_file = b.path("zig/tests/qwen35_cuda_main.zig"), .target = cuda_target, .optimize = .debug, .link_libc = true, .imports = &.{ .{ .name = "cuda", .module = check_cuda }, .{ .name = "qwen35", .module = qwen35 }, .{ .name = "core", .module = core }, .{ .name = "lanes", .module = lanes } } });
const rounds_compile = b.addObject(.{ .name = "qwen35-rounds-checker-compile", .root_module = b.createModule(.{ .root_source_file = b.path("zig/qwen35_rounds_compile.zig"), .target = cuda_target, .link_libc = true, .imports = &.{.{ .name = "tool", .module = rounds_tool }} }) });
_ = rounds_compile.getEmittedBin();
b.step("compile-qwen35-rounds-host", "Compile the real CUDA 64-row checker for Linux, no images or execution").dependOn(&rounds_compile.step);
Expand Down
3 changes: 2 additions & 1 deletion zig/build/safetensors_header_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ pub fn steps(b: *std.Build, core: *std.Build.Module, all: *std.Build.Step) void
const checkpoint_run = b.addRunArtifact(b.addTest(.{ .root_module = checkpoint }));
b.step("test-cluster-checkpoint-host", "Cluster metadata and range controls without shaders").dependOn(&checkpoint_run.step);
all.dependOn(&checkpoint_run.step);
const loader = b.createModule(.{ .root_source_file = b.path("zig/src/cluster/loader_test.zig"), .target = b.graph.host, .link_libc = true, .imports = &.{.{ .name = "core", .module = core }} });
const canon = @import("cuda_engines.zig").canonModule(b, b.graph.host, .debug);
const loader = b.createModule(.{ .root_source_file = b.path("zig/src/cluster/loader_test.zig"), .target = b.graph.host, .link_libc = true, .imports = &.{ .{ .name = "core", .module = core }, .{ .name = "canon", .module = canon } } });
b.step("test-cluster-loader-host", "Cluster local-file and fake-peer loading without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = loader })).step);
// the tower's reader opens and preads through libc's POSIX calls: not Windows
if (b.graph.host.result.os.tag != .windows) {
Expand Down
9 changes: 6 additions & 3 deletions zig/dense_serving_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ test "dense serving: owned CUDA images retain their reviewed lane and decode byt
try std.testing.expectEqualStrings("5f325dc6d8134624b30b5e99c5764f75beb3c344b5f949d38bfaa41bc8dfe5dc", &hash(@embedFile("kernels/cuda/experts_prefill.cu")));
try std.testing.expectEqualStrings("a9caeec5b270dcab933a5eae0f500d7aabcd31cde156238225ae064ac92ba2e8", &hash(@embedFile("kernels/cuda/gdn.cu")));
try std.testing.expectEqualStrings("dba5aae94115571ed48933d80f646fff31b2a7da226569867c74a1dc061d2ca2", &hash(@embedFile("kernels/cuda/lane_gemv.cu")));
try std.testing.expectEqualStrings("eca5e090022a25bf9b945750b42c1b77652f093ec3cc96d1797c94b96a23358e", &hash(@embedFile("kernels/cuda/prefill_attention.cu")));
// 94a9a48d6's bytes: 82f3dde92 adds pattn_kernel<64, 8, 4, 8>, 94a9a48d6 moves helpers out (#1492, SASS unchanged)
try std.testing.expectEqualStrings("a52da014495e328d10258191cbd51dd19dc77c1c019e037274e0e2387b24be01", &hash(@embedFile("kernels/cuda/prefill_attention.cu")));
const group = @embedFile("kernels/cuda/qmm_group.cu");
try std.testing.expectEqualStrings("ceff4ee13e97b5aa93cbe7a1edc9a524c78aaa145dd1e5c82dcb05a3011aae23", &hash(group[0..16095]));
try std.testing.expectEqualStrings("8780fd710be3ce2f04e53fa1e69eb062809d3bec6391d9bd49983d0588e374d0", &hash(group));
try std.testing.expectEqualStrings("45ab2be277c7c17e6cdc6041db45611f2554c6e88f09a295e88751b1c51be1f5", &hash(@embedFile("kernels/cuda/qmm_prefill.cu")));
try std.testing.expectEqualStrings("9f39fae379e506dffe7047925a5d13b57041d623be9d36fac25efba5487b7f10", &hash(@embedFile("kernels/cuda/qwen35.cu")));
// 01b45cd1d's bytes: tf_q35_norm_shift and tf_q35_head_norm_shift for BF16 checkpoints, under the contract (#2383)
try std.testing.expectEqualStrings("7438579264a99fd0ea99ac242afc68015c8b13a8cd3f10c43b93644376b87205", &hash(@embedFile("kernels/cuda/qwen35.cu")));
try std.testing.expectEqualStrings("7d916f0bb75d636ed15d8f30a7108cf05a6c5a833bd76beb8b627e6567a641db", &hash(@embedFile("kernels/cuda/qwen35.cuh")));
try std.testing.expectEqualStrings("acfa75d58a121eb389a69eb1f317a8a6b8ddc3adf7489ff295d7de42099ae70e", &hash(@embedFile("kernels/cuda/qwen35_draft.cu")));
try std.testing.expectEqualStrings("403cf841b89ad61da0818bdad8976ed4b286b3282c8c22df7171921b7e06eb6d", &hash(@embedFile("kernels/cuda/qwen35_keep.cu")));
Expand All @@ -39,5 +41,6 @@ test "dense serving: owned launches and projections retain their reviewed argume
try out.append(std.testing.allocator, c);
};
}
try std.testing.expectEqualStrings("265a34f9f0ae6d4e0d16f636b386e108cba10315918a26697622070c5aed2a83", &hash(out.items));
// 01b45cd1d's sequence: a BF16 checkpoint's norms take the norm_shift kernels, 1 + w in FP32 (#2383)
try std.testing.expectEqualStrings("d21cd8152c545d85a55547d15f633f090dffaabab1223afd885a07c01814154a", &hash(out.items));
}
2 changes: 1 addition & 1 deletion zig/exl3_prompt_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn run(rows: usize, prompt: bool, shared: bool) !void {
const s: cuda.Stream = .{ .d = &d, .handle = null };
var k: ex.Experts = .{ .mod = undefined, .group = function(&d, 1), .rot_in = function(&d, 2), .grouped = @splat(function(&d, 3)), .gateup = function(&d, 4), .down_combine = function(&d, 5) };
if (comptime @hasField(ex.Experts, "prompt")) k.prompt = .{ .rotate = function(&d, 11), .gateup = function(&d, 12), .down = function(&d, 13) };
const ek: glm.experts.Kernels = .{ .nvfp4 = undefined, .router = .{ .plan_small = function(&d, 20), .plan_rank = function(&d, 21), .plan_offsets = function(&d, 22), .plan_scatter = function(&d, 23), .plan_rows = function(&d, 24), .plan_rank_rows = function(&d, 25), .plan_scatter_rows = function(&d, 26) } };
const ek: glm.experts.Kernels = .{ .nvfp4 = undefined, .b32 = null, .router = .{ .plan_small = function(&d, 20), .plan_rank = function(&d, 21), .plan_offsets = function(&d, 22), .plan_scatter = function(&d, 23), .plan_rows = function(&d, 24), .plan_rank_rows = function(&d, 25), .plan_scatter_rows = function(&d, 26) } };
const w: glm.exl3.Experts = .{ .gt = 100, .ut = 200, .dt = 300, .k2 = 400, .suh_g = 500, .suh_u = 600, .svh_g = 700, .svh_u = 800, .suh_d = 900, .svh_d = 1000, .shx = shared };
const sc: glm.exl3.Scratch = .{ .picks = 0x100000000, .xg = 0, .xu = 0, .z = 0 };
const plan: cuda.grouped.Plan = .{ .items = 10000, .members = 20000, .counts = 30000, .rank = 40000, .hist = 50000 };
Expand Down
6 changes: 4 additions & 2 deletions zig/gemma4_shared_affine_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ test "landed Metal source bytes are pinned without shader compilation" {
{
var hash: [32]u8 = undefined;
std.crypto.hash.sha2.Sha256.hash(ks.core_affine_mm, &hash, .{});
try std.testing.expectEqualStrings("a91a353981c4e24142673ab9c97e9a449b973751bd5df7ad7c980757046cf61e", &std.fmt.bytesToHex(hash, .lower));
// dda89ef49's bytes: 47afc1620..dda89ef49 reworded comments only, after cf10a6b7d's pinned edit
try std.testing.expectEqualStrings("c959eb1f5ac8a57049c09b3aad5d20f26b64f2e47d8b082c47ebbfae90d97a8b", &std.fmt.bytesToHex(hash, .lower));
}
{
var hash: [32]u8 = undefined;
std.crypto.hash.sha2.Sha256.hash(ks.core_lane_projection, &hash, .{});
try std.testing.expectEqualStrings("d96f3c86926177d9fe6df6c82beea7e4f379b16654aa835200d50afe182f3c99", &std.fmt.bytesToHex(hash, .lower));
// 66155d5ee's bytes (8-bit lane codes and producer sums, Refs #2502, under the metal_lane_q8 contract)
try std.testing.expectEqualStrings("159f39224b5bb60fd2ced301496d91662d2958056bd291d13d8a5db5186dd41a", &std.fmt.bytesToHex(hash, .lower));
}
}
test "released lane parameters and conservative scratch size" {
Expand Down
3 changes: 2 additions & 1 deletion zig/qwen35_draft_equality.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Head = struct {
h.d.w.successor = &h.book;
h.d.staged = .{ .d = undefined, .bytes = &h.storage };
if (own_trees) h.d.c.block = 16;
h.d.tree_nodes = try q.draft.tree.nodes(); // as Draft.init reads it
h.d.gpa = a;
h.d.streams = .empty;
h.d.landing = .{};
Expand Down Expand Up @@ -137,7 +138,7 @@ const Head = struct {
// a grown tree takes the drafter's whole node budget; the engine admits its first nodes
if (own_trees) for (contexts[0..items.len]) |ctx| {
try std.testing.expect(ctx.grown > 0);
try std.testing.expect(ctx.grown <= q.draft.tree.nodes());
try std.testing.expect(ctx.grown <= try q.draft.tree.nodes());
};
}
fn held(p: *anyopaque, streams: []const *lanes.Stream, outs: []const []u32) !void {
Expand Down
3 changes: 2 additions & 1 deletion zig/qwen35_draft_frame_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ fn actualFrame(block: usize) !void {
d.e = &e;
d.c = config();
d.c.block = block;
d.tree_nodes = try q.draft.tree.nodes(); // as Draft.init reads it
d.streams = .empty;
defer d.streams.deinit(a);
d.selection_base = 0;
Expand Down Expand Up @@ -235,7 +236,7 @@ fn actualFrame(block: usize) !void {
try std.testing.expectEqual(@as(usize, 1), Record.waits);
for (contexts[0..count], holds[0..count], 0..) |ctx, it, i| {
// the production adapter: a grown tree holds the budget it grew, a chain the requested depth
const limit = if (block == 16) q.draft.tree.nodes() else 0;
const limit = if (block == 16) try q.draft.tree.nodes() else 0;
const held: usize = if (it.lanes != null) 7 else if (limit > 0) ctx.grown else @min(it.depth, block - 1);
try std.testing.expectEqual(held, ctx.held_n);
if (limit > 0 and it.lanes == null and it.depth > 0) try std.testing.expect(ctx.grown > 0);
Expand Down
1 change: 1 addition & 0 deletions zig/qwen35_live_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ test "served scratch: one drafter frame does not allocate 128 streams of logits
d.target_taps = 111411200;
d.step_ms = 1;
d.n_costs = 0;
d.tree_nodes = try q.draft.tree.nodes(); // as Draft.init reads it
try std.testing.expectEqual(d.c.ringBytes() + d.target_taps + d.scratch_one, d.drafter().facts().stream_bytes);
const one = try d.layout(false);
try std.testing.expectEqual(@as(usize, 23667968), one);
Expand Down
15 changes: 12 additions & 3 deletions zig/qwen35_shared_host.zig
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ test "Shared verification: empty multi-row keep preserves the root and completed
cache.advanced(128, false);
try std.testing.expect(cache.last == null);
try std.testing.expectEqual(@as(usize, 136), cache.len);
try std.testing.expectEqual(@as(usize, 2) * e.g.stateBytes() + e.g.kvBytes(256, false) + e.g.logBytes(64) + q.cache.pendBytes(e.g), e.streamBytes(256));
// the before copy sits inside the log's bytes (one overlaid block), so a stream holds one state beside it
const block = q.cache.overlay(&e);
try std.testing.expectEqual(e.g.logBytes(64), block.bytes);
try std.testing.expectEqual(e.g.stateBytes() + block.bytes + e.g.kvBytes(256, false) + q.cache.pendBytes(e.g), e.streamBytes(256));
}

const Owners = struct {
Expand Down Expand Up @@ -186,7 +189,8 @@ test "Shared verification: the actual cache constructor unwinds the before bank
e.n_taps = 1;
e.g.layers = 2;
e.g.linear[1] = false;
for (1..6) |fail| {
// kv, state, the overlaid log and before block, and the tap ring: four device allocations
for (1..5) |fail| {
Owners.setup(&d, fail, 0);
try std.testing.expectError(error.NotReady, q.engine.Cache.init(a, &e, 256));
try Owners.balanced();
Expand All @@ -203,7 +207,12 @@ test "Shared verification: the actual cache constructor unwinds the before bank
Owners.setup(&d, 0, 0);
var cache = try q.engine.Cache.init(a, &e, 256);
try std.testing.expect(cache.before != null);
try std.testing.expectEqual(@as(usize, 5), Owners.allocations);
try std.testing.expectEqual(@as(usize, 4), Owners.allocations);
const block = cache.block.?;
try std.testing.expect(cache.before.?.borrowed and cache.log.borrowed);
try std.testing.expectEqual(block.ptr, cache.log.ptr);
try std.testing.expectEqual(block.ptr + q.cache.overlay(&e).before_at, cache.before.?.ptr);
try std.testing.expect(cache.before.?.ptr + cache.before.?.len <= block.ptr + block.len);
cache.deinit(a);
try Owners.balanced();
}
3 changes: 3 additions & 0 deletions zig/residency_owner_tests.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub const qwen_vl = @import("src/core/qwen_vl/qwen_vl.zig");
pub const tree_round = @import("tree_round");
pub const tree_commit_gpu = @import("tree_commit_gpu");
pub const bf16_topk = @import("bf16_topk");
/// The core pool and its Metal pages, which qwen27/kv_pages.zig reads through core.
pub const kv_pool = @import("src/core/kv_pool.zig");
pub const metal_kv_pages = @import("src/core/metal_kv_pages.zig");
const a = std.testing.allocator;

test "residency owner GLM: actual arena slots tower and snapshots match live unique allocations" {
Expand Down
18 changes: 14 additions & 4 deletions zig/src/qwen27_rows_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ test "qwen27 rows: a below-floor setting refuses before the loader with its valu
var why: []const u8 = "";
try std.testing.expectError(error.PromptRowsTooSmall, loader.open(value, &why));
defer a.free(why);
try std.testing.expect(std.mem.indexOf(u8, why, "TF_PROMPT_ROWS=") != null);
try std.testing.expect(std.mem.indexOf(u8, why, value) != null);
try std.testing.expect(std.mem.indexOf(u8, why, "multiple of 16 from 128 to 2048") != null);
try std.testing.expect(std.mem.indexOf(u8, why, "at least 128 prompt rows") != null);
const origin = try std.fmt.allocPrint(a, "TF_PROMPT_ROWS supplied {s}.", .{value});
defer a.free(origin);
try std.testing.expect(std.mem.indexOf(u8, why, origin) != null);
try std.testing.expect(std.mem.indexOf(u8, why, "unset it to use the device default") != null);
}
try std.testing.expectEqual(@as(usize, 0), loader.calls);
}
Expand All @@ -114,7 +116,7 @@ test "qwen27 rows: a caller-created narrow frame names frame capacity rather tha

test "qwen27 rows: malformed and over-cap native settings refuse before loading" {
var loader: Load = .{};
for ([_][]const u8{ "", "no", " 512", "129", "2049", "4096", "4294967296" }) |value| {
for ([_][]const u8{ "no", " 512", "129", "2049", "4096", "4294967296" }) |value| {
var why: []const u8 = "";
try std.testing.expectError(error.InvalidEnvironment, loader.open(value, &why));
defer a.free(why);
Expand All @@ -123,3 +125,11 @@ test "qwen27 rows: malformed and over-cap native settings refuse before loading"
}
try std.testing.expectEqual(@as(usize, 0), loader.calls);
}

test "qwen27 rows: empty or whitespace-only settings are unset and reach the loader" {
var loader: Load = .{};
var why: []const u8 = "unchanged";
for ([_][]const u8{ "", " ", "\t\n" }) |value| try loader.open(value, &why);
try std.testing.expectEqual(@as(usize, 3), loader.calls);
try std.testing.expectEqualStrings("unchanged", why);
}
Loading
Loading