Skip to content

train 1124000129: #4694 #4641 #4673 (CI only) - #4813

Closed
ashhart wants to merge 19 commits into
mainfrom
lead/train-1124000129
Closed

ashhart wants to merge 19 commits into
mainfrom
lead/train-1124000129

Conversation

@ashhart

@ashhart ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

CI for a landing train: #4694 #4641 #4673 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.

MaverickKB and others added 19 commits November 23, 2026 23:59
…d edge and a ragged tile

(cherry picked from commit 0470bc0)
Each threadgroup is 64 x 128 with four warps of 32 x 64, so a loaded fragment feeds two MMAs where MLX's 32 x 32
warp feeds one, and the K chain is MLX's own: 32-deep steps in order. Every output's sums, the latent and the PNG are
unchanged; test-h3-gemm holds the new kernel against MLX's bit for bit across a band edge, a whole band and a ragged
tail. At 4,120 rows the shapes run at 116, 116, 108 and 103 TFLOP/s against MLX's 118, 118, 113 and 89, so the
products sit at the tensor units' rate and only the 14,336-deep fc2 gains (0.3 s of the six steps); warm 2048
pictures took 12.12 and 12.13 s against 12.30 s.

(cherry picked from commit 8d6f94c)
The image decoder decodes up to its scratch's 64 tiles a pass instead of 16, two passes at 2048x2048 instead of
eight; every tile's pixels are independent, so the latent and PNG are byte-identical.

(cherry picked from commit b6b209f, decoder part only)
…o plan.hpp

row_xor, wave_sum_dpp, kMaxGroup, kScoreKeys, kScoreSteps, cache_load,
score_fetch, score_store and plan_score256_body move verbatim into an
anonymous namespace of decode/plan.hpp, which now includes ops/common.hpp,
so a second kernel source can run tf_plan_score256_*'s body. Only one
comment changes, kScoreKeys' (kScoreKeysShort stays in plan.hip).

Pure code motion: with ROCm 10.1's hipcc, the disassembled code objects of
recurrence/gated_delta.hip, decode/decode.hip and decode/plan.hip, the
sources that include plan.hpp, are identical before and after on gfx1030,
gfx1100, gfx1151 and gfx1201. plan.hip falls from 599 to 486 lines.

Refs #3811
…ys at d 256

decode/plan_rows.hip, a new code object group, adds two score kernels
with tf_plan_score256_*'s arguments and grid, a block a plan row:

- tf_plan_lone_score256_f16 and _bf16 score the rows of one-row slots
  with plan_score256_body, the one-row kernel's body, and its LDS (one
  row's queries), and leave for the other rows;
- tf_plan_rows_score256_f16 and _bf16 score the multi-row slots' rows
  in chunks of two led from the slot's `first`: the chunk's first row's
  block reads the keys once, up to the further row's, and works each
  row's dots in the tree's operands and order, a key past a row's own
  scored -inf as the tree scores it; the other blocks leave, so a chunk
  never crosses a slot. Its LDS holds two rows' queries.

One predicate (plan_shared_at) picks the rows of the chunks for both, so
each row is scored by exactly one of them.

planScore is planCausalAs's score step on its own. With `.shared`, at
d = 256 on long spans with q fp32, it launches the two kernels on the
same grid; elsewhere, and with `.one`, it launches today's kernel.
planCausalAs passes `.one`, so no walk changes here.

The contract runs the two launches as one operator, a replacement of
tf_plan_score256_*, for both head groups (16 over 2, 24 over 4) and both
cache kinds. Gate 3 requires the replaced kernel's bytes on 16 shapes a
case: launches of 1 to 64 rows over slots of 3, 1, 4 and 2 rows one
position apart (at the span's end, mid-span, across a block's first key,
at the span's start) and over 5 and 7 one-row slots, spans of 16,384 to
262,144 keys, NaN and infinite keys that some rows of a chunk see and
others do not, and NaN queries. Its controls go red at gate 3: chunks
led over the whole launch (every slot's first 0, its count every row),
and the chunks' launch alone. Gate 5's records are ROCm 10.1's hipcc on
gfx1030, gfx1100, gfx1151 and gfx1201: tf_plan_lone_score256_* 108
VGPRs and 16 KiB of dynamic LDS, tf_plan_score256_*'s; and
tf_plan_rows_score256_* 115 VGPRs and 32 KiB.

Refs #3811
planCausalAs passes `.shared` to planScore when its launch holds more
than one row. At d = 256 on long spans with q fp32, the Qwen
checkpoints' served decode walk, a round's score step is then two
launches: the one-row slots' rows at the one-row kernel's occupancy, and
the multi-row slots' rows in chunks of two from one read of their keys.
One-row launches keep a single tf_plan_score256_* launch; q in the
cache's kind, d = 128 and spans under 16,384 keys keep their kernels;
softmax, the values' walk and the tiles' sum are unchanged. The grid,
the launch arguments and the replay key stay as they were.

The whole score step against the tree on gfx1151 (medians of 15
alternated runs): one slot of 2 or 4 rows -14.0% to -18.5% (16 heads
over 2) and -31.1% to -32.3% (24 over 4) at 131K and 262K keys; a
2-row slot with two 1-row slots -6.0% to -15.3%; 2 or 4 one-row slots
+0.6% to +0.9%, the second launch's blocks leaving at once.

A kernel test walks a round's slots one position apart through
planCausal (slots of 3, 1, 2 and 4 rows; 1, 4 and 3; four of one row;
and 2, 1, 1, 3, 1 and 4) with NaN and infinite keys and an infinite
value, and requires the bits of each row walked alone in a one-row
launch, in its scores and its rows. The pinned NaN digests of
plan_pin.zig, whose d = 256 q fp32 case is a two-row launch, are
unchanged.

Refs #3811
@ashhart ashhart closed this Nov 24, 2026
@ashhart ashhart reopened this Nov 24, 2026
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

Stopped at #4641: it moved after it was stacked.

@ashhart ashhart closed this Nov 24, 2026
@ashhart
ashhart deleted the lead/train-1124000129 branch November 24, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants