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

- HIP: the load-time lane cost table times a shared bucket of two or more windows with a distinct token a row, as shared rounds draft, instead of one repeated token; lone windows, one-row buckets, the head step and one-stream servers are timed as before, and only the drafted width can change, never a token (#2652, part of #2605). Thanks to @AbrahamCete.

- Tool calls: a reply's call ids are an HMAC-SHA-256 of the request (its body without `stream` and `stream_options`, the choice and the call's index) under the server's key instead of chance, so a request replayed to the same server gets the same ids, a stream names its calls as its whole reply and the next turn's background prefill do, and a Responses `fc_` item id follows its call; without the key an id reveals nothing about the request, and byte-identical requests under one key share ids. The key is random per server process unless `TENSORFOLD_TOOL_ID_KEY_FILE` names an owner-only file of at least 32 bytes, which keeps ids across restarts and machines sharing it, and a missing, unreadable, linked, shared, short or oversized file stops the start by name; the `call_` and 24 hex digit form and the ids a client sends back are unchanged (#2653).

- Qwen3.8-27B on Metal: after a sampled or grammar-masked verify, only the drafter's taps and head row are waited for; the target's keep follows on the same queue and is settled before the next verify, so the drafter starts sooner, with every token unchanged. One stream sampled with DFlash2 on an M3 Ultra: chat 75.3 to 77.0 tok/s, code 106.8 to 109.8 (#2646). Thanks to @mrv777.
Expand Down
8 changes: 7 additions & 1 deletion zig/src/families/qwen3_5/backend/hip/engine/hip_costs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ pub const nowNs = serve.backend.nowNs;
/// A stream's window position in the timings (the caches are scratch).
const at = 16;

/// A timed forward's tokens: one repeated for a lone window, one a row for shared rows, which an MoE routes apart.
pub fn fillTokens(tokens: []u32, windows: usize, vocab: usize) void {
const span = @min(vocab, 65536) - 1;
for (tokens, 0..) |*t, k| t.* = if (windows > 1) @intCast(1 + (k * 7919) % span) else 1;
}

const Rig = struct {
gpa: std.mem.Allocator,
e: *Engine,
Expand All @@ -33,7 +39,6 @@ const Rig = struct {
r.caches = try gpa.alloc(state.Caches, streams);
r.rows = try gpa.alloc(Engine.Rows, streams);
r.tokens = try gpa.alloc(u32, most);
@memset(r.tokens, 1);
r.reqs = try gpa.alloc(draw.Request, most);
r.out = try gpa.alloc(u32, most);
// a bucket's rows over the streams can outgrow a lone window when `most` passes 16 rows a stream
Expand Down Expand Up @@ -61,6 +66,7 @@ const Rig = struct {
for (0..w) |j| r.reqs[total + j] = .{ .sampling = null, .position = at + j + 1 };
total += w;
}
fillTokens(r.tokens[0..total], widths.len, r.e.model().spec.vocab);
const n = shared.runs(total);
var spent: u64 = 0;
for (0..n.warm + n.reps) |i| {
Expand Down
17 changes: 17 additions & 0 deletions zig/src/families/qwen3_5/backend/hip/engine/hip_costs_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,20 @@ test "the lone window table stays one window of each width to the widest" {
}
}
}

test "a lone window times one repeated token; shared rows carry a token a row inside the vocabulary" {
var tokens: [256]u32 = undefined;
costs.fillTokens(&tokens, 1, 248320);
for (tokens) |t| try T.expectEqual(@as(u32, 1), t);

costs.fillTokens(&tokens, 4, 248320);
var seen: std.AutoHashMapUnmanaged(u32, void) = .empty;
defer seen.deinit(T.allocator);
for (tokens) |t| {
try T.expect(t > 0 and t < 248320);
try T.expect(!(try seen.getOrPut(T.allocator, t)).found_existing);
}

costs.fillTokens(tokens[0..16], 2, 1000);
for (tokens[0..16]) |t| try T.expect(t > 0 and t < 1000);
}
Loading