Repository navigation
tests: size the flash-attention K/V at the kernel's 64-token tile, and pin the fallback (engine#2870) - #433
Merged
bong-water-water-bong merged 4 commits intoNov 20, 2026
Conversation
This was referenced Nov 20, 2026
added 4 commits
November 19, 2026 23:23
…d pin the fallback The split-attention fixtures allocated K/V at exactly key_value_token_count, so the kv=65 and kv=513 cases handed the matcher a cache it refuses by design (engine#2494: key->ne[1] >= ceil(kv/64)*64). A real cache is allocated to the tile, so the rig is now too, and the mask widens with it -- that is the length the kernel is handed. The rows the split arm cannot take (kv not a 64-token multiple, or past the engine#679 cap of 2944) now assert the fallback explicitly instead of failing on the split arm's transients: one launch per query row, none of the split transients, and never the split kernel. Ports the fix from tests/fa-kv-tile-capacity (llama.cpp#430) onto 1bit/hrx-vulkan-patched, whose exported matcher was already renamed, and adds the fallback guard for the 2304/4096/16384 rows #430 leaves out.
…the split arm The first version of the fallback guard sent every padded row down the "not the split arm" branch, which the device rejected: kv=513 over a tile-sized cache IS the split arm, and that is the point of the tile. The mask keeps the graph's logical key length (it is what tells the matcher how many keys are real), so mask, mask row bytes and the key_value_token_count parameter stay at the token count; only the K/V storage is padded. The guard now covers just the case #429 defines: past 2944 tokens the split dispatch is not offered at all. fa_decode_split on gfx1201: 5 passed, 0 failed (was 3 passed / 2 failed).
The >2944 block never ran: no case passed kv past the cap. kv=3008 is the smallest 64-token multiple above it, so the padded storage is exactly the shape the general matcher accepts and the split matcher declines; the block now pins the general kernel by name instead of only "not the split one". kv=65 is the shape engine#2494 blamed and is now legal for the split arm. Both cases are plan-only: they check which kernel the scheduler picks.
Same fixture as test-hrx-ops: K/V storage at ceil(kv/64)*64, mask at the logical length, capacity by the tile instead of power-of-two doubling. Its kv513 rows now reach the split arm instead of the general kernel. Two stale expectations in this suite kept the five rows red even for kv512, where the allocation was already aligned: the Q8_1 alternate is registered on the attention output while the row looked it up on the reshape that aliases it, and the split kernel is Exact, as the untouched kv320 row already shows. Both are plan-only rows.
bong-water-water-bong
force-pushed
the
corpus/fa-kv-tile-on-hrx
branch
from
November 20, 2026 03:35
07928ba to
a463160
Compare
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.
The split-attention fixtures allocated K/V at exactly
key_value_token_count, so the kv=65 and kv=513 cases handed the matcher a cache it refuses by design:dispatch-flash-attention.cpprequires the storage to be at least the padded capacityceil(kv/64)*64(engine#2494, added after the kv65 page faults). A real cache is allocated to the tile, so the rig is now too.The mask is left alone:
mask->ne[0]is the matcher'skey_value_token_count, i.e. how many keys are real. Padding it would rewrite the shape under test (and silently turn kv=513 into kv=576, so the split arm would be selected for a different reason). Only the K/V storage is padded.Ports the same fix as #430 (
tests/fa-kv-tile-capacity) onto1bit/hrx-vulkan-patched, where the exported matcher is alreadyggml_flash_attention_decode_split_f32_f16_wmma_next_q8.Evidence (ryzen, gfx1201,
GGML_HRX_GTT_RESERVE_MB=1024, SDK libhsa on LD_LIBRARY_PATH)fa_decode_split— before: 3 passed / 2 failed (fa_decode_split.4.513,fa_decode_split.4.513.true.96.64.1/sqrt(96.0f), both failingplan.dispatches.size() == query_token_countbecause the split arm declined and nothing else took the node). After: 7 passed, 0 failed, 372 ms — kv=513 now reaches the split arm over its 576-slot cache, which is the behaviour the fix exists to prove.Rebased onto
bccadbe54(Merge pull request #432); the two commits that landed as #432/#434 dropped out of this diff.Second commit (
tests: reach the decode-split fallback above the cap, and add kv=65): the branch's ownif (key_value_token_count > 2944)block had never executed, because no case passed kv past the cap — every caller used 512 or 513. It also asserted the wrong thing: above the cap a row keeps one launch per query row with the general kernel taking the node, not one launch total, and the arm there isloom_libs:ggml_flash_attention_f32_f16_wmma, not "anything but the split kernel". Fixed and made reachable byfa_decode_split.1.3008(the smallest 64-multiple past the cap), added alongsidefa_decode_split.1.65— the shape engine#2494 blamed and which is legal for the split arm now.Third commit ports the same fixture to
tests/hrx-ops-test.cpp, replacing its power-of-two cache doubling (64, 128, 256 …) with the kernel's 64-token tile, which is what the matcher actually requires.Full
test-hrx-opson this branch: 16 passed, 274 failed, 290 total, 674343 ms. Every one of the 274 isgraph_compute: no HRX dispatch registry for target gfx1201— this box cannot build the HIP add-on (__builtin_amdgcn_wmma_f32_16x16x16_f16_w32needswmma-256b-insts,wavefrontsize32, which gfx1201 lacks), so that total measures the absent add-on, not this diff. The gate number is 46 of 271 on gfx1151; see engine#2774.Also carries, as separate commits
hrx: promote the installed-package targets to GLOBAL so the HRX unit tests link(hrx: promote the installed-package targets to GLOBAL so the HRX unit tests link #432). Without it a tree configured against the installedhrxpackage does not generate at all.hrx: compile against the loomc C API that ships.loom-jit.cppcalledloomc_link_index_builder_allocate/_free; the installed loomc exports_create/_release, soggml-hrxdid not compile and no HRX test binary could be built in a package-configured tree.Both are defects independent of engine#2870 and could land first.
Not done here, and now known not to be needed
I had written that the
flash_attention.{64..512}.2.65.1group needs its padded tail masked out and the padded slots zeroed. That was wrong in purpose: those eight rows pass unchanged on a tree that builds the add-on —They were only ever red in a tree with no add-on, where no amount of fixture padding helps. So there is no follow-up change to make here; see engine#2870.