Repository navigation
hip flashnext: stage each tile's q rows once in LDS in tf_fn_idx_scores - #3601
Merged
Merged
Conversation
gilby
force-pushed
the
strix/hip-idx-scores-lds
branch
from
November 16, 2026 19:24
9cf47b8 to
04b2741
Compare
Owner
|
Thanks @gilby. Staging the block's q rows in LDS once gives the waves the same values they read from global memory, in the same order, so the scores stay bit for bit. The early exit is uniform across the block, so every thread reaches the barrier, and widths over 512 keep the direct reads. With the new contract, the two-tile test and your gfx1151 receipts, this is ready. The only conflict is a changelog line, which we'll resolve when it lands. Nothing more is needed from you; it's in our landing queue.
|
ashhart
force-pushed
the
strix/hip-idx-scores-lds
branch
from
November 17, 2026 01:38
04b2741 to
0969ecc
Compare
Owner
|
Thank you @gilby. 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 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.
Problem
tf_fn_idx_scores(zig/kernels/hip/flashnext/indexer.hpp) walks up to fourkMost(32-wide) pooled-key slots per wave for eight rows (r0..r1) a block. Because each lane readq[(r * heads + h) * dims + d]directly from global memory on every block tile alongx(blocks / 8grid columns), the sameqtile was re-read from memory across every block wave andkMoststep.Change
qs[8 * kStage](16,384bytes LDS,kStage = 512) once per(blockIdx.x, blockIdx.y)tile whenheads * dims <= kStage, after a block-uniform early exit (tileoverb0 = blockIdx.x * kFnWaves) so inactive decode-graph blocks exit before readingqor hitting__syncthreads(), then keep the per-wavewantedcheck before readingpooled.tf_fn_idx_scoresunder Gate 1–4 kernel contracts (zig/tests/hip/contract_idx_scores.zig,zig/tests/hip/contract_main.zig) including a plantedone_head_shortcontrol caught byshapes, plus Gate 5 RDNA records (zig/src/core/contract/hip_records_sparse.zig, ROCm 10.1 counts:24VGPRs /39SGPRs ongfx1030/gfx1100/gfx1151,23VGPRs /40SGPRs ongfx1201,16,384LDS,0scratch,bound 256,wave32) and unit coverage inzig/src/hip/kernel_tests/flashnext_attn.zig+docs/kernel-contract.md.rocprofv3 --kernel-trace(Qwen3.8-Flash-Next-oQ4e-tf-hip2,gfx1151,--context 131072 --parallel 4 --prompt-cache-gib 0)tf_fn_idx_scores)origin/main(5987b9b5...)6a57c62b...)4prompt tok,4gen tok)0.238 ms0.209 ms1.14x(-0.029 ms)8K(7,377prompt tok,max_tokens=1)276.003 ms141.524 ms1.95x(-134.479 ms,-48.7%)32K(29,364prompt tok,max_tokens=1)2,873.855 ms2,091.387 ms1.37x(-782.468 ms,-27.2%)Without the block-uniform
tilecheck ahead of__syncthreads(), captured HIP graphs over--context 131072(grid.x = 1,049,088in warmup) paid0.467 mson that 4-token graph replay instead of0.209 ms.Serving benchmarks (
main / this / this / main, Strix Halogfx1151,Qwen3.8-Flash-Next-oQ4e-tf-hip2)Flags:
TENSORFOLD_MEMORY_RESERVE_GIB=4 --host 127.0.0.1 --port 28191 --context 131072 --parallel 4 --prompt-cache-gib 0, page cache dropped (sync; echo 3 > /proc/sys/vm/drop_caches) before every server,performancepower mode throughout.86,736,945,152bytes identically onarm1-main,arm2-this,arm3-this,arm4-main(out of123,480,309,760bytes total).bench_cache.py --require-cold --tokens 16 --repeats 1:arm1-mainarm2-thisarm3-thisarm4-mainmean)cold-2k(2,048t)cold_firstTTFT3.190 s3.197 s3.172 s3.196 s+0.26%(tie)cold-2k(2,048t)repeatedTTFT2.514 s2.520 s2.525 s2.527 s-0.11%(tie)cold-2k(2,048t)concmakespan6.309 s6.313 s6.303 s6.312 s+0.04%(tie)cold-8k(7,377t)cold_firstTTFT9.485 s9.365 s9.367 s9.494 s+1.31%(WIN,-124 ms)cold-8k(7,377t)repeatedTTFT8.844 s8.741 s8.749 s8.853 s+1.17%(WIN,-104 ms)cold-8k(7,377t)concmakespan19.999 s19.771 s19.767 s19.994 s+1.14%(WIN,-228 ms)cold-8k(7,377t)concfast / slow TTFT8.851 / 19.563 s8.739 / 19.334 s8.752 / 19.330 s8.848 / 19.557 s+1.18% / +1.17%(WIN)cold-32k(29,364t)cold_firstTTFT39.203 s41.716 s38.479 s39.141 s-2.36%(1-arm first-fault spike; tie)cold-32k(29,364t)repeatedTTFT38.374 s37.939 s37.879 s38.430 s+1.28%(WIN,-493 ms)cold-32k(29,364t)concmakespan79.592 s79.307 s79.353 s80.494 s+0.89%(-713 ms)cold-32k(29,364t)concfast TTFT38.407 s38.034 s38.159 s38.667 s+1.14%(WIN,-441 ms)bench_concurrent.py --levels 1,2,4 --tokens 256 --reps 3 --alone --serial --temperatures 1.0,0 --prompts tools/bench_prompts.json:Tagg_tps(m1 / t1 / t2 / m2)steady_tps(m1 / t1 / t2 / m2)req_decode_tpsagg_prompt_ttft_tps1.0146.4 / 46.4 / 46.4 / 46.4(+0.00%)—46.36 / 46.41 / 46.40 / 46.3878.86 / 78.56 / 78.93 / 78.621.0265.9 / 65.4 / 65.0 / 64.8(-0.23%)69.2 / 69.2 / 69.2 / 69.134.71 / 34.76 / 34.61 / 34.8486.88 / 87.01 / 86.95 / 86.811.0474.1 / 74.1 / 74.3 / 74.0(+0.20%)80.8 / 80.1 / 80.3 / 80.119.67 / 19.71 / 19.74 / 19.6883.90 / 84.61 / 84.55 / 84.470.0152.9 / 52.9 / 52.9 / 52.9(+0.00%)—52.85 / 52.93 / 52.94 / 52.8879.01 / 79.09 / 79.07 / 78.850.0272.3 / 71.5 / 71.6 / 72.2(-0.97%)75.5 / 75.5 / 75.7 / 75.537.10 / 36.85 / 37.21 / 37.0387.17 / 87.19 / 87.11 / 87.090.0475.6 / 75.8 / 76.1 / 75.7(+0.40%)85.2 / 85.6 / 85.2 / 85.021.38 / 21.32 / 21.81 / 21.4885.11 / 85.16 / 85.12 / 85.10bench_openai.py --tokens 256 --reps 3(decode_tps_median/ttft_s_median):fibonacci-raw(T=1.0):49.76 / 49.82 / 49.86 / 49.71(+0.21%), TTFT0.194 / 0.193 / 0.192 / 0.193 sgpu-chat-no-think(T=1.0):38.26 / 38.48 / 38.36 / 38.45(+0.17%), TTFT0.338 / 0.337 / 0.339 / 0.338 sfibonacci-raw(T=0.0):50.18 / 50.25 / 50.27 / 50.19(+0.15%), TTFT0.193 / 0.192 / 0.193 / 0.194 sgpu-chat-no-think(T=0.0):43.47 / 43.52 / 43.52 / 43.47(+0.12%), TTFT0.339 / 0.338 / 0.338 / 0.339 sToken identity & checks
bench_cache:12/12rows equal (4/4per prompt length:cold-2k7e13a80e2db1,cold-8k7106730d9614,cold-32kcc64c3fb3853; allqualified: true).bench_concurrent:42/42cross-armtoken_sha256equal;168/168aloneequal;96/96serial("draft": false) equal.bench_openai:12/12token_shaequal underentry["evidence"].9cf47b894(gfx1151, Strix Halo):zig build hip-kernel-contract:PASS limits live flashnext tf_fn_idx_scores(24VGPRs,16,384LDS);162kernels pass gates 1–4 (0fail,2pre-existing known findings),43/43planted controls red,2pre-existing limit problems (tf_moe_combine_gate,tf_vl_resize).zig build hip-kernel-contract-limits -Dhip-relax-branches=true:PASS(record current) fortf_fn_idx_scoresacrossgfx1030,gfx1100,gfx1151,gfx1201.zig build hip-kernel-test:22/22 steps succeeded; 219/226 passed (7 skipped). (PASSon unit test and planted-control fault caught byflashnext_attn.zig:232.)zig build hip-kernel-contract:162/162pass gates 1–4,43/43controls red.zig build check-hip-kernel-contract-host hip-host-test test-kernel-contract -Dhip=true --summary all:47/47 steps succeeded; 312/312 passed.zig build test -Dhip=true(umask 022):771/771 steps succeeded; 6177/6228 passed (51 skipped).rocprofv3summary: https://gist.github.com/gilby/f290b865992369db4d39ab4e96657480Checklist
zig fmt --check zig/cleancontract_idx_scores.zig) and Gate 5 ROCm 10.1 record (hip_records_sparse.zig) added and verified ongfx1151312/312on macOS,6177/6228with51skipped on Ubuntu-Dhip=true) andhip-kernel-test(219/226,7skipped) passmain / this / this / mainserving benchmarks pass with zero#2984regressions and 100% token-hash identitytools/pr_check.py,unwrap_md.py --check, andpublish_check.py --upstreamclean