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

- Kolibri-1: the tree-attention cache offsets are signed, so a server with default flags no longer panics with an integer overflow on its first request when a cache sits below the origin (#3561). Thanks to @jschmied.

- H3 on Metal: `Model.load` reads every transformer shard ahead of its mappings and fails the load on a missing or short shard; `TF_LOAD_PREFETCH` sets the reader count and `0` turns read-ahead off (#2999). Thanks to @plotarmordev.

- App: an idle task's disabled Planning only control opens the model picker on Local, so a planning provider no longer strands the user; the ordinary model button still opens All (#3357). Thanks to @garvrao80.
Expand Down
12 changes: 10 additions & 2 deletions zig/src/families/kolibri1/forward.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const grouped = cuda.grouped;
const experts = cuda.experts;
const TreeAttention = cuda.tree_attention.TreeAttention;

/// bf16 elements from `origin` to `at`, signed: a cache made after `origin` (attach's rings) may sit below it.
pub fn elementsFrom(origin: u64, at: u64) i64 {
return @divExact(@as(i64, @bitCast(at -% origin)), 2);
}

/// Prompt rows a forward takes: the chunk grid, from position 0.
pub const prompt_rows = 8192;
/// Decode rows a forward takes over every stream's window.
Expand Down Expand Up @@ -405,8 +410,8 @@ pub const Model = struct {
defer m.gpa.free(offs);
for (0..c.layers) |i| for (chains, 0..) |ch, j| {
const at = if (m.paged and c.full[i]) 0 else ch.slot * per; // paged: the layer's region, the table's rows
offs[(i * chains.len + j) * 2] = @intCast((m.k[i] + at - m.origin) / 2);
offs[(i * chains.len + j) * 2 + 1] = @intCast((m.v[i] + at - m.origin) / 2);
offs[(i * chains.len + j) * 2] = elementsFrom(m.origin, m.k[i] + at);
offs[(i * chains.len + j) * 2 + 1] = elementsFrom(m.origin, m.v[i] + at);
};
try m.upload(s, dst, std.mem.sliceAsBytes(offs));
}
Expand Down Expand Up @@ -590,3 +595,6 @@ test "a page's bytes: the pool's layout and the kernels' stride agree" {
try std.testing.expectEqual(m.pageBytes(), m.layout().pageBytes());
try std.testing.expectEqual(@as(u32, 10), m.layout().group().layers);
}
test {
_ = @import("forward_offsets_test.zig");
}
8 changes: 8 additions & 0 deletions zig/src/families/kolibri1/forward_offsets_test.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const std = @import("std");
const fwd = @import("forward.zig");

test "cache offsets from the tree origin are signed: a ring made below the origin counts back" {
try std.testing.expectEqual(@as(i64, 128), fwd.elementsFrom(0x1000, 0x1100));
try std.testing.expectEqual(@as(i64, -128), fwd.elementsFrom(0x1100, 0x1000));
try std.testing.expectEqual(@as(i64, 0), fwd.elementsFrom(0x7f00_0000_0000, 0x7f00_0000_0000));
}
Loading