Repository navigation
Conversation
…final norm over the read row's 128-row block A chunk that keeps no row already writes only its last layer's keys and values (keysOnly). The prompt's last chunk keeps one row: every layer still writes the whole KV cache and recurrent state, and only rows no head reads skip the last layer's q, o, MLP and final norm. prompt_tail.zig holds both rules on one Facts; first() uses core prompt_tail, as the CUDA tail does, and refuses taps, images, more than one stream, tensor pairs, the ANE share, MoE and row-dependent projections. Co-authored-by: ArthurOstapenko <4603588+ArthurOstapenko@users.noreply.github.com> Co-authored-by: ercumentyildirim <43972346+ercumentyildirim@users.noreply.github.com>
…r units Keep main’s existing prompt-tail test import after the rebase, and report a successful skip before constructing the synthetic model when prompt passes cannot exceed one 128-row block. Current projection dispatch and barrier ordering remain intact.
…he kept row's tile (#2829) A prompt chunk before the last reads none of its rows, and the last reads one. Past the last layer's keys and values, nothing else reaches the other rows, so: - forward.spanFor: on the last layer every row still runs the input norm, k, v, k's norm, RoPE and both page writes. An unread chunk stops there. A read chunk runs q, the prefill tile, the gate, o, the residual norm, the MLP and the final norm over its last 128 rows only (core's tail), q at its own positions over every key. `span` keeps every row, as before, for the checks, the scratch sizing and captures. - forward/prompt_tail.zig: the HIP facts for core/prompt_tail.zig. A tap on the last layer, a trace that reads rows, an image prompt and a readout are readers and keep the whole chunk; rocBLAS (its bits vary with rows) refuses the tail only; a last layer that is not full attention refuses both. The layer-cancel poll reads no rows. - engine: advance asks for keys only, prefill for the last row (its logits and the MTP head's input, which reads that row alone), spanRows for every row. - Every rank decides from the same facts (taps, images and rocBLAS are one-rank only), so tensor-parallel reduces stay matched. Host tests: each planted reader refuses; a launch-recording span of a two-layer model shows an unread chunk's last layer launching only k, v, k's norm and RoPE and the page writes, a read chunk's queries, attention, o, MLP and final norm over 128 rows from len - 128, and a tail across two 2,048-row steps; advance, prefill and readout ask for keys, the tail and every row; the cancel poll reads no rows.
…hunk `tf-qwen35-test check --only invariants` gains one line a length (1, 63, 64, 65, 1,023, 1,024, 1,025, 2,049 and 4,096 rows). Each runs one chunk three ways: whole (main's path), with its last row read (the tail) and unread (keys only), then the next 16 rows over each chunk's caches. The tail's last final row and logits, and both continuations' rows, must equal the whole chunk's byte for byte. The invariants phase sizes its engine for the 4,096-row case.
…dling tails checked (#2845 review) - prompt_tail.zig: `dense`, a `.dense` q, o or MLP product on the last layer (a widened BF16 chat checkpoint, or an unquantized tensor in an MLX one: both reach Qwen HIP), refuses the tail as rocBLAS does; the keys-only pass stays, as k and v run every row either way. Routed and shared experts are weighed too. - The recorded span's last layer now runs real MLX tiles (gfx1151's affine kernels and registry, each kernel named by its symbol); a dense last layer keeps keys only and runs every row when read; at 2,175 rows the read row's step runs main's tile at main's 127 rows while the first step's one-row piece takes another tile. - tail_run: the device check adds 2,100, 2,148 and 2,175 rows, whose tails put 76, 28 and 1 rows in the first 2,048-row step.
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI for a landing train: #2826 #2845 stacked on main in that order. Nothing merges from this PR: each PR above lands on its own once this tip is green, and this PR is then closed.