Repository navigation
inkling2 metal: lift UnsupportedInklingTree with 0-ULP tree convolutions, attention, and compaction - #5011
inkling2 metal: lift UnsupportedInklingTree with 0-ULP tree convolutions, attention, and compaction#5011gilby wants to merge 1 commit into
Conversation
|
I trial-merged zig build test-inkling2-host test-inkling2-metal-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'I also filtered the Metal test root in scratch to the sliding-wrap KV/history compaction and 48-visit synthetic verify/replay fixtures. That run had eight passes and zero skips, so both named cases executed. Live checkpoint serving and throughput were outside this run. For integration, #4998 merges cleanly pairwise. There are source conflicts with #4981, #5000, #5001, #5004 and #5005, mostly in attention/forward and their registrations. The device receipt above is for the standalone trial. Igor Lessio - AIFLOW LABS |
|
I tested an integration of this head (
Scope was this pair with synthetic inputs. The full-checkpoint and throughput checks are still outstanding. Igor Lessio - AIFLOW LABS |
|
Thanks, @gilby. The tree code keeps ancestor order and the existing convolution and attention rounding points. The reported synthetic replay, wrap compaction and mixed linear/tree checks are useful. The remaining gate is checkpoint-backed branch/keep/replay on both M3 and M5, plus final-tree serving and memory checks. The plain decode receipt does not exercise trees. With paired K/V,
|
a3a83b6 to
a7ba033
Compare
|
I reran the checkpoint-backed branch/keep/replay test on M5 Max at Use the TF_INKLING2_METAL_DIR=/path/to/pinned/checkpoint zig build test-inkling2-metal-host -Dfixed-cpu -j2 --summary allThe broad combined run passed 157 host tests with 11 skipped, plus 71 Metal kernels and all 75 planted controls. M3, final-tree serving and memory, and #5004's baseline pipeline-load failure test remain open. Exact forward.zig resolution for a7ba033 + 23870c9In a scratch checkout of #5011, merge #5004 and take #5011's version of diff --git a/zig/src/families/inkling2/metal/forward.zig b/zig/src/families/inkling2/metal/forward.zig
index 8548d6513..448d49ed9 100644
--- a/zig/src/families/inkling2/metal/forward.zig
+++ b/zig/src/families/inkling2/metal/forward.zig
@@ -181,11 +181,17 @@ fn prepareAttentionInputs(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scra
}
}
-fn staticPostConv(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, slot: usize, conv_state: usize, raw: Ref, weight: ck.Tensor, out: Ref, base: usize, rows: usize, is_tree: bool) void {
+fn stageConvInput(m: *const Model, e: mtl.ComputeEncoder, cache: *state.Cache, slot: usize, conv_state: usize, raw: Ref, base: usize, rows: usize) Ref {
const channels = state.convWidth(conv_state);
const taps = cache.staged(slot, conv_state, 0);
copyBf16(m, e, cache.history(slot, conv_state), taps, 3 * channels);
copyBf16(m, e, at(raw.buf, raw.off + base * channels * 2), cache.staged(slot, conv_state, 3), rows * channels);
+ return taps;
+}
+
+fn staticPostConv(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, slot: usize, conv_state: usize, raw: Ref, weight: ck.Tensor, out: Ref, base: usize, rows: usize, is_tree: bool) void {
+ const channels = state.convWidth(conv_state);
+ const taps = stageConvInput(m, e, cache, slot, conv_state, raw, base, rows);
if (is_tree) {
tree.convStatic(&m.tree, e, taps, r(weight), at(s.conv_src, base * 4 * 4), at(out.buf, out.off + base * channels * 2), @intCast(rows), @intCast(channels));
} else {
@@ -210,13 +216,14 @@ fn attendSegments(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, v:
.segs = a(at(s.segs, si * @sizeOf(ap.Seg))),
};
const kv = attention.Cache{ .k = a(cache.keys(v.cache_slot)), .v = a(cache.values(v.cache_slot)) };
- try convInputForAttention(m, e, s, cache, v, base, rows, true, sm.is_tree);
- try convInputForAttention(m, e, s, cache, v, base, rows, false, sm.is_tree);
if (sm.is_tree) {
+ treeConvInputForAttention(m, e, s, cache, v, base, rows, true);
+ treeConvInputForAttention(m, e, s, cache, v, base, rows, false);
attention.prepTree(&m.attention, e, rr, layer, prep, meta, .{ a(at(s.q_raw, base * state.query_width * 2)), a(at(s.k_conv, base * state.kv_width * 2)), a(at(s.v_conv, base * state.kv_width * 2)), a(at(s.rel_raw, base * state.rel_width * 2)) }, .{ a(r(m.weights.layers[v.layer].attn.q_scale)), a(r(m.weights.layers[v.layer].attn.rel_scale)) }, a(at(s.q_prep, base * state.query_width * 2)), a(at(s.rel_prep, base * state.rel_width * 2)), kv);
attention.relTable(&m.attention, e, rr, a(at(s.rel_prep, base * state.rel_width * 2)), a(r(m.weights.layers[v.layer].attn.rel_projection)), a(at(s.rel_tab, base * 24 * ap.extent * 2)));
try attention.attendTree(&m.attention, e, rr, layer, state.max_attention_stride, @intCast(start), meta, a(at(s.tree_paths, base * state.window_rows * 4)), a(at(s.tree_tail_o, base * 2 * 24 * ap.head_dim * 4)), a(at(s.tree_tail_ml, base * 24 * 16)), a(at(s.q_prep, base * state.query_width * 2)), kv, a(at(s.rel_tab, base * 24 * ap.extent * 2)), a(at(s.part_o, base * 24 * state.max_attention_stride * ap.head_dim * 4)), a(at(s.part_ml, base * 24 * state.max_attention_stride * 8)), a(at(s.sink, base * 24 * 2)), a(at(s.gate, base * state.query_width * 2)), a(at(s.att, base * state.query_width * 2)));
} else {
+ convInputsForAttention(m, e, s, cache, v, base, rows);
attention.prep(&m.attention, e, rr, layer, prep, meta, .{ a(at(s.q_raw, base * state.query_width * 2)), a(at(s.k_conv, base * state.kv_width * 2)), a(at(s.v_conv, base * state.kv_width * 2)), a(at(s.rel_raw, base * state.rel_width * 2)) }, .{ a(r(m.weights.layers[v.layer].attn.q_scale)), a(r(m.weights.layers[v.layer].attn.rel_scale)) }, a(at(s.q_prep, base * state.query_width * 2)), a(at(s.rel_prep, base * state.rel_width * 2)), kv);
attention.relTable(&m.attention, e, rr, a(at(s.rel_prep, base * state.rel_width * 2)), a(r(m.weights.layers[v.layer].attn.rel_projection)), a(at(s.rel_tab, base * 24 * ap.extent * 2)));
try attention.attend(&m.attention, e, rr, layer, state.max_attention_stride, 0, meta, a(at(s.q_prep, base * state.query_width * 2)), kv, a(at(s.rel_tab, base * 24 * ap.extent * 2)), a(at(s.part_o, base * 24 * state.max_attention_stride * ap.head_dim * 4)), a(at(s.part_ml, base * 24 * state.max_attention_stride * 8)), a(at(s.sink, base * 24 * 2)), a(at(s.gate, base * state.query_width * 2)), a(at(s.att, base * state.query_width * 2)));
@@ -225,24 +232,45 @@ fn attendSegments(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, v:
}
}
-fn convInputForAttention(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, v: *const layer_plan.Visit, base: usize, rows: usize, key: bool, is_tree: bool) !void {
+fn treeConvInputForAttention(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, v: *const layer_plan.Visit, base: usize, rows: usize, key: bool) void {
const lp = m.weight_plan.at(v.layer);
const w = &m.weights.layers[v.layer];
const raw = if (key) at(s.k_conv, base * state.kv_width * 2) else at(s.v_conv, base * state.kv_width * 2);
- const projected = if (key) at(s.k_raw, base * state.kv_width * 2) else at(s.v_raw, base * state.kv_width * 2);
+ const projected = if (key) at(s.k_raw, 0) else at(s.v_raw, 0);
const normalized = if (key) at(s.k_norm, 0) else if (v.hasMessages() or lp.kind == .global) at(s.v_norm, 0) else at(s.q_norm, 0);
- const taps = cache.staged(v.cache_slot, if (key) 0 else 1, 0);
- copyBf16(m, e, cache.history(v.cache_slot, if (key) 0 else 1), taps, 3 * state.kv_width);
- copyBf16(m, e, projected, cache.staged(v.cache_slot, if (key) 0 else 1, 3), rows * state.kv_width);
- if (is_tree) {
- const src = at(s.conv_src, base * 4 * 4);
- switch (if (key) w.attn.k_conv else w.attn.v_conv) {
- .static => |weight| tree.convStatic(&m.tree, e, taps, r(weight), src, raw, @intCast(rows), state.kv_width),
- .dynamic => |d| tree.convDynamic(&m.tree, e, taps, at(normalized.buf, normalized.off + base * state.hidden * 2), r(d.static_w), r(d.projection), src, raw, @intCast(rows), state.kv_width),
- }
- } else switch (if (key) w.attn.k_conv else w.attn.v_conv) {
- .static => |weight| glue.convStatic(&m.glue, e, taps, r(weight), raw, @intCast(rows), state.kv_width),
- .dynamic => |d| glue.convDynamic(&m.glue, e, taps, at(normalized.buf, normalized.off + base * state.hidden * 2), r(d.static_w), r(d.projection), raw, @intCast(rows), state.kv_width),
+ const taps = stageConvInput(m, e, cache, v.cache_slot, if (key) 0 else 1, projected, base, rows);
+ const src = at(s.conv_src, base * 4 * 4);
+ switch (if (key) w.attn.k_conv else w.attn.v_conv) {
+ .static => |weight| tree.convStatic(&m.tree, e, taps, r(weight), src, raw, @intCast(rows), state.kv_width),
+ .dynamic => |d| tree.convDynamic(&m.tree, e, taps, at(normalized.buf, normalized.off + base * state.hidden * 2), r(d.static_w), r(d.projection), src, raw, @intCast(rows), state.kv_width),
+ }
+}
+
+fn convInputsForAttention(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, v: *const layer_plan.Visit, base: usize, rows: usize) void {
+ const lp = m.weight_plan.at(v.layer);
+ const w = &m.weights.layers[v.layer];
+ const k_taps = stageConvInput(m, e, cache, v.cache_slot, 0, at(s.k_raw, 0), base, rows);
+ const v_taps = stageConvInput(m, e, cache, v.cache_slot, 1, at(s.v_raw, 0), base, rows);
+ const k_out = at(s.k_conv, base * state.kv_width * 2);
+ const v_out = at(s.v_conv, base * state.kv_width * 2);
+ const k_in = at(s.k_norm, base * state.hidden * 2);
+ const v_norm = if (v.hasMessages() or lp.kind == .global) at(s.v_norm, 0) else at(s.q_norm, 0);
+ const v_in = at(v_norm.buf, v_norm.off + base * state.hidden * 2);
+ switch (w.attn.k_conv) {
+ .static => |kw| switch (w.attn.v_conv) {
+ .static => |vw| glue.convStaticKv(&m.glue, e, k_taps, r(kw), k_out, v_taps, r(vw), v_out, @intCast(rows), state.kv_width),
+ .dynamic => |vd| {
+ glue.convStatic(&m.glue, e, k_taps, r(kw), k_out, @intCast(rows), state.kv_width);
+ glue.convDynamic(&m.glue, e, v_taps, v_in, r(vd.static_w), r(vd.projection), v_out, @intCast(rows), state.kv_width);
+ },
+ },
+ .dynamic => |kd| switch (w.attn.v_conv) {
+ .dynamic => |vd| glue.convDynamicKv(&m.glue, e, k_taps, k_in, r(kd.static_w), r(kd.projection), k_out, v_taps, v_in, r(vd.static_w), r(vd.projection), v_out, @intCast(rows), state.kv_width),
+ .static => |vw| {
+ glue.convDynamic(&m.glue, e, k_taps, k_in, r(kd.static_w), r(kd.projection), k_out, @intCast(rows), state.kv_width);
+ glue.convStatic(&m.glue, e, v_taps, r(vw), v_out, @intCast(rows), state.kv_width);
+ },
+ },
}
}
Igor Lessio - AIFLOW LABS |
|
I reran the paired integration after #4981 landed at
That scratch integration passed 157 host tests with 11 skips, all 71 Metal kernels and 75 planted controls, and the pinned checkpoint replay again on M5 Max (7/7 focused checks). M3 and the final serving, memory and #5004 failure-path gates remain open. Igor Lessio - AIFLOW LABS |
a7ba033 to
c1a82fe
Compare
|
I tested I also added #5004's current zig build test-inkling2-host test-inkling2-metal-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'The resolved Exact forward.zig resolutiondiff --git a/zig/src/families/inkling2/metal/forward.zig b/zig/src/families/inkling2/metal/forward.zig
index a5b13f0e6..688fdf08a 100644
--- a/zig/src/families/inkling2/metal/forward.zig
+++ b/zig/src/families/inkling2/metal/forward.zig
@@ -198,11 +198,17 @@ fn prepareAttentionInputs(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scra
}
}
-fn staticPostConv(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, slot: usize, conv_state: usize, raw: Ref, weight: ck.Tensor, out: Ref, base: usize, rows: usize, is_tree: bool) void {
+fn stageConvInput(m: *const Model, e: mtl.ComputeEncoder, cache: *state.Cache, slot: usize, conv_state: usize, raw: Ref, base: usize, rows: usize) Ref {
const channels = state.convWidth(conv_state);
const taps = cache.staged(slot, conv_state, 0);
copyBf16(m, e, cache.history(slot, conv_state), taps, 3 * channels);
copyBf16(m, e, at(raw.buf, raw.off + base * channels * 2), cache.staged(slot, conv_state, 3), rows * channels);
+ return taps;
+}
+
+fn staticPostConv(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, slot: usize, conv_state: usize, raw: Ref, weight: ck.Tensor, out: Ref, base: usize, rows: usize, is_tree: bool) void {
+ const channels = state.convWidth(conv_state);
+ const taps = stageConvInput(m, e, cache, slot, conv_state, raw, base, rows);
if (is_tree) {
tree.convStatic(&m.tree, e, taps, r(weight), at(s.conv_src, base * 4 * 4), at(out.buf, out.off + base * channels * 2), @intCast(rows), @intCast(channels));
} else {
@@ -227,13 +233,14 @@ fn attendSegments(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, v:
.segs = a(at(s.segs, si * @sizeOf(ap.Seg))),
};
const kv = attention.Cache{ .k = a(cache.keys(v.cache_slot)), .v = a(cache.values(v.cache_slot)) };
- try convInputForAttention(m, e, s, cache, v, base, rows, true, sm.is_tree);
- try convInputForAttention(m, e, s, cache, v, base, rows, false, sm.is_tree);
if (sm.is_tree) {
+ treeConvInputForAttention(m, e, s, cache, v, base, rows, true);
+ treeConvInputForAttention(m, e, s, cache, v, base, rows, false);
attention.prepTree(&m.attention, e, rr, layer, prep, meta, .{ a(at(s.q_raw, base * state.query_width * 2)), a(at(s.k_conv, base * state.kv_width * 2)), a(at(s.v_conv, base * state.kv_width * 2)), a(at(s.rel_raw, base * state.rel_width * 2)) }, .{ a(r(m.weights.layers[v.layer].attn.q_scale)), a(r(m.weights.layers[v.layer].attn.rel_scale)) }, a(at(s.q_prep, base * state.query_width * 2)), a(at(s.rel_prep, base * state.rel_width * 2)), kv);
attention.relTable(&m.attention, e, rr, a(at(s.rel_prep, base * state.rel_width * 2)), a(r(m.weights.layers[v.layer].attn.rel_projection)), a(at(s.rel_tab, base * 24 * ap.extent * 2)));
try attention.attendTree(&m.attention, e, rr, layer, state.max_attention_stride, @intCast(start), meta, a(at(s.tree_paths, base * state.window_rows * 4)), a(at(s.tree_tail_o, base * 2 * 24 * ap.head_dim * 4)), a(at(s.tree_tail_ml, base * 24 * 16)), a(at(s.q_prep, base * state.query_width * 2)), kv, a(at(s.rel_tab, base * 24 * ap.extent * 2)), a(at(s.part_o, base * 24 * state.max_attention_stride * ap.head_dim * 4)), a(at(s.part_ml, base * 24 * state.max_attention_stride * 8)), a(at(s.sink, base * 24 * 2)), a(at(s.gate, base * state.query_width * 2)), a(at(s.att, base * state.query_width * 2)));
} else {
+ convInputsForAttention(m, e, s, cache, v, base, rows);
attention.prep(&m.attention, e, rr, layer, prep, meta, .{ a(at(s.q_raw, base * state.query_width * 2)), a(at(s.k_conv, base * state.kv_width * 2)), a(at(s.v_conv, base * state.kv_width * 2)), a(at(s.rel_raw, base * state.rel_width * 2)) }, .{ a(r(m.weights.layers[v.layer].attn.q_scale)), a(r(m.weights.layers[v.layer].attn.rel_scale)) }, a(at(s.q_prep, base * state.query_width * 2)), a(at(s.rel_prep, base * state.rel_width * 2)), kv);
attention.relTable(&m.attention, e, rr, a(at(s.rel_prep, base * state.rel_width * 2)), a(r(m.weights.layers[v.layer].attn.rel_projection)), a(at(s.rel_tab, base * 24 * ap.extent * 2)));
try attention.attend(&m.attention, e, rr, layer, state.max_attention_stride, 0, meta, a(at(s.q_prep, base * state.query_width * 2)), kv, a(at(s.rel_tab, base * 24 * ap.extent * 2)), a(at(s.part_o, base * 24 * state.max_attention_stride * ap.head_dim * 4)), a(at(s.part_ml, base * 24 * state.max_attention_stride * 8)), a(at(s.sink, base * 24 * 2)), a(at(s.gate, base * state.query_width * 2)), a(at(s.att, base * state.query_width * 2)));
@@ -242,24 +249,45 @@ fn attendSegments(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, v:
}
}
-fn convInputForAttention(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, v: *const layer_plan.Visit, base: usize, rows: usize, key: bool, is_tree: bool) !void {
+fn treeConvInputForAttention(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, v: *const layer_plan.Visit, base: usize, rows: usize, key: bool) void {
const lp = m.weight_plan.at(v.layer);
const w = &m.weights.layers[v.layer];
const raw = if (key) at(s.k_conv, base * state.kv_width * 2) else at(s.v_conv, base * state.kv_width * 2);
- const projected = if (key) at(s.k_raw, base * state.kv_width * 2) else at(s.v_raw, base * state.kv_width * 2);
+ const projected = if (key) at(s.k_raw, 0) else at(s.v_raw, 0);
const normalized = if (key) at(s.k_norm, 0) else if (v.hasMessages() or lp.kind == .global) at(s.v_norm, 0) else at(s.q_norm, 0);
- const taps = cache.staged(v.cache_slot, if (key) 0 else 1, 0);
- copyBf16(m, e, cache.history(v.cache_slot, if (key) 0 else 1), taps, 3 * state.kv_width);
- copyBf16(m, e, projected, cache.staged(v.cache_slot, if (key) 0 else 1, 3), rows * state.kv_width);
- if (is_tree) {
- const src = at(s.conv_src, base * 4 * 4);
- switch (if (key) w.attn.k_conv else w.attn.v_conv) {
- .static => |weight| tree.convStatic(&m.tree, e, taps, r(weight), src, raw, @intCast(rows), state.kv_width),
- .dynamic => |d| tree.convDynamic(&m.tree, e, taps, at(normalized.buf, normalized.off + base * state.hidden * 2), r(d.static_w), r(d.projection), src, raw, @intCast(rows), state.kv_width),
- }
- } else switch (if (key) w.attn.k_conv else w.attn.v_conv) {
- .static => |weight| glue.convStatic(&m.glue, e, taps, r(weight), raw, @intCast(rows), state.kv_width),
- .dynamic => |d| glue.convDynamic(&m.glue, e, taps, at(normalized.buf, normalized.off + base * state.hidden * 2), r(d.static_w), r(d.projection), raw, @intCast(rows), state.kv_width),
+ const taps = stageConvInput(m, e, cache, v.cache_slot, if (key) 0 else 1, projected, base, rows);
+ const src = at(s.conv_src, base * 4 * 4);
+ switch (if (key) w.attn.k_conv else w.attn.v_conv) {
+ .static => |weight| tree.convStatic(&m.tree, e, taps, r(weight), src, raw, @intCast(rows), state.kv_width),
+ .dynamic => |d| tree.convDynamic(&m.tree, e, taps, at(normalized.buf, normalized.off + base * state.hidden * 2), r(d.static_w), r(d.projection), src, raw, @intCast(rows), state.kv_width),
+ }
+}
+
+fn convInputsForAttention(m: *const Model, e: mtl.ComputeEncoder, s: *state.Scratch, cache: *state.Cache, v: *const layer_plan.Visit, base: usize, rows: usize) void {
+ const lp = m.weight_plan.at(v.layer);
+ const w = &m.weights.layers[v.layer];
+ const k_taps = stageConvInput(m, e, cache, v.cache_slot, 0, at(s.k_raw, 0), base, rows);
+ const v_taps = stageConvInput(m, e, cache, v.cache_slot, 1, at(s.v_raw, 0), base, rows);
+ const k_out = at(s.k_conv, base * state.kv_width * 2);
+ const v_out = at(s.v_conv, base * state.kv_width * 2);
+ const k_in = at(s.k_norm, base * state.hidden * 2);
+ const v_norm = if (v.hasMessages() or lp.kind == .global) at(s.v_norm, 0) else at(s.q_norm, 0);
+ const v_in = at(v_norm.buf, v_norm.off + base * state.hidden * 2);
+ switch (w.attn.k_conv) {
+ .static => |kw| switch (w.attn.v_conv) {
+ .static => |vw| glue.convStaticKv(&m.glue, e, k_taps, r(kw), k_out, v_taps, r(vw), v_out, @intCast(rows), state.kv_width),
+ .dynamic => |vd| {
+ glue.convStatic(&m.glue, e, k_taps, r(kw), k_out, @intCast(rows), state.kv_width);
+ glue.convDynamic(&m.glue, e, v_taps, v_in, r(vd.static_w), r(vd.projection), v_out, @intCast(rows), state.kv_width);
+ },
+ },
+ .dynamic => |kd| switch (w.attn.v_conv) {
+ .dynamic => |vd| glue.convDynamicKv(&m.glue, e, k_taps, k_in, r(kd.static_w), r(kd.projection), k_out, v_taps, v_in, r(vd.static_w), r(vd.projection), v_out, @intCast(rows), state.kv_width),
+ .static => |vw| {
+ glue.convDynamic(&m.glue, e, k_taps, k_in, r(kd.static_w), r(kd.projection), k_out, @intCast(rows), state.kv_width);
+ glue.convStatic(&m.glue, e, v_taps, r(vw), v_out, @intCast(rows), state.kv_width);
+ },
+ },
}
}
Igor Lessio - AIFLOW LABS |
Real Inkling 2 Mini Checkpoint & Multi-Architecture Receipt (
|
…ons, attention, and compaction Refs ashhart#4961
c1a82fe to
7e8a1f2
Compare
|
Rebased cleanly onto
Fresh checks on
|
|
Thank you, @gilby. The current head merges cleanly. It includes new relative-bias bindings, atomic probe registration and the kept final-row logits copy. The earlier green M5 result and disclosed M3 overlay receipt are retained for their tested trees. Ready for controlled comparisons of this integration. Exact checkpoint tree replay and kept-row continuation still need coverage on the updated bias/cache path; the older receipt does not exercise those new bytes. The M3 cell also needs the reviewed address-space fix.
|
Refreshed Real-Checkpoint Receipt on Rebased Head
|
What this changes
Before: on
main, the Inkling 2 Mini Metal backend only accepted linear verification chains (w.parents == null) and returnederror.UnsupportedInklingTreewhenever a lane verification window included tree-structured branches.After: implements full
0-ULP tree verification and arbitrary surviving-path state compaction in the Inkling 2 Mini Metal backend (zig/src/families/inkling2/metal/{tree,tree_plan,attention,attention_plan,backend,forward,state,model}.zig), addingtf_ink2_conv_static_tree,tf_ink2_conv_dynamic_tree,tf_ink2_keep_kv, andtf_ink2_keep_convinzig/kernels/metal/inkling2/tree.metalalongside ancestor-remappedtf_ink2_prep_tree,tf_ink2_attn_scalar_tree,tf_ink2_attn_prompt_tree_prefix, andtf_ink2_attn_prompt_tree_tailinattention.metalandprompt_attention.metalwith fused on-the-fly relative bias (#5000, norel_tablescratch/dispatch), liftingUnsupportedInklingTreefor non-linear verification windows while preserving linear non-tree decode performance and bounding tree scratch buffers tobatch_rows(32). Adds host, GPU, serving, andcontract.register-wired (#5058) kernel-contract suites (tree_test.zig,tree_gpu_test.zig,metal_inkling2_tree*.zig).origin/main(f3c0fa8c65, including#5000fused on-the-fly relative bias and#5058contract.register;git merge-tree --write-treeclean61f47e0c02)Checks on this head
7e8a1f29afpython3 tools/pr_check.py --base origin/main --pr 5011:lean 164 vs 164, 0 new,0 error(s)(31changed files,2944 insertions(+), 76 deletions(-), max touched file598lines<= 600;tree_gpu_test.zig584,metal_inkling2_tree_attn.zig578);zig fmt --check build.zig zigandgit diff --check origin/main..HEADexit0.7e8a1f29af):zig build -Dcpu=apple_m1 -Doptimize=ReleaseFast: exit0.zig build compile-inkling2-native-host: exit0.zig build compile-inkling2-native-host -Dtarget=x86_64-windows: exit0.zig build compile-native-cuda-windows: exit0.zig build tf-kernel-contract -Doptimize=ReleaseFast: exit0.7e8a1f29af):zig build test-inkling2-host -Dcpu=apple_m1 -Doptimize=ReleaseFast --summary all:5/5 steps succeeded(46 pass, 4 skip (50 total)on69149deee4, cached pass on7e8a1f29af).zig build test-inkling2-controls-host --summary all:5/5 steps succeeded(26 pass (26 total)on69149deee4, cached pass on7e8a1f29af).zig build test-kernel-contract --summary all:45/45 steps succeeded; 260/260 tests passed(Metal launch map: 1321 registered launches, 2 controls, 0 missing;304/304uncached on69149deee4).zig build test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFast --summary all:5/5 steps succeeded; 118/125 tests passed (7 skipped)(0failed;tree_gpu_test.zig48-visit differential + mixed-batch C2/C7 +lanes.Engineconformance all pass; JPEG/checkpoint env tests skipped).7e8a1f29af):./zig-out/bin/tf-kernel-contract --only "metal inkling2":SUMMARY 70 kernels: 70 pass gates 1-4, 0 fail, 0 known findings; 76 controls: 76 red as planted, 0 missed; 0 limit problems; gates 55909 ms, limits 626 ms(exit0)../zig-out/bin/tf-kernel-contract --only "metal inkling2 tree":SUMMARY 4 kernels: 4 pass gates 1-4, 0 fail, 0 known findings; 4 controls: 4 red as planted, 0 missed; 0 limit problems; gates 4709 ms, limits 52 ms(exit0).TF_INKLING2_REAL_TREE=1): see Apple M5 Ultra 512 GiB + Apple M3 Ultra 512 GiB receipt comment (8/8tests pass on both architectures with bit-for-bit FP32 logits & feature taps matching sequential replay,plain == tree == resumed).7e8a1f29af.#issuecomment-7166583709) and post-rebase Apple M5 Max contract + 48-visit GPU tests verify exactness and zero regression.Receipt
c1a82fe5d1,tools/bench_concurrent.py --tokens 128 --reps 2 --no-drafts --parallel 4 --context 8192,0cross-legtoken_sha256mismatches across all cells on both machines):mainvs branch, plain linear decode guard):-0.59%..+0.30%across cells (0mismatches).mainvs branch, plain linear decode guard):c=1:code T=0.0:13.40 -> 13.40 tok/s(0.00%, TTFT+0.19%);chat T=0.0:13.50 -> 13.50 tok/s(0.00%, TTFT-0.55%).c=4:code T=0.0:21.40 -> 21.35 tok/s(-0.23%, TTFT-3.31%);chat T=0.0:22.85 -> 22.90 tok/s(+0.22%, TTFT-1.21%).lanes.Engineconformance (TF_INKLING2_REAL_TREE=1): Apple M5 Ultra 512 GiB and Apple M3 Ultra 512 GiB (8/8pass,0-ULP FP32 logits & feature taps match sequential replay; see#issuecomment-7166583709).zig/kernels/metal/inkling2/{attention,prompt_attention,tree}.metal,tree_sources.zig,inkling2_sources.zig,inkling2_{attention,tree}_metal_records.zig,registry_joins.zig,contract.zig,zig/src/families/inkling2/metal/{attention,attention_plan,backend,forward,host_test,metal,model,state,tree,tree_plan,tree_test,tree_gpu_test}.zig,inkling2_serving_test.zig,zig/build/{inkling2_host,kernel_contract,metal_targets}.zig,zig/tests/contract/{metal_inkling2_controls_host,metal_inkling2_main,metal_inkling2_tree,metal_inkling2_tree_attn,metal_inkling2_tree_controls,metal_limits}.zig.7e8a1f29afrebased ontoorigin/main(f3c0fa8c65), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17); pre-rebase receipts on Apple M5 Ultra 512 GiB, Apple M3 Ultra 512 GiB, and Apple M5 Pro 64 GiB; checkpoint Inkling-2-Mini.0cross-legtoken_sha256mismatches across all cells on Apple M5 Ultra and Apple M5 Pro;0-ULP bitwise agreement for fused on-the-fly relative-bias tree convolutions, tree attention, and surviving-path compaction verified inmetal_inkling2_tree*.zigandtree_gpu_test.zig, plus real-checkpoint Inkling-2-Mini verification in#issuecomment-7166583709.-0.59%..+0.30%(M5 Ultra) /-0.23%..+0.22%(M5 Pro) noise band on linear decode while liftingUnsupportedInklingTreeto enable tree-structured verification windows (and removing the separaterel_tablescratch buffer and dispatch via#5000).-3.31%(code c=4) and-1.21%(chat c=4) onM5 Pro.Kernel contract, only when a GPU kernel is new or changed
tf_ink2_conv_static_tree,tf_ink2_conv_dynamic_tree,tf_ink2_keep_kv,tf_ink2_keep_conv(tree.metal/inkling2_tree_metal_records.zig) plustf_ink2_prep_tree,tf_ink2_attn_scalar_tree,tf_ink2_attn_prompt_tree_prefix,tf_ink2_attn_prompt_tree_tail(attention.metal,prompt_attention.metal/inkling2_attention_metal_records.zig), extending the linear verify path with fused on-the-fly relative bias (#5000) to support tree-structured windows.76/76controls on Apple M5 Max (7e8a1f29af) fail red as planted (0missed), including planted failure controls inmetal_inkling2_tree_controls.zig(26/26host control tests pass).SUMMARYline and exit status:7e8a1f29af,--only "metal inkling2"):SUMMARY 70 kernels: 70 pass gates 1-4, 0 fail, 0 known findings; 76 controls: 76 red as planted, 0 missed; 0 limit problems; gates 55909 ms, limits 626 ms(exit0).7e8a1f29af,--only "metal inkling2 tree"):SUMMARY 4 kernels: 4 pass gates 1-4, 0 fail, 0 known findings; 4 controls: 4 red as planted, 0 missed; 0 limit problems; gates 4709 ms, limits 52 ms(exit0).a3a83b6e5d):SUMMARY 56 kernels: 56 pass gates 1-4, 0 fail, 0 known findings; 63 controls: 63 red as planted, 0 missed; 0 limit problems; gates 43253 ms, limits 7 ms(exit0).applegpu_g15real-checkpoint tree suite ran pre-rebase in#issuecomment-7166583709).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled.