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
5 changes: 3 additions & 2 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

- Shared draft rounds price each stream's drafts before drafting, and a stream whose drafts would get no verify rows skips the drafter's proposal work, for Nemotron, Qwen's MTP, GLM, Gemma 4 (assistant and DFlash) and attached LFM2 drafters, on CUDA and Metal; each family keeps its head step's cost in the price. Replies are unchanged. Nemotron 3.5 Lightning with its MTP head: on an M5 Ultra, 16-stream chat +9.0% greedy and +4.7% sampled; on a GB10, 16 streams +2.1% and 8 streams +1.1%.

- MOSS-Image's image decoder (the checkpoint's FLUX.2 small VAE, in float32 as the pipeline runs it) runs on Metal inside the `moss_image` family, and `tf-moss-image` writes `picture.png` itself, so torch no longer decodes (#1687, #1504). Thanks to @BobClawblaw.

- On CUDA, a driver older than CUDA 13.0 is refused at startup with a plain message naming the driver to install (R580 or newer), before any kernel loads; an R550 driver had ended the process with SIGILL inside libcuda on the first module load (#1791, #1724). Thanks to @rootsbymenda.
Expand All @@ -24,8 +26,6 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- Qwen3.6-35B-A3B on CUDA: `--drafter` also takes a DFlash2 draft model, chosen by the `dflash_config` in its `config.json`; the checkpoint's own directory still drafts with its MTP layer. With `incoai/Qwen3.6-35B-A3B-DFlash2` over `nvidia/Qwen3.6-35B-A3B-NVFP4`, one GB10 decodes 130 tok/s at one stream on a 4.2K-token prompt (MTP: 99), and every drafted reply equals its plain run (#1674).



- A fresh-start session disk now clears the `.tfs` and `.tmp` files earlier serving processes left behind, under an exclusive lock on its directory, so restarts no longer fill the disk (#1680). Ported by @jayleaton from @mikolaj92's downstream fix, corroborated by @Jenpo.

- GLM-5.3-Flash on CUDA: `TF_GLM_KV_SHARE=n` with `TF_KV_PAGES=on` keeps prompts as the KV pool's pages in the shared prompt store (the one `TF_QWEN_KV_SHARE` uses), with at most n states past them, on one GPU and at tensor parallel. Where main's flat store has no room for a long state (GB10s at TP=3 with the 1M window), a 64k message sent again resumes in about 1.7 s instead of prefilling for 36 s; token-id prompts resume at every width (#1732, #1510). Unset, nothing changes.
Expand Down Expand Up @@ -68,6 +68,7 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

- Flash Next's MTP head norms its 10,240-value rows with tiled launches on CUDA sm_120 and sm_121 and split wave launches on HIP gfx1201, storing the same bytes as before: the norm kernel runs 1.4x to 2.5x faster on a GB10 and 4x to 5x on a Radeon AI PRO R9700 at 1 to 16 rows (#1702, fixes #1689). Thanks to @laudney.


## 1.2.0

- CUDA EXL3: the dense projections zero their split-K counters only when the buffer grows, on the calls' stream, instead of before every 128-row block of every call; each block's last program already resets its own counter. Replies are token-identical, and on a GB10 with the Qwen3.8-27B 3.50 bpw pack decode is 0.4% to 0.9% faster (#1475). Thanks to @diwakergupta.
Expand Down
1 change: 1 addition & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub fn build(b: *std.Build) void {
const budget_empty = b.addWriteFiles().add("budget-compile-only.metallib", "");
budget_mods.sources.addImport("nemotron_packed_metallib", embedded(b, budget_empty, "nemotron_packed.metallib"));
@import("zig/build/fsr.zig").deviceSteps(b, budget_mods.metal, budget_mods.engine, budget_mods.sources);
b.step("test-shared-head-cost-metal-host", "Metal family head-cost grants without device execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = budget_mods.engine, .filters = &.{"shared head costs:"} })).step);
@import("zig/build/flashnext_budget.zig").compileHost(b, budget_mods.metal, budget_mods.engine, budget_mods.lanes);
@import("zig/build/residency_host.zig").compileHost(b, budget_mods.metal, budget_mods.engine, budget_mods.lanes);
}
Expand Down
11 changes: 10 additions & 1 deletion zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
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, .debug, cuda, draft_ids);
const skip_drafts = b.step("test-drafter-skip-cuda-host", "Counted shared draft skips without devices");
for ([_]*std.Build.Module{ mods.nemotron, mods.qwen35, flashnextModule(b, host, .debug, cuda, mods.core, mods.lanes, mods.qwen_vision, mods.api) }) |m| skip_drafts.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m, .filters = &.{"zero grant:"} })).step);
@import("qwen_contract.zig").host(b, mods.core, step);
@import("qwen_vision_weights_host.zig").host(b, mods.core, step);
@import("inc4_host.zig").round(b, cuda, mods.core);
Expand Down Expand Up @@ -324,6 +326,8 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
}
const drama3 = @import("drama3_host.zig").hostTests(b, step, cuda, mods.core);
const native_modules = engines(b, host, .debug, cuda, mods.core, mods.lanes, mods.nemotron, mods.heat, mods.qwen35, mods.qwen_vision);
b.step("test-qwen-grants-host", "Qwen MTP head-cost and copy grants without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.qwen35, .filters = &.{"shared head costs:"} })).step);
b.step("test-nemotron-grants-host", "Nemotron shared head-cost and copy grants without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mods.nemotron, .filters = &.{"Nemotron shared prices:"} })).step);
@import("rows_host.zig").tests(b, native_modules.api, step);
const native = native_modules.engines;
b.step("test-draft-cuda-host", "CUDA draft source metadata without devices").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = native, .filters = &.{"draft sources:"} })).step);
Expand Down Expand Up @@ -452,9 +456,14 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
const attn_ref = b.createModule(.{ .root_source_file = b.path("zig/tests/cuda/contract_attn.zig"), .target = host, .optimize = .debug, .imports = &.{.{ .name = "core", .module = mods.core }} });
step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = attn_ref })).step);
const glm = glmCuda(b, host, .debug, cuda, mods.core, mods.lanes, mods.heat, mods.api);
b.step("test-glm-grants-host", "GLM CUDA head-cost policy without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = glm, .filters = &.{"shared head costs:"} })).step);
skip_drafts.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = glm, .filters = &.{"zero grant:"} })).step);
@import("glm_family_host.zig").steps(b, cuda, glm, mods, step);
@import("kolibri.zig").host(b, kolibri1Module(b, host, .debug, cuda, mods.core, mods.lanes), native_modules.api, step);
@import("gemma4_cuda.zig").host(b, @import("gemma4_cuda.zig").module(b, host, .debug, cuda, mods.core, mods.lanes), step);
const gemma = @import("gemma4_cuda.zig").module(b, host, .debug, cuda, mods.core, mods.lanes);
b.step("test-gemma-grants-host", "Gemma assistant and DFlash head-cost grants without a GPU").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = gemma, .filters = &.{"shared head costs:"} })).step);
@import("gemma4_cuda.zig").host(b, gemma, step);
skip_drafts.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = gemma, .filters = &.{"zero grant:"} })).step);
@import("spark25.zig").host(b, @import("spark25.zig").module(b, host, .debug, cuda, mods.core, mods.lanes), step);
@import("glm_contracts.zig").tests(b, glm, mods.lanes, cuda, mods.core);
// the shares a GLM-5.3-Flash rank takes (cluster/canon.zig against the Python family's)
Expand Down
1 change: 1 addition & 0 deletions zig/build/metal_targets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub fn nativeServer(b: *std.Build, target: std.Build.ResolvedTarget, optimize: s
golden_build.step(b, target, server_tests, api, tokenizer, template, engines);
engines.addImport("lanes", api.import_table.get("lanes").?);
b.step("test-draft-metal-host", "Metal draft source metadata without devices").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = engines, .filters = &.{"draft sources:"} })).step);
b.step("test-drafter-skip-metal-host", "Counted shared draft skips without device execution").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = engine, .filters = &.{"zero grant:"} })).step);
b.step("test-native", "The Metal engines module's host-side tests").dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = engines })).step);
const reuse = b.addExecutable(.{ .name = "tf-flashnext-reuse", .root_module = b.createModule(.{
.root_source_file = b.path("zig/tests/flashnext_reuse.zig"),
Expand Down
3 changes: 3 additions & 0 deletions zig/src/core/lanes/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub const default_prior = [_]f64{ 0.85, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.5, 0.
/// What a backend reports about its loaded model: the attributes the Python engine reads at setup.
pub const Model = struct {
allocate_shared_drafts: bool = false, // reserve useful shared head rows before a proposal pass
limit_shared_drafts: bool = false, // retain the cost rule's depth cap before reserving shared rows
root_copies: bool = false, // verified context copies precede head drafts and skip their proposal pass
copy_drafts: bool = true, // global serving switch, independent of shared verification capacity
own_copy_rates: bool = false, // a copy window is priced by its stream's own copies, not copy_rate's prior
Expand Down Expand Up @@ -52,6 +53,7 @@ pub const Model = struct {

pub const Config = struct {
allocate_shared_drafts: bool = false, // reserve useful shared head rows before a proposal pass
limit_shared_drafts: bool = false, // retain the cost rule's depth cap before reserving shared rows
root_copies: bool = false,
family_width: u32,
max_copy: u32,
Expand Down Expand Up @@ -132,6 +134,7 @@ pub const Config = struct {
errdefer gpa.free(depth_prior);
return .{
.allocate_shared_drafts = m.allocate_shared_drafts,
.limit_shared_drafts = m.limit_shared_drafts,
.root_copies = m.root_copies and m.copy_drafts,
.context_copies = m.context_copies and m.copy_drafts,
.enter_match = @max(1, m.copy_match),
Expand Down
7 changes: 5 additions & 2 deletions zig/src/core/lanes/drafted.zig
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub const Drafted = struct {
m.mtp = true;
m.speculate = true;
m.speculate_early = false;
m.allocate_shared_drafts = true;
m.drafts = @min(d.depth, if (target.exact_width > 1) target.exact_width - 1 else 0);
m.mtp_step_ms = d.step_ms;
m.draft_prior = d.prior;
Expand All @@ -111,6 +112,8 @@ pub const Drafted = struct {
m.draft_probabilities = x.drafter.vtable.chances != null;
m.head_trees = false;
}
m.limit_shared_drafts = (target.limit_shared_drafts or d.limit_shared_drafts) and
!m.draft_probabilities and m.draft_confidence == null;
if (d.copy_match > 0) m.copy_match = d.copy_match;
if (d.window_costs.len > 0) m.window_costs = d.window_costs;
if (d.lane_costs.len > 0) m.lane_costs = d.lane_costs;
Expand Down Expand Up @@ -286,7 +289,7 @@ pub const Drafted = struct {
for (rows, 0..) |row, i| prefix = prefix and row == i;
const n: u32 = @intCast(if (prefix) rows.len else rows[rows.len - 1] + 1);
const f = try x.target.features(r.stream, x.drafter.taps(), r.start, n);
try x.absorbs.append(x.gpa, .{ .stream = r.stream, .features = f, .start = r.start, .follow = r.follow[0..rows.len], .rows = if (prefix) null else rows, .prompt = false, .offered = lane.offered });
try x.absorbs.append(x.gpa, .{ .stream = r.stream, .features = f, .start = r.start, .follow = r.follow[0..rows.len], .rows = if (prefix) null else rows, .prompt = false, .propose = r.depth > 0, .offered = lane.offered });
lane.offered = 0;
pending = r.follow[rows.len - 1];
lane.rows = true;
Expand All @@ -300,7 +303,7 @@ pub const Drafted = struct {
const last = r.stream.prompt_len - 1;
if (r.stream.cached <= last) { // the pass computed the prompt's last row (not restored whole)
const f = try x.target.features(r.stream, x.drafter.taps(), last, 1);
try x.absorbs.append(x.gpa, .{ .stream = r.stream, .features = f, .start = last, .follow = @as(*const [1]u32, tok) });
try x.absorbs.append(x.gpa, .{ .stream = r.stream, .features = f, .start = last, .follow = @as(*const [1]u32, tok), .propose = r.depth > 0 });
lane.rows = true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions zig/src/core/lanes/drafted_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub const FakeDrafter = struct {
facts_: dr.Facts = .{ .depth = 6, .step_ms = 0.5 },
opens: u32 = 0,
absorbs: u32 = 0,
proposed_absorbs: u32 = 0,
holds: u32 = 0,
helds: u32 = 0,
releases: u32 = 0,
Expand Down Expand Up @@ -79,6 +80,7 @@ pub const FakeDrafter = struct {
x.absorbs += 1;
if (x.fail == .absorb) return error.Injected;
for (items) |it| {
if (it.propose) x.proposed_absorbs += 1;
const l = x.lanes.getPtr(it.stream) orelse return error.UnknownStream;
const f = it.features;
if (f.space != .host or f.dtype != .u32 or f.row_bytes != 4 or it.follow.len != f.rows or f.ready != .none) return error.Shape;
Expand Down
2 changes: 2 additions & 0 deletions zig/src/core/lanes/drafter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Allocator = @import("std").mem.Allocator;

/// What the round loop's depth rule needs from the drafter itself (not from the target, whose own head may not exist).
pub const Facts = struct {
limit_shared_drafts: bool = false, // retain the depth rule's head-step price before reserving shared rows
depth: u32, // drafts a round at most
step_ms: f64, // one more draft's cost (timed at load); the rule prices a round as forward(rows) + step_ms x drafts
prior: []const f64 = &.{}, // acceptance by depth until a stream has its own
Expand All @@ -29,6 +30,7 @@ pub const Absorb = struct {
follow: []const u32,
rows: ?[]const u32 = null,
prompt: bool = true, // prompt ingestion keeps its historical arithmetic; accepted live rows set false
propose: bool = true, // false: retain committed context without computing unused proposal outputs
offered: u32 = 0, // the drafter's grown tree's first nodes the verified window carried (0: none of its own)
};

Expand Down
3 changes: 3 additions & 0 deletions zig/src/core/lanes/lanes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ pub const backend = @import("backend.zig");
pub const embedding = @import("embedding.zig");
pub const events = @import("events.zig");
pub const windows = @import("windows.zig");
pub const shared_drafts = @import("shared_drafts.zig");
pub const trail = @import("trail.zig");
pub const engine = @import("engine.zig");
pub const fake = @import("fake.zig");
pub const shared_head_cost_check = @import("shared_head_cost_check.zig");
pub const shared_draft_check = @import("shared_draft_check.zig");
pub const drafter = @import("drafter.zig");
pub const drafted = @import("drafted.zig");
pub const recorder = @import("recorder.zig");
Expand Down
Loading
Loading