Skip to content

perf(hip): multi-row decode rounds score each slot's rows from one read of their keys - #4673

Closed
AbrahamCete wants to merge 3 commits into
ashhart:mainfrom
AbrahamCete:perf/hip-decode-rows-share-score
Closed

AbrahamCete wants to merge 3 commits into
ashhart:mainfrom
AbrahamCete:perf/hip-decode-rows-share-score

Conversation

@AbrahamCete

@AbrahamCete AbrahamCete commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

At d = 256 on long spans (the Qwen checkpoints' served decode walk), every row of a decode round reads its slot's whole
key cache in the score step, so the pending token and each drafted row of a stream pay for the same reads. Now a
multi-row round's score step is two launches on today's grid: the rows of one-row slots take today's kernel body at
today's occupancy, and the rows of multi-row slots are scored in chunks of two, a chunk's keys read once. Each row keeps
the tree's operands and the order of its sums, so the scores' bytes are today's. One-row rounds keep today's single
launch. This is the score half of #3811; the values' walk (apply) is a separate pull request, stacked on this one.

The shape follows ashhart's answer on #3811 (issuecomment-7077344772):

  • Two stacked pull requests, score first, then apply. Each has its own LDS and occupancy trade-off (your 2-row score
    and 4-row apply chunks), and separate PRs let each carry its own contract cases, planted control and timing.
  • Leading a chunk from first and count with the grid unchanged is the right fit for graph replay: the replay key
    stays as it is, and a chunk never crosses a stream. One-row rounds should keep today's kernels.
  • New entry points in a new file beside plan.hip, with their records beside hip_records_score.zig, as you suggest.

For landing, what you listed: byte checks with NaN/inf-poisoned caches, rows away from the span's end and several
streams in one launch, the HIP contract SUMMARY line, and served receipts on the head: token hashes equal to main,
drafted equal to "draft": false, and decode at 131K and 262K with drafts on.

Design.

  • decode/plan_rows.hip, a new kernel group appended to zig/build/hip.zig and zig/src/hip/kernels.zig, holds two
    score kernels with tf_plan_score256_*'s arguments and grid, a block a plan row:
    • tf_plan_lone_score256_{f16,bf16} scores the rows of one-row slots with plan_score256_body, the one-row kernel's
      body, and its LDS (one row's queries, 16 KiB at most); its other blocks leave at once.
    • tf_plan_rows_score256_{f16,bf16} scores the rows of multi-row slots in chunks of two, led from the slot's first
      and count. The block of a chunk's first row loads the keys once, up to the further row's, and works each row's dots
      in the tree's order; a key past a row's own is scored -inf as the tree scores it, not given weight 0. The other
      blocks leave at once, so a chunk never crosses a slot. Its LDS holds two rows' queries (32 KiB at most).
    • One predicate, plan_shared_at, decides for both which rows are in chunks, so each row is scored by exactly one
      launch.
  • planScore is planCausalAs's score step on its own. planCausalAs passes .shared when its launch holds more than
    one row; then, at d = 256 on spans of 16,384 keys or more with q fp32, it launches the two kernels on the same grid.
    One-row launches, q in the cache's kind (act), d = 128 and shorter spans keep their kernels, and softmax, the values'
    walk and the tiles' sum are unchanged. The grid, the launch arguments and the replay key do not change; the score's
    dynamic LDS follows from the shape.
  • plan.hip was at 599 lines, so the first commit moves the long-span score's pieces (row_xor, wave_sum_dpp, the
    constants, cache_load, score_fetch, score_store, plan_score256_body) verbatim into plan.hpp for both
    sources. With ROCm 10.1's hipcc the disassembled code objects of the three sources that include plan.hpp
    (gated_delta.hip, decode.hip, plan.hip) are identical before and after on gfx1030, gfx1100, gfx1151 and
    gfx1201. plan.hip falls to 486 lines.

Why two launches. The first version was one launch: the shared kernel for every row of a multi-row launch. The
replay key holds the round's rows, not its rows per slot, so it took every multi-row launch, including several streams
with no drafts, where nothing is shared and its two rows of queries in LDS halve the blocks a CU. Kernel time against the
tree (medians of 15 alternated runs at the span's end):

Launch 16 heads over 2, 128K 256K 24 heads over 4, 128K 256K
one slot, 2 rows -22.0% -17.4% -33.3% -33.3%
one slot, 4 rows -20.8% -16.0% -32.7% -32.4%
2 slots, one row each +10.2% +12.0% +2.2% +1.7%
4 slots, one row each +10.6% +13.3% +2.1% +2.4%

With the one-row slots' rows on today's body in their own launch, the whole score step (both launches) against the tree:

Slots in the launch 16/2, 131K 16/2, 262K 24/4, 131K 24/4, 262K
{2} 1,347.0 -> 1,097.3 us, -18.5% 2,642.1 -> 2,248.5, -14.9% 2,587.9 -> 1,754.1, -32.2% 5,058.4 -> 3,426.1, -32.3%
{4} 2,646.0 -> 2,199.5, -16.9% 5,229.9 -> 4,499.5, -14.0% 5,106.3 -> 3,489.6, -31.7% 10,055.9 -> 6,930.9, -31.1%
{1, 1} 1,359.6 -> 1,369.4, +0.7% 2,635.3 -> 2,655.2, +0.8% 2,573.0 -> 2,588.4, +0.6% 5,040.8 -> 5,071.5, +0.6%
{1, 1, 1, 1} 2,678.2 -> 2,700.7, +0.8% 5,234.2 -> 5,279.3, +0.9% 5,092.6 -> 5,122.0, +0.6% 10,052.1 -> 10,118.7, +0.7%
{2, 1, 1} 2,671.2 -> 2,510.5, -6.0% 5,232.3 -> 4,915.7, -6.1% 5,065.0 -> 4,310.0, -14.9% 10,060.3 -> 8,517.0, -15.3%

Each side's interquartile range over its 15 runs is 0.1% to 2.9% (5.0% for one cell). The +0.6% to +0.9% left on
one-row slots is the second launch's blocks leaving at once (10 to 67 us a step). Served, the same no-drafts rounds read
level (the Receipt). A variant with 512-key blocks in the second launch cut that cost to +0.1% to +0.3% but lost most of
the gains (+5.2% and +7.6% in two cells), so it is not here.

Beyond the plan, or where it was silent; say which you want changed:

Size: +910/-139 in 14 files, three commits; 418 of those lines are the contract's test type.

Checks on this head

  • Head commit: 00a2faf on main a325f58, built from a git archive tree; the checks below ran on it. Before the
    rebase each of the three commits passed its own checks on d7f1f40: lean, zig fmt --check, git diff --check,
    pr_check, hip-host-test and check-hip-kernel-contract-host, the first commit's hip-kernel-build, and on the
    second the kernel contract (the same SUMMARY as below), its limits and hip-kernel-test (235 of 242, 7 skipped).
    The receipts ran on 448b93710, these three commits on d7f1f40 (see Not run).
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 165 and 165, 0 new.
    python3 tools/pr_check.py --base origin/main: 0 errors, 1 advisory warning (the changelog line needs this pull
    request's number).
  • Tests run, with the command and pass, fail and skip counts:
    • zig build hip-kernel-test -Dhip=true -Dhip-arch=gfx1151 on the GPU: 236 of 243 passed, 7 skipped, 0 failed. The new
      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. plan_pin.zig's pinned NaN digests are unchanged;
      their d = 256 q fp32 case is a two-row launch, so it now runs the shared kernel.
    • zig build test test-golden -Dhip=true: 12,854 of 12,949 passed, 94 skipped, 1 failed. The failure is not in files
      this changes: stage_hip_test "every staged call on HIP memory equals the reference, whole and in parts"
      (zig/src/fabric/tp/, which imports none of the changed files; feat(hip): Inkling 2 attention kernels under the kernel contract #4633 reports it failing on main too).
    • The host test of the dispatch (launches/plan.zig): one-row launches, act, d = 128 and short spans keep their
      kernels.
    • zig fmt --check on the changed files and git diff --check: clean.
  • The new tests fail before their change:
    • the dispatch's host test, with the one-row rule inverted: expected 2, found 1;
    • with chunks led by the launch's row index (crossing slots), all four contract registrations go red at gates 1 and 3
      (at 8x16x16387 its bytes differ from tf_plan_score256_f16's from byte 3146304), and so does the kernel test;
    • with the first launch scoring no row, all four registrations go red at gates 1 and 3, and the kernel test fails;
    • the gate-5 records first registered empty: stale on all four chips.
  • CI: green on 00a2faf: fmt, zig, zig-b, zig-windows, zig-macos-dev-tools, pytest,
    release-paths (ubuntu-24.04), benchmark-clients (ubuntu, windows) and
    comfyui-moss-installer pass; host-nightly-linux and host-nightly-macos skipped.
  • Not run, and why:
    • gfx1030, gfx1100 and gfx1201 on a device: I have only gfx1151. They build, and their records match the code objects.
    • Sampled requests (every served cell is greedy), more than four streams, and Nemotron (d = 128, which never takes these
      kernels).
    • DFlash2's 8-row blocks (--drafter, which HIP serves since feat(hip): serve Qwen3.8-27B with its DFlash2 drafter #3665): not measured; the kernels take any rows a slot.
    • Served receipts on this rebased head: they ran on main d7f1f40 against these three commits on it (448b93710).
      The rebase changed none of the three commits' patches. main's 123 commits since d7f1f40 change the lanes'
      copy pricing and Qwen's HIP drafting and engine (core/lanes/copy_price.zig, core/lanes/lone_copy.zig,
      qwen3_5/backend/hip/draft/, engine/native.zig, engine/hip_lanes.zig), and none of the walk's sources.

Receipt

  • Main against branch: main d7f1f40 (B) against 448b93710 (C, these three commits on it), both built by the same script
    from clean git archive trees (ReleaseFast, gfx1151). One fresh server a run, alternated B1 C1 C2 B2 in every cell,
    an explicit --prompt-cache-gib on every start, temperature 0, seed 1234. Each start waited for a quiet machine
    (memory, no other server, the GPU idle for 10 s, no other /dev/kfd holder), and /dev/kfd was sampled every 3 s
    during every run. One foreign holder, 14:08:03-14:08:13Z, fell inside B1's cold 258K fill, before its timed turns.

    One stream with drafts (Qwen3.6-35B-A3B, MTP). perf(hip): score the planned decode walk at d = 256 without element tests #3508's turn method: K + 8 tokens cold, then 8 turns of the K kept
    tokens plus 200 fresh, 128 reply tokens, drafts on, off, off, on in each of two fresh stretches. Decode tok/s, medians
    of both servers a side:

    Kept tokens, stretch main this head change
    131,072, drafts on, stretch 1 27.89 (27.83-27.96) 28.16 (28.01-28.48) +0.96%
    131,072, drafts on, stretch 2 27.33 (27.32-27.40) 28.10 (27.94-28.18) +2.83%
    131,072, "draft": false 35.73 (35.66-35.81) 35.76 (35.61-35.80) +0.06%
    258,048, drafts on, stretch 1 17.35 (17.32-17.39) 17.80 (17.75-17.85) +2.62%
    258,048, drafts on, stretch 2 14.54 (14.49-14.55) 15.01 (14.98-15.02) +3.27%
    258,048, "draft": false 23.02 (22.93-23.07) 23.04 (23.01-23.07) +0.08%

    The four drafts-on rows are faster beyond both sides' ranges; "draft": false is level. The first token of a
    resumed turn reads level: 0.739 s on both at 131K, 1.260 s against 1.256 s at 258K.

    Four streams (--parallel 4): four distinct prompts filled cold, then two rounds of prompt 1 alone (128 tokens)
    and the four together (256 each), with drafts on, then with "draft": false. Aggregate tok/s, medians:

    Cell main this head change
    35B-A3B 32,768, "draft": false 94.25 94.13 -0.13% (spread 0.38% / 0.12%)
    35B-A3B 32,768, drafts on, round 1 / 2 74.58 / 92.80 74.88 / 93.13 +0.41% / +0.36%
    35B-A3B 131,072, "draft": false 43.72 43.65 -0.16% (spread 0.81% / 0.64%)
    35B-A3B 131,072, drafts on, round 1 / 2 23.71 / 41.05 24.48 / 42.07 +3.23% / +2.48%
    27B 32,768, "draft": false 29.17 29.21 +0.14% (spread 0.46% / 0.11%)
    27B 32,768, drafts on, round 1 / 2 27.66 / 28.20 28.26 / 28.28 +2.17% / +0.30%

    Steady tok/s of the "draft": false rounds: -0.05% (35B 32K), -0.20% (35B 131K), +0.42% (27B 32K), all inside the
    spread. Prompt 1 alone with drafts on: +1.03% (35B 32K), +6.71% (35B 131K), +0.71% (27B 32K), each beyond the spread.
    So the no-drafts rounds that carry the kernel's +0.6% to +0.9% read level served.

    One stream with drafts (Qwen3.8-27B). The same method, with --prompt-cache-gib 18 (one stream at a 262,144-token
    window takes 16.15 GiB); its drafts as served are copies (no draft head on HIP). No foreign /dev/kfd holder was
    sampled during any run. Decode tok/s, medians of both servers a side:

    Kept tokens, stretch main this head change
    131,072, drafts on, stretch 1 8.00 (7.95-8.01) 8.23 (8.20-8.25) +2.81%
    131,072, drafts on, stretch 2 8.17 (8.13-8.18) 8.38 (8.36-8.40) +2.59%
    131,072, "draft": false 8.64 (8.60-8.65) 8.63 (8.58-8.64) -0.11%
    258,048, drafts on, stretch 1 4.85 (4.85-4.86) 5.09 (5.08-5.11) +4.96%
    258,048, drafts on, stretch 2 5.31 (5.29-5.31) 5.58 (5.57-5.58) +5.11%
    258,048, "draft": false 6.24 (6.21-6.24) 6.24 (6.21-6.24) +0.02%

    Pooled over both stretches, drafts on: 8.07 -> 8.31 tok/s (+2.91%) at 131,072 and 5.07 -> 5.34 (+5.19%) at 258,048.
    The four drafts-on rows are faster beyond both sides' ranges; "draft": false is level. The rounds, accepted and
    drafted counts of every turn are the same on all four servers, so the gain is a faster round, not more accepted
    drafts. The first token of a resumed turn reads level: 1.774 s against 1.773 s at 131K, 2.897 s against 2.898 s at
    258K. Every reply is equal request by request on all four servers (9 of 9 in each cell), and drafted against
    "draft": false gives one hash per stretch: 97a39f51eebf and 1be5faab3a2c at 131,072, df07006606e7 and
    bab906d9141a at 258,048.

  • Boxes it reaches: HIP Qwen checkpoints with 256-wide heads (Qwen 3.5/3.6/3.8) in decode rounds of more than one row at
    spans of 16,384 keys or more: drafted rounds, and several streams together.

  • New switch? No.

  • Environment: TensorFold d7f1f40 (main) and 448b93710 (these three commits on it) for the served cells, and
    a325f58 (main) and 00a2faf (this head) for the checks; Zig 0.17.0; the served builds with the system hipcc (HIP
    7.1.52801, Ubuntu clang 21.1.8) and LLVM 21's device bitcode, the kernel contract and records with ROCm 10.1's hipcc
    (HIP 7.16.26385); Ryzen AI Max+ 395 (Strix Halo, gfx1151), unified memory; Ubuntu 26.04.1, kernel 7.0.0-44;
    Qwen3.6-35B-A3B-MLX-4bit-MTP and Qwen3.8-27B-MLX-4bit. The served binaries (sha256 prefixes): main f488bf980a8f
    and head c787ad3867db for the 35B-A3B cells and the 27B's four-stream cell; main 516b6b5bcec2 and head
    df2724d4a6d1, rebuilt from the same commits, for the 27B's one-stream cells (each build embeds its scratch path).

  • Paths and platforms: ran HIP gfx1151 at one rank, both checkpoints, one and four streams, drafts on and
    "draft": false, greedy. Not run: the list under Checks.

  • Exactness:

    • Main against this head: every reply is equal request by request on all four servers of a cell: 9 of 9 in each
      one-stream cell, 24 of 24 in each four-stream cell.
    • Drafted against "draft": false: one hash per stretch on every server. 35B-A3B at 131,072: 0dc71eaf9689 and
      354d2aa6522a, the hashes of perf(hip): score the planned decode walk at d = 256 without element tests #3508's receipts; at 258,048: d42f2e2f48f7 and 9ced54eaca25.
    • Four streams: drafted against "draft": false and round 1 against round 2, one hash per phase and stream on every
      server (35B 32K: alone e05f32999d13, together 83dcb52f04c7, 46675e2d0063, d76858ae958d, bf9af62b9ee7;
      35B 131K: e88dce5eded4, then 00474f283746, 00e7354df7fa, 4ae3370f467e, 49946caeafa8; 27B 32K:
      28bb6ebb4d19, then 9aa3b4882600, 746ce67ba326, 97e08cce66af, 454d232851e5).
    • Below the server, the contract's gate 3 and the kernel test above: the scores' bytes equal today's kernel's.
  • Main against this branch, same machine and checkpoint: the tables here. Scripts and raw files: on request.

  • Decode speed before and after: the tables above.

  • Prompt speed before and after: n/a, the change reaches only the decode walk's score step. The served cells' cold
    first token (K + 8 tokens), main's two servers against this head's: 35B-A3B 172.0 and 173.3 s against 172.5 and
    172.6 s at 131,072, and 554.3 s (main's second server) against 553.4 and 552.0 s at 258,048, where main's first server
    was slowed by the foreign GPU holder above; 27B 577.0 and 578.8 s against 582.3 and 579.3 s at 131,072 (+0.5%, the
    two sides' servers do not overlap), and 1,685.5 and 1,686.0 s against 1,682.9 and 1,684.2 s at 258,048 (-0.2%).
    These are two servers a side and not tools/bench_cache.py --require-cold runs.

  • Licence of any new weights or drafter: n/a.

Kernel contract, only when a GPU kernel is new or changed
  • Kernels registered with the contract, and the kernel each one replaces: the two launches as one operator,
    tf_plan_lone_score256_* then tf_plan_rows_score256_*, a replacement of tf_plan_score256_* (gate 3 requires its
    bytes), for 16 query heads over 2 and 24 over 4, each in fp16 and bf16 caches (4 registrations):

    • gate 3: 16 shapes a registration, bit-equal: 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, one past a block's first key, at the span's start; 16 rows hold slots of 1, 2, 3
      and 4 together), launches of 5 and 7 one-row slots, and spans of 16,384 to 262,144 keys, with the rows' and keys'
      tile edges. The keys are NaN- and inf-poisoned: one key in about 40 holds a NaN of some payload or an infinity, and
      in each slot the key only its last row sees and the key past all its rows are non-finite; a row's queries carry
      quiet NaNs of distinct payloads.
    • gate 1: the classes of float64's scores (a NaN query, NaN and infinite keys), 979,173 non-finite and 1,118,363 finite
      outputs at 16 heads, fp16;
    • gate 4: exact sums at 262,144 keys, where fp16 sums would miss by 452,984,819x and bf16 by 298,394,761x (16 heads).
  • A planted control for each new kernel, and each one fails as planted, all red at shapes:

    • chunks led over the whole launch (every slot's first 0 and its count every row), so a chunk crosses a slot (fp16
      and bf16);
    • the chunks' launch alone, so no launch scores the rows of one-row slots (fp16 and bf16).
    • A row scored by both launches gets the same bytes from each, so it cannot be caught by bytes; the docs say so.
  • Each backend's SUMMARY line and exit status (gfx1151, ROCm 10.1's hipcc, HIP 7.16):

    SUMMARY gfx1151 192 kernels: 192 pass gates 1-4, 0 fail, 2 known findings; 58 controls: 58 red as planted, 0 missed; 2 limit problems; gates 618303 ms, limits 2782 ms (exit 1, on 00a2faf)

    The two limit problems are FAIL limits live lines of tf_moe_combine_gate and tf_vl_resize, whose records this
    does not touch; the first run of this contract on a head without these kernels' dispatch showed the same two.
    zig build hip-kernel-contract-limits: the four new records PASS on all four chips. The step exits 1 with 11
    problems, the same 11 as on main d7f1f40 with this hipcc (a325f58 changes no HIP record, kernel or
    zig/build/hip.zig), all in other groups: tf_moe_combine_gate (gfx1030,
    gfx1100, gfx1151), tf_vl_resize (all four chips), and the 6- and 8-bit relu2 stream tiles 2x8 and 4x4 on gfx1100.

    Records (hip_records_score_rows.zig), the same on gfx1030, gfx1100, gfx1151 and gfx1201; no scratch on any chip:

    Launch Threads VGPRs SGPRs Dynamic LDS bytes, at most
    tf_plan_lone_score256_{f16,bf16} 128 108 77 16,384
    tf_plan_rows_score256_{f16,bf16} 128 115 95 32,768

    tf_plan_lone_score256_* uses tf_plan_score256_*'s VGPRs and LDS (108, 16 KiB), so one-row slots keep its
    occupancy.

  • Chips I could not run: gfx1030, gfx1100 and gfx1201 (limits only).

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
    (Drafted equals "draft": false in every served cell, and every reply equals main's request by request. Resumed
    against fresh and concurrent against solo were not compared on their own here.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (The bits do
    not change.)
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no
    slower than without it, greedy and sampled. (Decode: no measured cell is slower beyond the spread, both checkpoints at
    one stream at 131K and 258K kept tokens and at four streams, drafts on and "draft": false, greedy; the resumed first
    token is level. Prompt: the 27B's cold first token at 131,072 reads 0.5% later on this head, two servers a side that do
    not overlap, in a step this change does not reach; no --require-cold run. Not run: sampled requests, more than four
    streams, and --drafter (DFlash2 on the 27B, which HIP serves since feat(hip): serve Qwen3.8-27B with its DFlash2 drafter #3665).)

…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 ashhart#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 ashhart#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 ashhart#3811
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @AbrahamCete. All three commits from this PR are already on main, with your authorship: they landed as part of #4754, which was stacked on this branch (a63fd8d, 400b112 and 52a8b76, each with an identical patch to yours).

There's nothing left to merge here, so I'm closing this as done. #4673 had no changelog line of its own, so #4844 adds one with your credit.

  • Synthena

@ashhart ashhart closed this Nov 24, 2026
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.

2 participants