Repository navigation
Ling: grouped expert routing on Metal, checked against a float64 reference - #1836
Conversation
|
Thanks @ThinkOffApp. We checked the kernel against the reference, and it matches the f32 formula (and f32 matches float64 in the host tests) on ties (lower group, then lower id), NaN scores (never in a group score or a pick), plus and minus infinity, and groups with fewer finite experts than top-k. One change before it lands:
Two smaller asks:
It needs a mechanical rebase for two registration lines. After that we'll run the Metal kernel contract on an M5 and land it. |
330a008 to
5b2a1f2
Compare
|
Thank you @ashhart for the detailed check! This is now rebased on main at 1ce4526 (the conflict was the
On an M5 Max: After this making the Ventuno HW proposal as we discussed. |
|
Thanks @ThinkOffApp: all three earlier asks are answered (empty picks, |
|
Thanks @ThinkOffApp for the quick fix. It's gated and queued to land, and we've written the changelog line. One thing we changed while preparing it: your commits were authored with a personal email address, and we only publish GitHub noreply addresses in the repository's history. So the commits that land carry your noreply address ( |
|
Thanks @ashhart, the noreply address is now our default for commits. |
keep_groups then top-k, as glue.select and ling_forward.py take it. Tiny (16 experts a group) and flash (64) both run. The tiny-index TF_LING_INDEX check against tiny_config.json ships here. Refs ashhart#1247.
tf-kernel-contract now compiles: route.zig is a named module, not a path outside it. Gate 5 knows the launch. NaN/Inf, ties and the 32-thread record all pass. Refs ashhart#1247.
Mutation left six common-mode bugs green: top-1 group score, keep+1, bias in the weights, sigmoid(2x), mask-to-zero, and f64 without renorm. These cases use hand-computed weights and rankings the shared host/Metal oracle cannot see. Refs ashhart#1247.
A padded choice of 0 beats every negative expert. GPU smoke now uses bias-2 so those slots stay out of the picks. The 1e-5 bound hid a 1e-4 epsilon. Refs ashhart#1247.
The contract never ties at the keep boundary, and its nonfinite gate only runs the tiny shape, so the whole-column branch never saw NaN. Both shapes now keep the lower groups on a full tie; flash plants a NaN at expert 64. Refs ashhart#1247.
A picked slot is marked NaN, not -inf, so a later -inf tie cannot repeat the id. Host and Metal both do this. Tests cover a trailing NaN in the winning group, an odd-column NaN on flash, all-NaN and one-finite-per-group rows, all -10 / -100 weights, and a NaN-aware weight check. Refs ashhart#1247.
selectF64 must not repeat an id after finite choices run out. The contract states that filler picks with NaN scores make the row's weights NaN. Refs ashhart#1247.
…he bias refusal A row with fewer usable experts than top-k (every expert left NaN: an all-NaN row with one group or every group kept) wrote out-of-range ids: experts, experts + 1 on the kernel's padded slots, 1 << 30 at 512 experts, and experts on the host. The kernel and both references now end such a row with empty picks, id 0 with weight 0, after the real picks; selectF32 and selectF64 return how many are real. Shape.of(config) builds the shape from a parsed config, and Shape.check holds glue.select's bounds; config.parse now refuses through Shape.check, so the bounds live in one place. checkBias refuses a group holding both a +inf and a -inf bias, whose top-2 sum would be NaN. The contract and GPU harnesses call both.
tools/zig/lean_check.py reported 9 problems in route.zig: multi-line doc comments at 21, 22, 39, 43, 44, 147 and 185, and comments past 120 columns at 22 and 23. Each doc comment is now one line within 120 columns, and the file reports none. Comments only: zig fmt --check is clean and test-ling-host gives 48/50 (2 skipped).
|
Thank you @ThinkOffApp. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
|
Landed as bfc374f. Thanks @ThinkOffApp! |
|
Thanks @ThinkOffApp! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2 |
Grouped expert routing for the Ling family on Metal, for #1247.
The kernel is
tf_ling_route. A float64 reference checks the same picks. Host tests pin the sigmoid, the group score, keep-4, and the float64 weights. Padded picks are rejected, and the Metal weight bound is 1e-6. GPU cases cover tied groups and a planted NaN. After a NaN the picks stay unique, and the float64 reference uses distinct ids.Rebased onto current main.
zig build testwith Zig 0.17 exited 0.This is the routing step only. Tokenizer, gates, MLA, the full forward pass, and the ARM board backend stay later.