Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
9f0d4c7
XPU backend: Qwen3.8-27B on Intel Arc Pro B70 (Xe2) over Level Zero
Mirrdhyn Oct 14, 2026
25ef56c
XPU: drop the Triton SPIR-V; streams sized from the device's free mem…
Mirrdhyn Oct 14, 2026
ba9193f
Add the Intel GPU (Level Zero) runtime and Nemotron 3.5 Lightning on …
BHCC2025 Oct 8, 2026
f8da783
Arc recipe: decode figures of the earlier decode attention measured o…
BHCC2025 Oct 9, 2026
0fdb2be
Arc recipe: prompt attention before and after measured with the CLI o…
BHCC2025 Oct 9, 2026
eb9a960
Arc: remove the debug and path switches, one admission rule, one-line…
BHCC2025 Oct 10, 2026
c936acf
xpu: Nemotron on the XPU backend's Level Zero table (ze.zig), not a s…
BHCC2025 Oct 15, 2026
5dc655b
xpu nemotron: windows take the decode step's arithmetic, a one-row wi…
BHCC2025 Oct 15, 2026
cd41379
xpu nemotron: prompt rows take the decode step's arithmetic, so a pro…
BHCC2025 Oct 15, 2026
ebb49f1
Nemotron on Intel Arc in the XPU server, beside Qwen3.8-27B
BHCC2025 Oct 15, 2026
d8b996c
xpu server: Nemotron's MTP head and copy drafts through the lane core…
BHCC2025 Oct 14, 2026
8aa5fc3
xpu server: a one-row round is the decode step itself
BHCC2025 Oct 15, 2026
9ec1385
xpu server: concurrent requests share rounds, each stream on its own …
BHCC2025 Oct 14, 2026
5375580
xpu server: the prompt cache, a resumed turn equal to a fresh prompt
BHCC2025 Oct 15, 2026
9674eb6
Arc recipe: drafts, concurrent streams and the prompt cache through t…
BHCC2025 Oct 15, 2026
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
Prev Previous commit
Next Next commit
xpu server: a one-row round is the decode step itself
Windows take the decode step's arithmetic (#523), so a one-row window and the decode step give the same bits: with the
MTP head loaded, a round of one row (no drafts held, or plain_guard) runs the decode step (5.54 ms) instead of a window
(6.47 ms), and plain replies keep the decode speed. The head reads the decode step's row through Model.normRow; the
measured window costs take the decode step as width 1.
  • Loading branch information
BHCC2025 committed Oct 15, 2026
commit 8aa5fc32a49c75a4ecc69c22b1f5caebaa701572
22 changes: 19 additions & 3 deletions zig/src/families/nemotron/xpu_engine.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub const Engine = struct {
/// The MTP head and the prompt's last normed row (its first draft reads it), when loaded.
head: ?mtp.Mtp = null,
last_h: ?xpu.rt.Buffer = null,
/// The last round was a decode step (stepRow): the head reads its row from the model's scratch, not the window's.
stepped: bool = false,

pub fn init(gpa: std.mem.Allocator, io: std.Io, ctx: *const xpu.Context, dir: []const u8, o: Options) !*Engine {
const t0 = std.Io.Clock.awake.now(io);
Expand Down Expand Up @@ -120,6 +122,7 @@ pub const Engine = struct {
/// The prompt in windows of `rows`, in place; the head absorbs all rows but the last (last_h, for draftFirst).
pub fn prefillHead(e: *Engine, prompt: []const u32, rows: u32) !void {
const mt = &e.head.?;
e.stepped = false;
var t: usize = 0;
while (t < prompt.len) {
try nw.stopCheck(&e.r);
Expand All @@ -141,9 +144,17 @@ pub const Engine = struct {
/// One window of ids at m.pos, not committed; every row gets logits (rowTokens / rowLogits).
pub fn verifyRows(e: *Engine, ids: []const u32) !void {
try nw.stopCheck(&e.r);
e.stepped = false;
try e.w.forward(&e.m, ids, false, @intCast(ids.len));
}

/// One token on the decode step, in place, with logits (argmax / fetchLogits): the bits of a one-row window.
pub fn stepRow(e: *Engine, token: u32) !void {
try nw.stopCheck(&e.r);
e.stepped = true;
try e.m.forward(token, true);
}

/// Greedy token of each row of the last window (syncs).
pub fn rowTokens(e: *Engine, out: []i32) !void {
try e.w.rowArgmax(&e.m, out);
Expand All @@ -162,7 +173,7 @@ pub const Engine = struct {
/// The head absorbs the kept rows of the last window (follow: the token after each) from `start`, then drafts.
pub fn draftKept(e: *Engine, follow: []const u32, start: u32, depth: u32, out: []u32) !usize {
const mt = &e.head.?;
try e.w.normRows(&e.m, @intCast(follow.len), mt.hn);
if (e.stepped) try e.m.normRow(mt.hn) else try e.w.normRows(&e.m, @intCast(follow.len), mt.hn);
const d = try mt.step(&e.w, &e.m, follow, mt.hn, start, depth > 0);
return e.chain(d, depth, out);
}
Expand Down Expand Up @@ -198,8 +209,13 @@ pub const Engine = struct {
for (ms, 1..) |*out, width| {
for (&runs) |*r| {
const t0 = nowNs();
try e.verifyRows(ids[0..width]);
try e.rowTokens(g[0..width]);
if (width == 1) { // a one-row round is the decode step (lane: stepRow)
try e.stepRow(ids[0]);
_ = try e.argmax();
} else {
try e.verifyRows(ids[0..width]);
try e.rowTokens(g[0..width]);
}
r.* = @as(f64, @floatFromInt(nowNs() - t0)) / 1e6;
}
out.* = median(&runs);
Expand Down
5 changes: 5 additions & 0 deletions zig/src/families/nemotron/xpu_model.zig
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,11 @@ pub const Model = struct {
m.pos += 1;
}

/// norm_f of the residual row the last decode step left (the MTP head's input row) into out [h].
pub fn normRow(m: *Model, out: Buf) !void {
try run(&m.k.rms, .{ 1, 1, 1 }, .{ m.s.x, m.norm_f, out, m.cfg.hidden_size, m.cfg.layer_norm_epsilon });
}

/// The greedy token of the last forward with logits (syncs).
pub fn argmax(m: *Model) !u32 {
var out: [1]i32 = undefined;
Expand Down
16 changes: 16 additions & 0 deletions zig/src/native/xpu_lane.zig
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,24 @@ pub fn Xpu(comptime S: type) type {
.mtp = true,
.speculate = true,
.speculate_early = false,
.plain_guard = true, // a round drafts only when its depth beats the decode step on the measured costs
.drafts = max_rows - 1,
.window_costs = self.costs[0..max_rows],
.mtp_step_ms = self.mtp_ms,
.max_streams = 1,
};
}

/// A one-row round on the decode step (a one-row window's bits): greedy on the device, else drawn on the host.
fn stepOne(self: *Self, token: u32, sampling: ?lanes.Sampling, position: u64) !u32 {
if (comptime !has_head) unreachable;
try self.e.stepRow(token);
const greedy = if (sampling) |s| s.temperature <= 0 else true;
if (greedy) return self.e.argmax();
try self.e.fetchLogits(self.logits);
return draw(self.gpa, self.logits, sampling.?, position);
}

/// The window's rows drawn: greedy on the device, else each row's logits drawn at its keyed position.
fn drawRows(self: *Self, rows: usize, sampling: ?lanes.Sampling, positions: []const u64, out: []u32) !void {
if (comptime !has_head) unreachable;
Expand Down Expand Up @@ -248,6 +259,11 @@ pub fn Xpu(comptime S: type) type {
@memcpy(ids[1..][0..w.held], self.held[0..w.held]);
} else @memcpy(ids[1..][0..w.tokens.len], w.tokens);
self.start = e.m.pos;
self.held_n = 0;
if (rows == 1) { // no drafts: the decode step, kept in place
out[0].sampled[0] = try self.stepOne(w.pending, w.stream.sampling, w.positions[0]);
return;
}
try e.verifyRows(ids[0..rows]);
try self.drawRows(rows, w.stream.sampling, w.positions, out[0].sampled);
@memcpy(out[0].drafts, ids[1..rows]);
Expand Down