Repository navigation
perf(hip): multi-row decode rounds weigh each slot's rows from one read of their values - #4754
Merged
ashhart merged 9 commits intoNov 24, 2026
Merged
Conversation
…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
plan_apply_body, tf_plan_apply_*'s body, moves verbatim into the anonymous namespace of decode/plan.hpp beside the d = 256 score's pieces, so a second kernel source can run it. Only that namespace's comment changes. Pure code motion: with ROCm 10.1's hipcc, the disassembled code objects and kernel notes of recurrence/gated_delta.hip, decode/decode.hip, decode/plan.hip and decode/plan_rows.hip, the sources that include plan.hpp, are identical before and after on gfx1030, gfx1100, gfx1151 and gfx1201. plan.hip falls from 486 to 421 lines. Refs ashhart#3811
…lues at d 256 decode/plan_rows.hip adds two values kernels with tf_plan_apply_*'s arguments and grid, a block a plan row: - tf_plan_lone_apply_f16 and _bf16 weigh the rows of one-row slots with plan_apply_body, the one-row kernel's body, and its LDS, and leave for the other rows; - tf_plan_rows_apply_f16 and _bf16 weigh the multi-row slots' rows in chunks of four led from the slot's `first`: the chunk's first row's block reads each value of its 128-key tile once, up to the furthest row's keys, a page at a time and eight ahead, and adds every row's and head's sum in key order with the tree's operands. A key past a row's own keys is left out of that row's sum, as the tree leaves it, not weighed 0, so a NaN or infinite value there cannot reach the row; a tile past a row's keys writes its zeros. The other blocks leave, so a chunk never crosses a slot. Its LDS holds four rows' weights of at most eight heads (16 KiB). The score's predicate (plan_shared_at) picks the chunks' rows for both, so each row is weighed by exactly one of them. planApply is planCausalAs's values step on its own. With `.shared`, at d = 256 on long spans with q fp32, where the score's blocks share, and with at most eight heads a block (the served groups are 8 for 16 heads over 2 and 6 for 24 over 4), it launches the two kernels on the same grid; elsewhere, and with `.one`, 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_apply_*, for both head groups and both cache kinds, on fp32 scores and stats. Gate 3 requires the replaced kernel's bytes on 17 shapes a case: launches of 1 to 64 rows over slots of 3, 1, 4, 2 and 6 rows one position apart (at the span's end, mid-span, one past a tile'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 values at the key only a slot's last row weighs, at the key past all its rows and at scattered keys, and NaN and infinite scores. Gate 1 adds a NaN max; gate 4 weighs every key 1, 1/2 or 1/4 and sums integer values. 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. With the lab prototype's rule (every key of a chunk added, weighed 0 past a row's own) gates 1 and 3 go red on all four registrations. Gate 5's records are ROCm 10.1's hipcc on gfx1030, gfx1100, gfx1151 and gfx1201: tf_plan_lone_apply_* 42 VGPRs and 8 KiB of LDS, tf_plan_apply_*'s; and tf_plan_rows_apply_* 81 VGPRs and 16 KiB. Refs ashhart#3811
planCausalAs passes the score's `.shared` to planApply too 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 values 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 four from one read of their values. One-row launches keep a single tf_plan_apply_* launch; q in the cache's kind, d = 128, spans under 16,384 keys and apply groups of more than eight heads keep their kernels; softmax and the tiles' sum are unchanged. The grid, the launch arguments and the replay key stay as they were. The whole values step against the tree on gfx1151 (medians of 15 alternated runs, three runs): one slot of 2 or 4 rows -22.0% to -30.4% (16 heads over 2) and -30.2% to -38.1% (24 over 4) at 131K and 262K keys; a 2-row slot with two 1-row slots -10.2% to -15.2%; 2 or 4 one-row slots +0.4% to +1.0%, the second launch's blocks leaving at once. The score and values steps together, one slot of 2 or 4 rows: -20.7% to -26.7% (16 over 2) and -31.8% to -37.1% (24 over 4). The kernel test of a round's slots in one walk adds a NaN value only a slot's last row weighs and an infinite one past all its rows, and slots of 6, 1 and 5 rows, and requires each row's bits walked alone, in its scores and its rows; with the lab prototype's weight-0 rule it fails at the first slots. Refs ashhart#3811
ashhart
force-pushed
the
perf/hip-decode-rows-share-apply
branch
from
November 24, 2026 00:37
a26855e to
6a1789a
Compare
Owner
|
Thank you @AbrahamCete. 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. |
This was referenced Nov 24, 2026
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.
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
value cache in the values step (
tf_plan_apply_*), so the pending token and each drafted row of a stream pay for thesame reads. #4673 made a multi-row round's score step read a slot's keys once; this does the same for its values. A
multi-row round's values step is now 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 weighed in chunks of four, a chunk's values read once. Each row
keeps the tree's operands and the order of its sums, so the partials' bytes are today's. One-row rounds keep today's
single launch. This is the apply half of #3811, stacked on the score half (#4673).
It follows the shape ashhart gave on #3811 (issuecomment-7077344772), as #4673 does:
Design.
decode/plan_rows.hip, perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's kernel group, gains two values kernels withtf_plan_apply_*'s arguments and grid(256 threads, a block a plan row, 128-key tile and head group):
tf_plan_lone_apply_{f16,bf16}weighs the rows of one-row slots withplan_apply_body, the one-row kernel's body,and its LDS (8 KiB); its other blocks leave at once.
tf_plan_rows_apply_{f16,bf16}weighs the rows of multi-row slots in chunks of four, led from the slot'sfirst.The block of a chunk's first row works the chunk's weights into LDS (four rows of at most eight heads, 16 KiB),
reads each value of its tile once, a page at a time and eight ahead as
plan_apply_bodydoes, up to the furthestrow's keys, and adds it into every row's and head's sum in key order with the tree's operands. A key past a row's
own keys is left out of that row's sum, as the tree leaves it, not weighed 0: the lab kernel behind HIP: every row of a decode round re-reads the whole K/V cache on gfx1151; reading it once for a stream's rows makes a 2-4 row round's attention walk 16-30% shorter at 131K-262K, same bits #3811's numbers
weighed it 0, which gives the tree's bits only while the value is finite (0 x NaN and 0 x inf are NaN), so a NaN or
infinite value there would reach a row the tree adds nothing to. A tile past every row's keys writes zeros, as the
tree's does. The other blocks leave at once, so a chunk never crosses a slot.
plan_shared_at, picks the chunks' rows for both, so each row is weighed by exactly one launch.planApplyisplanCausalAs's values step on its own, as perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673 split outplanScore. With.sharedit launches thetwo kernels on the same grid where the score's blocks share (d = 256, spans of 16,384 keys or more, q fp32) and the
values block takes at most eight heads (the served groups are 8 for 16 heads over 2 and 6 for 24 over 4); elsewhere,
and with
.one, today's kernel.planCausalAspasses it the score's.sharedwhen its launch holds more than onerow. One-row launches, q in the cache's kind (
act), d = 128, shorter spans and values groups of more than eightheads keep their kernel, and softmax, the score step and the tiles' sum are unchanged. The grid, the launch arguments
and the replay key do not change.
plan_apply_bodyverbatim fromplan.hipintoplan.hpp, beside the score's pieces perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673moved there, so
plan_rows.hipcan run it. With ROCm 10.1's hipcc the disassembled code objects and kernel notes ofthe four sources that include
plan.hpp(gated_delta.hip,decode.hip,plan.hip,plan_rows.hip) are identicalbefore and after on gfx1030, gfx1100, gfx1151 and gfx1201.
plan.hipfalls from 486 to 421 lines.docs/kernel-contract.mddescribes the two launches and their registrations, beside perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's paragraph.docs/optimization-ledger.mdgains row 39, "Drafted rows share the walk", for both halves:open H[#4673]inqwen3_5's column and
?in the others, its rough gain, and the gains measured in perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673 and here. perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673 did not addit; this pull request finishes the optimization, so the row comes with it.
Timing. The values step against the tree's
tf_plan_apply_*(the base's values step) on gfx1151, both launches:medians of 15 alternated runs at the span's end after 3 warm-up pairs, each slot with its own K/V pool; the first of
three runs in microseconds, and the change in each of the three. 16/2 is 16 query heads over 2 KV heads (the
35B-A3B's shape), 24/4 is 24 over 4 (the 27B's):
Each side's interquartile range over its 15 runs is 0.1% to 3.8% (0.1% to 1.1% on the one-row slots). With the score
step, both steps on this stack against both on today's one-row kernels, one slot of 2 or 4 rows: -20.7% to -26.7%
(16/2) and -31.8% to -37.1% (24/4). The +0.4% to +1.0% left on one-row slots is the second launch's 4,096 to 32,768
blocks leaving at once (12 to 79 us a step), as in #4673. Served, the same no-drafts rounds read level (the Receipt).
Beyond the plan, or where it was silent; say which you want changed:
values group is larger keeps today's kernel; the served groups are 8 and 6.
of four and a tail, so the contract's slots add one of 6 rows, and the kernel test slots of 6 and 5.
cache_load, the global load perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's score uses, whereplan_apply_bodyusesload(a flat load); the bits are the same, and I did not time one against the other. Its body is__forceinline__: without it the kernel took 148 VGPRs and scratch.predicate keeps the two sets apart. It would cost time, not bits.
contract_apply_rows.zigrepeats three private helpers ofcontract_walk_rows.zig(mix,finite,nonFinite)instead of exporting them.
row).
Size: +797/-92 in 13 files, four commits; 451 of those lines are the contract's test type. This is the second of the
two stacked pull requests, score then apply.
00a2faf00), onmaina325f58. This PR adds four commits,941c00fa7,55921be72,73abb2cdfanda26855e01; please review00a2faf00..a26855e01. It comes from a fork, so it targetsmain, anduntil perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673 merges GitHub lists its commits too. Commits:
atc overlap --json(2026-11-23 12:08 UTC, on 73abb2c,main556094f): incomplete (limitationsotherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit). Of the 14 open pull requests itread that share a file with this branch, 6 merge clean and for 8 it could not tell; it reports no conflict with a
pull request. It read 20 of the local worktrees; the nine conflicts it reports there are with my own local branches,
on older bases. It did not read feat(hip): Inkling 2 attention kernels under the kernel contract #4633 or perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673. For the ledger commit,
atc who docs/optimization-ledger.md(incomplete:
pullFilesUnavailable) lists no open pull request on that file. Bygit merge-treeon a26855e:clean against
main556094f, whose commits since a325f58 touch none of this stack's files; against my feat(hip): Inkling 2 attention kernels under the kernel contract #4633(Inkling 2 attention, head e90a42e) it conflicts in
zig/build/hip.zigandzig/src/hip/kernels.zig, fromperf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's commits, which add
plan_rows.hip's kernel group at the end of the same lists as feat(hip): Inkling 2 attention kernels under the kernel contract #4633 does; this pullrequest's own commits touch neither file. Whichever lands first, I rebase the other.
Checks on this head
maina325f58). The fourth changes onlydocs/optimization-ledger.md;tools/evidence_index.pyreads its row (openin qwen3_5's column,?elsewhere)with no error. The kernel test, the contract, its limits, the timing and the host suite below ran on the first three
commits as they stood before a last edit, which made one comment of
plan.hpp(its namespace comment) one lineinstead of two; that comment and the ledger commit are the only differences from this head. The served receipts ran
on 73abb2c, this head but the ledger commit;
pr_checkand the lean counts ran on a26855e. Before that edit,each of the three code commits passed its own checks from a
git archivetree:zig fmt --checkon its Zig files(the first has none),
git diff --check,hip-host-test(89, 90 and 90 passed),check-hip-kernel-contract-host,hip-kernel-buildandhip-kernel-contract-build.python3 tools/zig/lean_check.py, on the base and on this head, astools/pr_check.pyruns it: 165 and165, 0 new.
python3 tools/pr_check.py --base origin/main(merge base a325f58, the stack's 17 files) and--base 00a2faf00(this pull request's 13): 0 errors, 1 advisory warning each (the changelog line needs this pullrequest's number).
zig build hip-kernel-test -Dhip=true -Dhip-arch=gfx1151on the GPU: 237 of 244 passed, 7 skipped, 0 failed.perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's test of a round's slots in one walk through
planCausal, which requires the bits of each row walked alonein a one-row launch, in its scores and its rows, now also plants in each slot a NaN value only its last row weighs
and an infinite one past all its rows, and adds slots of 6, 1 and 5 rows (a chunk of four and a tail).
zig build test test-golden -Dhip=true: 12,766 of 12,861 passed, 94 skipped, 1 failed. The failure is the oneperf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673 reports, 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/). One step ran fromzig build's cache, so its 89 tests are not in thesecounts.
launches/plan.zig): chunks of four only where the score's blocks share and avalues block takes at most eight heads; one-row launches,
act, d = 128, short spans and groups of 16 heads keeptheir kernel; the served groups come out at 8 and 6.
zig fmt --checkon the changed files andgit diff --check: clean.planApply's rule:use of undeclared identifier 'apply_rows';error: HipFailed;at gate 1 (
80 of 4227072 outputs differ in class; first at 32770: nan where float64 gives finite, 16 heads,fp16) and gate 3 (
at 8x16x16387 its bytes differ from tf_plan_apply_f16's from byte 131080):SUMMARY gfx1151 196 kernels: 192 pass gates 1-4, 4 fail, 2 known findings; 62 controls: 62 red as planted, 0 missed; 4 limit problems; gates 626447 ms, limits 2795 ms(the two extra limit problems are that variant's 82 VGPRs against the recorded 81); the kernel test fails too, its
first difference at the element of the NaN value only a slot's last row weighs;
hip-kernel-contract-limitsreported them stale on all four chips.release-paths (ubuntu-24.04), benchmark-clients (ubuntu, windows) and
comfyui-moss-installer pass; host-nightly-linux and host-nightly-macos skipped.
kernels).
--drafter, which HIP serves since feat(hip): serve Qwen3.8-27B with its DFlash2 drafter #3665): not measured; a slot of 8 rows is two chunks.mainserver in this receipt: the base is perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head, which this stacks on (see the Receipt).Receipt
Main against branch: the base is perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head, not
main, since this pull request is stacked on it: 00a2faf (B,on
maina325f58) against 73abb2c (C, this head but the ledger commit), both built by the same script fromclean
git archivetrees (ReleaseFast, gfx1151). One fresh server a run, alternated B1 C1 C2 B2 in every cell, anexplicit
--prompt-cache-gibon 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/kfdholder), and/dev/kfdwas sampled every 3 sduring every run; no foreign holder was sampled during any run. Every token hash below is a hash of perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's
receipts, where
maind7f1f40 and perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's commits gave it on all four servers.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:
"draft": false"draft": falsePooled over both stretches, drafts on: 28.38 -> 30.02 tok/s (+5.78%) at 131,072 and 16.46 -> 17.22 (+4.60%) at
258,048. The four drafts-on rows are faster beyond both sides' ranges;
"draft": falseis level. The first token of aresumed turn reads level: 0.738 s on both at 131K, 1.250 s against 1.254 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:"draft": false"draft": false"draft": falseSteady tok/s of the
"draft": falserounds: -0.11% (35B 32K), -0.26% (35B 131K), +0.41% (27B 32K), all inside thespread. Prompt 1 alone with drafts on: +2.46% (35B 32K) and +9.43% (35B 131K), beyond the spread, and +0.32% (27B 32K),
inside it. So the no-drafts rounds that carry the kernel's +0.4% to +1.0% read level served.
One stream with drafts (Qwen3.8-27B). The same method, with
--prompt-cache-gib 18(one stream at a 262,144-tokenwindow takes 16.15 GiB); its drafts as served are copies (no draft head on HIP). Decode tok/s, medians of both servers
a side:
"draft": false"draft": falsePooled over both stretches, drafts on: 9.31 -> 9.49 tok/s (+1.95%) at 131,072 and 6.54 -> 6.78 (+3.70%) at 258,048.
Three of the four drafts-on rows are faster beyond both sides' ranges; the first stretch at 258,048 (+0.43%) is inside
them.
"draft": falseis level. The first token of a resumed turn reads level: 1.765 s against 1.767 s at 131K,2.890 s against 2.887 s at 258K. These speeds do not compare with perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's tables, which ran on
maind7f1f40: thisbase is on a325f58, whose commits since then change the lanes' copy pricing and Qwen's HIP drafting (the list in
perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673), and the 27B's drafts-on speed at 258,048 is 6.54 tok/s here on perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head against 5.34 with perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's
commits on d7f1f40.
Draft counts. In perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's 27B receipts the rounds, accepted and drafted counts were the same on all four servers;
here they differ between the two sides, most at 258,048 kept tokens, where this head drafts and accepts more. In the
35B-A3B's first stretch there, its turns take 102 to 107 rounds with 20 to 25 drafts accepted of 78 to 87, against
111 rounds with 16 of 71 on both base servers; the 27B's turns draft 22 to 29 in the first stretch and 35 or 36 in the
second, against 17 to 20 and 28 to 31. The two servers of one side do not always agree either (35B-A3B at 131,072,
first stretch: 119 and 114 drafted on the base's two). The depth rule weighs forward and head timings that each
server measures at start (
measureinqwen3_5/backend/hip/engine/hip_lanes.zigandhip_costs.zig), so a cheapermulti-row round can buy deeper drafts. Those timings are not logged, so I cannot show which of them moved. Where the
counts are close, this head is still faster: the 35B-A3B at 131,072 (+5.64% and +6.94%), and its second stretch at
258,048 (111 rounds with 16 of 116 drafts accepted, against 110 with 17 of 115: +5.38%).
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, with at most eight query heads a values block (both served shapes): drafted rounds, and
several streams together.
New switch? No.
Environment: TensorFold 00a2faf (perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head, on
maina325f58) and 73abb2c (this head but the ledgercommit) for the served cells and the checks, a26855e for
pr_check; Zig 0.17.0; the served builds with the systemhipcc (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-MTPandQwen3.8-27B-MLX-4bit. The served binaries (sha256 prefixes): basebe3226bdf2d8and head3e092b693d07, one build of each for every cell (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:
one-stream cell, 24 of 24 in each four-stream cell.
"draft": false: one hash per stretch on every server. 35B-A3B at 131,072:0dc71eaf9689and354d2aa6522a; at 258,048:d42f2e2f48f7and9ced54eaca25. 27B at 131,072:97a39f51eebfand1be5faab3a2c;at 258,048:
df07006606e7andbab906d9141a."draft": falseand round 1 against round 2, one hash per phase and stream on everyserver (35B 32K: alone
e05f32999d13, together83dcb52f04c7,46675e2d0063,d76858ae958d,bf9af62b9ee7;35B 131K:
e88dce5eded4, then00474f283746,00e7354df7fa,4ae3370f467e,49946caeafa8; 27B 32K:28bb6ebb4d19, then9aa3b4882600,746ce67ba326,97e08cce66af,454d232851e5).maind7f1f40's in perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's receipts; nomainserver ran here.
Main against this branch, same machine and checkpoint: the tables here, against perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head; perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's receipts hold
mainagainst its commits. 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 values step. The served cells' cold
first token (K + 8 tokens), the base's two servers against this head's: 35B-A3B 172.3 and 172.4 s against 173.1 and
172.5 s at 131,072 (+0.3%, the two sides' servers do not overlap), and 551.2 and 551.1 s against 548.4 and 550.7 s at
258,048 (-0.3%, nor do they); 27B 577.4 and 576.3 s against 576.2 and 580.1 s at 131,072, and 1,681.6 and 1,682.1 s
against 1,680.2 and 1,682.7 s at 258,048. These are two servers a side and not
tools/bench_cache.py --require-coldruns.
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_apply_*thentf_plan_rows_apply_*, a replacement oftf_plan_apply_*(gate 3 requires its bytes), onfp32 scores and stats, for 16 query heads over 2 and 24 over 4, each in fp16 and bf16 caches (4 registrations):
position apart (at the span's end, mid-span, one past a tile's first key, at the span's start), launches of 5 and 7
one-row slots, and spans of 16,384 to 262,144 keys. The values are NaN- and inf-poisoned: one key in 41 holds a NaN
of some payload or an infinity at one element, and in each slot the value only its last row weighs and the one past
all its rows are non-finite; the scores hold a NaN, an infinity and a negative infinity at keys some rows of a chunk
weigh.
16 heads, fp16;
by 16,777,216x and bf16 by 20,971,520x (16 heads).
A planted control for each new kernel, and each one fails as planted, all red at
shapes:first0 and its count every row), so a chunk crosses a slot (fp16and bf16);
Each backend's
SUMMARYline and exit status (gfx1151, ROCm 10.1's hipcc, HIP 7.16):SUMMARY gfx1151 196 kernels: 196 pass gates 1-4, 0 fail, 2 known findings; 62 controls: 62 red as planted, 0 missed; 2 limit problems; gates 644186 ms, limits 2802 ms(exit 1)The two limit problems are the
FAIL limits livelines oftf_moe_combine_gateandtf_vl_resize, as on perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673,whose records this does not touch.
zig build hip-kernel-contract-limits: the four new records PASS on all fourchips. The step exits 1 with 11 problems, the same 11 as on perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head, 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 ongfx1100.
Records (
hip_records_apply_rows.zig), the same on gfx1030, gfx1100, gfx1151 and gfx1201 but for one SGPR; noscratch on any chip:
tf_plan_lone_apply_{f16,bf16}tf_plan_rows_apply_{f16,bf16}tf_plan_lone_apply_*usestf_plan_apply_*'s VGPRs and LDS (42, 8 KiB), so one-row slots keep its occupancy.Chips I could not run: gfx1030, gfx1100 and gfx1201 (limits only).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.(Drafted equals
"draft": falsein every served cell, and every reply equals perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head's request by request, withperf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's hashes. Resumed against fresh and concurrent against solo were not compared on their own here.)
not change.)
--drafter, noslower than without it, greedy and sampled. (Decode, against perf(hip): multi-row decode rounds score each slot's rows from one read of their keys #4673's head: 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; the kernel's +0.4% to +1.0% on one-row slots reads levelserved. Prompt: the 35B-A3B's cold first token at 131,072 reads 0.3% later on this head, two servers a side that do
not overlap, in a step this change does not reach; no
--require-coldrun. Not run: sampled requests, more than fourstreams, and
--drafter(DFlash2 on the 27B, which HIP serves since feat(hip): serve Qwen3.8-27B with its DFlash2 drafter #3665).)