Skip to content

test-hrx-ops: 13 flash-attention rows expect the split/next_q8 kernel and get the general one #2870

Closed

Description

@bong-water-water-bong

Thirteen rows in the fork's test-hrx-ops suite fail on the HRX dispatch path used by the gate, and none of them is a value comparison: the scheduler falls through to the general ggml_flash_attention_f32_f16_wmma where the test expects the split/next_q8 path.

qwen_flash_attention   missing expected kernel: loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
                       scheduled kernels:      loom_libs:ggml_flash_attention_f32_f16_wmma
fa_decode_split.4.513  tests/test-hrx-ops.cpp:2502: requirement failed: plan.dispatches.size() == query_token_count

Aborting rows: qwen_flash_attention, flash_attention.accumulator_range.128.1024.v1000, flash_attention.{64,128,192,256,320,384,448,512}.2.65.1/...wmma, flash_attention.96.2.4.1/...next_q8.320, fa_decode_split.4.513, fa_decode_split.4.513.true.96.64.1/....

Suite line in the tree that produced it (fork 4df0f3e6c, gfx1151): 261 passed, 13 failed, 0 known-fail, 0 unexpected-pass, 274 total, 401 s.

What is ruled out: the IQ1/prefill change (empty diff for dispatch-flash-attention.cpp and ops/flash_attention.loom between 8c23f152 and that head); the mul_mat path (every dense.* row passes, and the gate's FLASH_ATTN_EXT set is inside the 3604/3604); the box (the run completed clean, no fault).

What is not established: the split path's kernels live in the private gpu-kernels add-on (addons/hip-hrx/qsa_attn_select.hip, dispatch-hip-qsa-attn-select.cpp), which this tree does not build (GGML_HRX_HIP_ADDON_DIR empty) while the gate tree does. That is suggestive rather than proof - the expected kernel name is also in this tree's own corpus includes and has a registered matcher (dispatch-flash-attention.cpp:42 and :650) - so the next step is one run of the same two cases in a tree that builds the add-on. The gate tree builds no test-hrx-ops, so that tree needs one extra target configured.

Not urgent: nothing here blocks a merge, and the FA compute path is covered by the gate. Filed so the rows are not silently carried as "the 13 we do not explain".

Activity

  1. bong-water-water-bong commented on Nov 19, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The add-on hypothesis is dead: it reproduces in a tree that does build the private add-on.

    Recipe (gate tree, which configures GGML_HRX_HIP_ADDON_DIR=/home/bcloud/.cache/hw-gate/gpu-kernels/addons/hip-hrx):

    cd ~/.cache/hw-gate/build-685489b587
    cmake --build . --target test-hrx-ops -j 8          # not built by default; links in 6 steps
    export LD_LIBRARY_PATH=$PWD
    export IREE_HAL_AMDGPU_LIBHSA_PATH=/opt/rocm-therock/lib/python3.14/site-packages/_rocm_sdk_core/lib/libhsa-runtime64.so.1
    ./bin/test-hrx-ops --hrx-ops-test-test-case fa_decode_split.4.513
    

    Result:

    tests/test-hrx-ops.cpp:2502: requirement failed: plan.dispatches.size() == static_cast<size_t>(query_token_count)
    

    Same failure, same line, in the tree that has qsa_attn_select.hip / dispatch-hip-qsa-attn-select.cpp compiled. So the row is not failing because the add-on is missing here — it fails wherever the split decode path is planned, which is the point plan.dispatches.size() is asserting.

    Two notes for whoever picks this up:

    • the free-standing binary needs IREE_HAL_AMDGPU_LIBHSA_PATH set to a libhsa that exports hsa_amd_queue_create (the distro one does not); without it every device row reports the HRX runtime did not initialise and the run is meaningless.
    • the flag is --hrx-ops-test-test-case, not --hrx-test-case (that belongs to the fork's hrx-ops-test); --hrx-ops-test-test-list prints the names.

    Next: dispatch-flash-attention.cpp:42/:650 register the matcher, so the question is now why the plan produces fewer dispatches than query_token_count for query=4/kv=513 — read plan.dispatches at that assertion rather than the matcher.

  2. bong-water-water-bong commented on Nov 19, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Instrumented the failing assertion. The planner does not fail to find a kernel — it produces one dispatch where the row expects four, and zero transients where it expects four:

    PROBE2870 dispatches=1 query_token_count=4 transients=0
    test-hrx-ops.cpp:2503: requirement failed: plan.dispatches.size() == static_cast<size_t>(query_token_count)
    

    Reproduced in the gate tree that builds the private add-on (build-685489b587, GGML_HRX_HIP_ADDON_DIR=/home/bcloud/.cache/hw-gate/gpu-kernels/addons/hip-hrx), so this is not a missing-add-on row.

    What that shape says: the plan is a single fused dispatch, not the multi-partial decode_split plan this row asserts (4 partials + transients + completion_counter_requests). The row's expectations — dispatches.size() == query_token_count, transients.size() == 4, completion_counter_requests.size() == 1 — describe the produce-partials/reduce shape, and the scheduler handed back a fused equivalent instead.

    So the row is asserting an older plan shape, and the question the issue should ask is whether the fused plan is correct for query=4/kv=513, not why a kernel is missing. That also explains the sibling abort (missing expected kernel: ggml_flash_attention_decode_split_f32_f16_wmma_next_q8 with scheduled kernels: ggml_flash_attention_f32_f16_wmma): a single-dispatch registration claims the shape first.

    Probe recipe on the box (wrapper sets LD_LIBRARY_PATH, IREE_HAL_AMDGPU_LIBHSA_PATH, and takes a gpu-hold ticket):

    ~/hrxlab.sh fa_decode_split.4.513
    

    Next: print plan.dispatches[0].registration at the same point — one field, one rebuild — and decide whether the test or the registration is wrong. GGML_HRX_LOG_DISPATCH=1 stays silent in this path even with the wrapper, so it cannot answer that.

  3. bong-water-water-bong commented on Nov 19, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Probed the plan and the matcher chain. The row is not missing a kernel — the split matcher declines the shape and the general flash-attention matcher claims it with query chunking.

    Plan at the assertion (gate tree, add-on enabled, August GPU firmware, 0 faults):

    PROBE2870 d0 kernel_id=-1306170816954099529
    PROBE2870 dispatches=1 query_token_count=4 transients=0
    

    One dispatch, and transients=0 where the row expects 4 — i.e. no partials were produced at all, so this is not the split plan with a lost reduce, it is a different plan entirely.

    Why: dispatch-flash-attention.cpp registers the general matcher, which itself calls

    append_query_chunked_dispatches(
        dispatch, match.query_token_count, flash_attention_query_chunk_tokens(match.key_value_token_count), …

    so the general kernel is query-chunked, and for query=4/kv=513 the chunk collapses the whole query into one dispatch. The split matcher, match_flash_attention_decode_split_next_q8_dispatch, first does

    const DecodeSplitFlashAttentionMatch match = match_decode_split_flash_attention_f32_f16(...);
    if (!match.matched()) { return false; }

    and for this shape it does not match, so it never gets the chance to emit the 4-partial plan the row asserts.

    So the issue as filed ("missing expected kernel") describes the symptom, not the fault: no registration is absent, and adding qsa_attn_select.hip changes nothing (verified — same failure with the add-on built). The real question is a policy question: should kv=513, query=4 take the split path (4 partials + reduce + completion counter, which is what the row encodes) or the general query-chunked path (1 dispatch)? Right now the general matcher wins, and the row's expectations — dispatches.size() == query_token_count, transients.size() == 4, completion_counter_requests.size() == 1 — are hardcoded to the split shape.

    Either the split matcher's kv threshold is too high, or the row should assert whichever plan is intended for this shape. That decision is the issue; the 13 rows follow from it.

    Side note for whoever runs this: the abort leaves 0 page faults — unlike #2861's router_common_matmul.experts128.tokens512, which page-faults four times and hangs the box. Use the flash-attention rows for device experimentation; do not loop the router case.

  4. bong-water-water-bong commented on Nov 19, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Read-only, static: the fork pin 8c23f152 tree at third_party/llama.cpp. The file the issue names is byte-identical between 8c23f152 and the tree that produced the run (the issue body already establishes an empty diff for dispatch-flash-attention.cpp), so the line numbers below should land in 4df0f3e6c too.

    1. What declines query=4 / kv=513

    The split matcher is match_decode_split_flash_attention_f32_f16 (ggml/src/ggml-hrx/dispatch_registration/common/dispatch-flash-attention.cpp:308-400), called by match_flash_attention_decode_split_next_q8_dispatch (:649) and registered at :750-757 as common.flash_attention_decode_split_next_q8, DispatchMatchKind::SingleOp, priority 75. The neighbours are common.flash_attention_f32_f16_gate (:742-749, Fused, priority 100) and common.flash_attention_f32_f16_wmma (:758-766, SingleOp, priority 50).

    It is not the query cap and not a kv threshold:

    guard file:line constant (4, 513)
    node arity — sink forms are matched only by the general dispatch :309 inputs.size() != 4 passes (4)
    dtypes :322-323 Q F32 / K F16 / V F16 / mask F16 / out F32 passes
    head sizes :330-332, :110-122 qk 16..576 step 16; value 16..512 step 16 (kDecodeMaxValueHeadSize = 512, :70) passes (128)
    batch/mask dims :341-343 ne[3] == 1, mask ne[2..3] == 1 passes
    query length :347 → :102-104 1 <= q < kDecodeRowCapacity, kDecodeRowCapacity = 16 (:46) 4 < 16 → passes
    kv token count :348 → :98-100 1 <= kv <= 262144 513 → passes
    head counts :349-352 1..64, q_heads % kv_heads == 0 passes (32/4)
    shapes/layouts :356-365 V ne[1] == key ne[1], mask ne[1] == q passes
    capacity ceiling :373-376 ceil(kv/64)*64 <= kDecodeSplitMaxKeyValueTokenCapacity = 32768 (:56) 576 <= 32768 → passes
    padded-capacity guard (engine#2494) :387 key->ne[1] < ceil(kv/64)*64 513 < 576 → return {}
    partial alignment :393 decode_split_partial_alignment() != 4096 env unset → 4096 → passes
    // dispatch-flash-attention.cpp:373-379
    match.key_value_capacity = ceil_div(key_value_token_count, kDecodeKvTileSize) * kDecodeKvTileSize;  // 513 -> 576
    if (match.key_value_capacity > kDecodeSplitMaxKeyValueTokenCapacity) { return {}; }                 // 576 <= 32768
    // :387  -- this is the one that fires
    if (key->ne[1] < match.key_value_capacity || value->ne[1] < match.key_value_capacity) { return {}; }

    The case sizes K/V at exactly the token count, so the guard always sees ne[1] == 513:

    • tests/test-hrx-ops.cpp:859 (build_qwen_flash_attention_layout_graph, :845): ggml_new_tensor_3d(F16, qk_head_size, key_value_head_count, key_value_token_count) — after the permute(0,2,1,3), key->ne[1] == 513.
    • same in run_common_flash_attention_cpu_reference_case (tests/test-hrx-ops.cpp:2237-2238, helper at :2210): ggml_new_tensor_3d(F16, head_size, key_value_token_count, 1).

    kDecodeKvTileSize = 64 (:47) is the tile the kernel walks; #2494's own comment at :380-386 records the fault that produced the guard (kv65 cases, 63 slots read past the binding, gfxhub page fault + MODE2 reset, three times in 80 minutes), and says production caches always carry capacity >= ctx — which is why production never sees it and the test rigs do.

    For completeness on the helper the assignment names: there is no flash_attention_query_chunk_tokens(kv) in dispatch-query-chunks.{h,cpp} — that header only has query_chunk_tokens(kernel_max) (dispatch-query-chunks.cpp:25-30, GGML_HRX_QUERY_CHUNK_TOKENS) which concerns query rows. The kv-dependent helper is flash_attention_query_chunk_tokens(int64_t key_value_token_count) in this same file at :460-470: returns whole (kPrefillMaxQueryTokens, :88) for kv < 4096, otherwise min(GGML_HRX_FA_QUERY_CHUNK or 256, 2048). Nothing in it gates kv=513.

    2. Which kv would match

    With the harness as written (key->ne[1] == kv), the guard reduces to kv % 64 == 0, i.e. 64, 128, …, 32768. Concretely:

    • kv = 512 matches (capacity 512) — which is exactly why fa_decode_split.1.512 and fa_decode_split.1.512.true pass today.
    • kv = 513 cannot match at any query count; 576 would match (capacity 576), and so would keeping 513 tokens but allocating K/V at 576 rows, which is what a real cache does.

    So the row is testing an unreachable shape — not because the threshold is too high (the ceiling is 32768 and 513 is far under it) but because the K/V storage is not padded to the kernel's 64-token tile. After #2494 that is by design; the rig is what is stale.

    3. Are test-hrx-ops.cpp:2490-2510 consistent with the split plan?

    Yes — exactly, and only with the split plan, at any kv that matches. The capacity the case expects is itself the padded one: const int64_t key_value_capacity = (key_value_token_count + 63) / 64 * 64; (tests/test-hrx-ops.cpp:2466), i.e. 576 for 513 — so the test already knows the plan wants padded capacity, it just does not allocate it. Each assertion maps to one construction in the matcher:

    assertion (tests/test-hrx-ops.cpp:2493-2495, sizes at :2497-2500) where it comes from
    plan.dispatches.size() == query_token_count one dispatch per query row, for (int64_t row = 0; row < match.query_token_count; ++row) :704-726
    plan.transients.size() == 4 partial_max, partial_sum, partial_output, next_q8_output pushed at :679-686
    completion_counter_requests.size() == 1, count == key_value_head_count single request at :687-691, count = match.key_value_head_count
    bindings.size() == 10, per-row offsets on query/mask/output/q8 :705-725
    q8 alternate value on the output :693-700

    So the row's expectations are a faithful description of the split plan; they cannot be satisfied by the fallback, which produces 1 dispatch and 0 transients: match_flash_attention_f32_f16_dispatch (:606) calls flash_attention_query_chunk_tokens(513) → 2048 (:460-470), then append_query_chunked_dispatches(...) (:634; dispatch-query-chunks.cpp:44-46) which for token_count 4 <= max_tokens 2048 pushes the single whole dispatch and adds no transient. That is the observed dispatches=1 query_token_count=4 transients=0 on the box.

    The rest of the thirteen rows

    Twelve of the thirteen listed rows sit on this one guard — every one of them sizes K/V at exactly kv with kv not a multiple of 64:

    • flash_attention.{64,128,192,256,320,384,448,512}.2.65.1/…wmma — kv=65 → capacity 128 (:6462-6595)
    • flash_attention.96.2.4.1/…next_q8.320 and qwen_flash_attention — kv=4 → capacity 64
    • fa_decode_split.4.513, fa_decode_split.4.513.true.96.64.1/… — kv=513 → capacity 576

    and the two rows that do size kv at a multiple of 64 pass, as the same rule predicts: flash_attention.320.2.64.1/…next_q8.64 (kv=64) and fa_decode_split.1.512 (kv=512). I did not examine flash_attention.accumulator_range.128.1024.v1000 (a value-comparison row, not a kernel-selection row) — if it is in the thirteen it has a different cause.

    No code changed, no tests run, no benchmark.

  5. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fixed for the 4 layout rows: llama.cpp#430 (draft, base 1bit/hrx-vulkan-patched, commit 2f08bfa).

    The rig now allocates K/V at ceil(kv/64)*64 — the same padded capacity the case already computed for its decode.key_value_token_capacity assertion at test-hrx-ops.cpp:2476 — and widens the mask with it. The two kernel-facing expectations move to the capacity, because that is the length the kernel is handed.

    Verified on gfx1201, one process per case, GGML_HRX_GTT_RESERVE_MB=1024:

    case before after
    fa_decode_split.4.513 1 dispatch on ggml_flash_attention_f32_f16_wmma, then requirement failed: plan.dispatches.size() == query_token_count rc 0, one dispatch per query row on ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
    fa_decode_split.4.513.true.96.64.1 same failure rc 0
    qwen_flash_attention ggml_flash_attention_f32_f16_wmma unchanged — that case passes use_common_dispatch=true deliberately

    Not fixed by this PR: the eight flash_attention.{64,…,512}.2.65.1 rows go through run_common_flash_attention_cpu_reference_case, which compares numbers rather than the plan. Padding there also requires masking the padded tail and zeroing the padded K/V slots, otherwise the comparison reads uninitialised memory — a second, separate change. So #2870 stays open for that group, and the two next_q8.320/next_q8.64 rows in it are the ones worth doing next (kv=4 and kv=64, both already tile-aligned in intent).

  6. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Two of the thirteen are fixed and three questions in the "what is not established" section now have answers, all measured on ryzen (gfx1201, RX 9070 XT).

    fa_decode_split.4.513 / fa_decode_split.4.513.true.96.64.1/... — fixed, no add-on needed

    They were never a missing-kernel symptom. The fixture allocated K/V at exactly key_value_token_count, and dispatch-flash-attention.cpp:396 requires the storage to be at least the padded capacity ceil(kv/64)*64 (the engine#2494 guard added after the kv65 page faults). So the split matcher declined a legal-shape cache and nothing else took the node, surfacing as plan.dispatches.size() == query_token_count.

    Sizing the fixture's K/V to the 64-token tile — leaving the mask at the logical key length, since mask->ne[0] is the matcher's key_value_token_count — turns them green on device:

    fa_decode_split on gfx1201, GGML_HRX_GTT_RESERVE_MB=1024
    before: 3 passed, 2 failed
    after : 5 passed, 0 failed   (key_value_capacity 576 > 513; the split arm is selected)
    

    That is 1bit-MONSTER/llama.cpp#433 (corpus/fa-kv-tile-on-hrx). Note the first version of my own guard asserted transients.empty() for padded rows and the device rejected it: any single-launch arm carries transients too. Only the #429 cap (> 2944) changes the claim.

    The add-on cannot be built for gfx1201 at all

    GGML_HRX_HIP_ADDON_DIR pointed at three different add-ons, all fail the same way:

    addons/hip-hrx/kernels/fa_prompt_f16.hip:204:25: error: '__builtin_amdgcn_wmma_f32_16x16x16_f16_w32'
        needs target feature wmma-256b-insts,wavefrontsize32
    addons/hip-hrx/kernels/glm_mla_decode.hip:357:34: (same)
    

    Same file, same toolchain (/home/bcloud/sdk-gfx1201-devel/llvm/bin/amdclang++, -x hip --cuda-device-only --no-gpu-bundle-output -O3):

    file gfx1100 gfx1151 gfx1201
    fa_prompt_f16.hip 0 errors 0 errors 2 errors
    fa_decode_q8.hip (the split arm) 0 errors 0 errors 0 errors

    So the wave32 WMMA kernels are gfx11-only — -mwavefrontsize32 does not help (also tried -Xarch_device -mwavefrontsize32), and -mwavefrontsize32 leaks into the host clang++ invocation and breaks the other code objects. The remaining eleven rows can only be exercised on a gfx1151 (strixhalo) tree, which is where the gate builds the add-on; they are not exercisable on ryzen by construction.

    The split arm itself (fa_decode_q8.hip) is fine on gfx1201, so the decode-side rows are reachable there if the gfx11-only objects are excluded from the add-on target.

    The 13 were not the suite's baseline on this box

    A tree configured without the add-on at all (GGML_HRX_HIP_ADDON_DIR empty, 4 HIP code objects) does not fail 13 rows, it fails essentially everything:

    test-hrx-ops summary: 14 passed, 274 failed, 0 known-fail, 0 unexpected-pass, 288 total, 670820 ms
    graph_compute: no HRX dispatch registry for target gfx1201
    

    i.e. "the 13" is only meaningful for a gate-shaped tree. Worth stating explicitly in the issue so the number is not read as this box's pass rate.

  7. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Now measured on the box that can build the add-on. All thirteen pass — the add-on was the whole story, so this issue's own hypothesis was right and my earlier comment on this thread was incomplete.

    Tree: strixhalo, /home/bcloud/wt/2293-lcpp @ 5450c80543, build-ops configured with GGML_HRX_HIP_ADDON_DIR=/home/bcloud/.cache/scratch-pi-hrx-mem/store610/gpu-kernels/addons/hip-hrx and GGML_HRX_HIP_TARGETS=gfx1151 (62 HIP code objects, bin/test-hrx-ops present), run with LD_LIBRARY_PATH=/work-c22/hrx-toolchain/lib/python3.14/site-packages/_rocm_sdk_core/lib (the system libhsa-runtime64.so.1 lacks hsa_amd_queue_create, which is what the "runtime did not initialise" line is about) and GGML_HRX_GTT_RESERVE_MB=1024.

    --hrx-ops-test-test-filter "(fa_decode_split|qwen_flash_attention|65\.1|accumulator_range)"
    test-hrx-ops summary: 24 passed, 0 failed, 0 known-fail, 1 unexpected-pass, 25 total, 5039 ms
    

    Every row in this issue's aborting list passes, and the split arm is what runs:

    [PASS] flash_attention.448.2.65.1/....flash_attention_decode_split_f32_f16_wm   433 ms
    [PASS] flash_attention.512.2.65.1/....flash_attention_decode_split_f32_f16_wm   412 ms
    [PASS] fa_decode_split.4.513                                                    131 ms
    [PASS] fa_decode_split.4.513.true.96.64.1/sqrt(96.0f)                            120 ms
    

    One correction to my comment above

    I said the two fa_decode_split.4.513 rows were fixed by llama.cpp PR #433. That is true only for a tree whose fixture still allocated K/V at key_value_token_count. This tree already sizes them at the 64-token tile (tests/test-hrx-ops.cpp:2466, (key_value_token_count + 63) / 64 * 64) and predates the engine#2494 storage guard, so they pass here for a reason independent of #433. Both statements hold, they are about different trees; #433 is the fix for 1bit/hrx-vulkan-patched, not for this tree. Eight of the thirteen ({64..512}.2.65.1) remain a missing-add-on symptom everywhere the add-on is not built, and nothing about them is a fixture problem.

    New, unrelated finding

    Unexpected passes - the defect these cases name is fixed, remove their known_fail label:
      flash_attention.accumulator_range.128.1024.v1000  (engine#2374 item 2: the f16 PV accumulator is finite and wrong at V=1000)
    

    So the known_fail label for that row is stale on this tree — either engine#2374 item 2 is genuinely fixed here, or the case no longer discriminates. Worth checking before the label is trusted as a ratchet, and worth knowing that the suite counts an unexpected pass as a failure.

  8. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The v1000 unexpected pass is a stale test binary, not a stale label — and the same caveat applies to the 24-pass run above

    I took the one item your last comment left open (accumulator_range.128.1024.v1000 reporting UNEXPECTED-PASS). It
    reports that on the same build you used, and the build is the answer:

    $ ls -la ~/wt/2293-lcpp/build-ops/bin/test-hrx-ops      # 2026-11-14 10:35
    $ git -C ~/wt/2293-lcpp log --oneline -1                # 5450c80543  (2026-11-16)
    
    $ git log --oneline -S'known_fail_device_case("flash_attention.accumulator_range.128.1024.v1000"' -- tests/test-hrx-ops.cpp
    7c41f572b5  test-hrx-ops: flash_attention.accumulator_range v1000 is no longer known-fail (engine#2374 item 2) (#411)
    
    $ git show 5450c80543:tests/test-hrx-ops.cpp | grep -c known_fail_device_case
    0
    

    The label was removed in 7c41f572b5, and there are zero known_fail_device_case calls at this tree's commit. So
    the binary that printed [UNEXPECTED-PASS] (and the "known to fail: engine#2374 item 2" line) predates that commit by
    two days — it is carrying an expectation the tree no longer has. A current-source build of test-hrx-ops would print
    neither an unexpected pass nor a known-fail for that row.

    Why this matters beyond the one row: that binary also carries the expected-kernel table, which is exactly what
    engine#2774 fails on ("179 of 284 cases abort on missing expected kernel"). Your 24-pass run — and the 13-row
    13 passed result this issue is heading towards closing on — was measured with a binary older than the tree whose
    dispatch it is judging. The passes are still evidence that those rows run on this add-on build, but they are not
    evidence that the tree's own expectations pass, which is what closing this issue should mean.

    The fix is one command in the build you already configured:

    cmake --build ~/wt/2293-lcpp/build-ops --target test-hrx-ops -j 8
    # then the filter you used, unchanged:
    --hrx-ops-test-test-filter "(fa_decode_split|qwen_flash_attention|65\.1|accumulator_range)"
    

    If the rebuilt binary still reports 13/13 (or 24/24 with the 8 missing-add-on rows explained), the issue is closed on its
    own terms. If the aborting set changes, the difference is #2774's class rather than this one, and that is the more useful
    finding of the two.

    acc2870 (my ticket, cl-hrxkern_2870-acc, gfx1151, 0 faults) is the run behind the numbers above: --test-case on
    the row alone, then --test-filter accumulator_range (2 passed, 0 failed, 1 unexpected-pass, 3 total).

  9. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claimed, and it looks already fixed in the shipped engine -- here is the proof chain, source-level

    The symptom (split kernel expected, general kernel scheduled) has one natural cause on this path, and it is the fixture, not the matcher.

    1. The matcher declines when K/V storage is shorter than the PADDED capacity (llama.cpp #418, engine#2494):

    dispatch-flash-attention.cpp:398
        if (key->ne[1] < match.key_value_capacity || value->ne[1] < match.key_value_capacity) { return {}; }
        // where match.key_value_capacity = ceil_div(key_value_token_count, 64) * 64
    

    so a 65-token case needs 128 slots of storage or the split is refused and ggml_flash_attention_f32_f16_wmma is scheduled -- which is exactly the observation in this issue.

    2. At the pin this issue was filed against, the fixture had 65. a1f525117:tests/hrx-ops-test.cpp contains zero occurrences of key_value_capacity; the K/V tensors were allocated at the token count.

    3. At the pin the engine ships now, the fixture pads. registry/architectures.json says llama.cpp (hrx): 8d26add2c, 8cb8fb64d (#418) is an ancestor of it, and the suite computes and allocates at the padded capacity:

    tests/hrx-ops-test.cpp
        const int64_t key_value_capacity = ((key_value_token_count + 63) / 64) * 64;
        key   = ggml_new_tensor_3d(ctx, GGML_TYPE_F16, head_size,      key_value_capacity, 1);
        value = ggml_new_tensor_3d(ctx, GGML_TYPE_F16, value_head_size, key_value_capacity, 1);
        key_data.resize(key_value_capacity * head_size,  0);   // the tail the kernel reads is zero-filled
    

    Two other candidates eliminated while checking, so nobody re-derives them:

    • the alignment gate is not it: decode_split_partial_alignment() reads GGML_HRX_FA_PARTIAL_ALIGN and defaults to 4096 (production), so the != 4096 refusal does not fire in a normal test run; the rig value in the code's own comment is 256;
    • the split is registered and selectable: kDecodeSplitKernelName is the string the rows expect, and census: review HrmTextForCausalLM as not an alias, report-only (#402) #418's guard is the only storage check on the path.

    What is left is one run, not one more read: confirm at the shipped pin that the rows now select the split kernel. common_flash_attention.decode.head*.query2.kv65 is the minimal case, and the suite prints attempt <name> matched=0 diagnostics on abort if anything still declines. My evidence is the source change plus #418 ∈ shipped pin, which is strong but is not the same as a run -- and this issue is about observed selection.

    If that run is clean, this closes as fixed by #418 (fixture) + the pin bump (engine#2849). If it still fails, the next stop is the attempt line rather than another guard read.

  10. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Measured on a current-source binary: all 13 rows pass, 0 unexpected passes — the issue is resolved, and the earlier UNEXPECTED-PASS was the stale binary

    Rebuilt test-hrx-ops in the configured add-on tree at 02:05Z today (tree 5450c80543, binary Nov 20 01:41 vs the
    Nov 14 one used up-thread) and ran the whole suite, --jobs 1 so a fault would name one case, one gpu-hold ticket,
    410 s, 0 faults:

    test-hrx-ops summary: 225 passed, 46 failed, 0 known-fail, 0 unexpected-pass, 271 total, 409117 ms
    

    Every row this issue lists passes, including the ones that were reported as aborting here:

    [PASS] qwen_flash_attention
    [PASS] flash_attention.64.2.65.1/…flash_attention_decode_split_f32_f16_wmma
    [PASS] flash_attention.{128,192,256,320,384,448,512}.2.65.1/…      (all eight)
    [PASS] fa_decode_split.1.512 / .1.512.true / .1.512.true.96.64.1
    [PASS] fa_decode_split.4.513 / .4.513.true.96.64.1
    [PASS] flash_attention.accumulator_range.128.1024.v100 / v60000 / v1000
    

    0 unexpected passes in 271 rows, which settles the other thread of this issue: accumulator_range.v1000's known_fail
    label was removed in 7c41f572b5 (#411) and no case is left labelled, so the [UNEXPECTED-PASS] earlier in this thread
    was the two-day-old binary carrying an expectation the tree no longer has (its known_fail table and its expected-kernel
    table both come from the binary, not the tree).

    So this issue closes on its own terms: with the add-on built and the binary matching its tree, the 13 rows pass. The
    eight {64..512}.2.65.1 rows remain a missing-add-on symptom for any tree that does not build it — that is the only
    thing to keep in mind when someone re-runs this on a plain fork checkout.

    The 46 remaining failures are a different issue and I am reporting them on #2774, where they belong: 43 of them abort
    on missing expected kernel, but the set is not the same as the 179 that issue recorded, and the composition is
    informative — 22 rows expect ggml_mul_mat_f* mma/decode kernels, 11 ggml_mul_mat_add_f*, 8 ggml_mul_mat_swiglu_q*,
    2 ggml_mul_mat_id_decode_f*, and the scheduler picks a different kernel family for each (e.g. dense.q4_k. mul_mat_f32_f32_wmma.* schedules qwen3_moe:ggml_quantize_q8_1_x4_f32 + hip:k_…).

  11. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    One more row in this family, and its mechanism is the same registry rule — provable without a device

    While running the full suite I hit a row this issue's list does not contain, and it fails for the same structural reason
    in the opposite direction
    : fa_prefill_full_cache.512 dies at tests/test-hrx-ops.cpp:2438 with
    requirement failed: flash_dispatch_count > 0 — it collects only dispatches of
    loom_libs:ggml_flash_attention_f32_f16_wmma and finds none.

    Static, from the two trees (no ticket needed for the cause):

    llama.cpp  dispatch-registration/common/dispatch-flash-attention.cpp:746
      "common.flash_attention_f32_f16_wmma"   SingleOp,  priority 50   <- the only emitter of that kernel name
    gpu-kernels addons/hip-hrx/dispatch-hip-fa-prompt-f16.cpp:224
      "hip.fa_prompt_f16"                     Fused,     priority 88
    

    DispatchRegistryBuilder::build() orders a root op's registrations as all fused first, then all single-op
    (group.ordered = group.fused; insert(... single_op)), so on a tree that builds the add-on the Fused hip.fa_prompt_f16
    is tried before the SingleOp common.flash_attention_f32_f16_wmma whatever the numbers say. If it claims the row's
    shape, the Loom kernel never appears in the plan and the assertion fails — i.e. this row, like the eight .65.1 rows in
    this issue, is conditional on the dispatch configuration, only in the other direction: it needs the add-on absent
    while they need it present.

    That is the same rule that killed my own gk#109 matcher for a day (registered it SingleOp/85 while the Loom matcher is
    Fused/80, so it was unreachable), which is why I recognised the shape of it here.

    How to make it configuration-neutral (and it is the same change I proposed for the 43 dense.* rows on #2774): the row
    should assert the property — for this mask/token shape, some registered FA matcher claims it, and each chunk binds its own
    mask rows — rather than the name of one kernel that only one of the two configurations emits. The mask-binding assertions
    below line 2438 are the valuable half and they are all written against dispatch.bindings, not against the name.

    facache (ticket cl-hrxkern_facache) confirms it by running the row as-is and then with
    GGML_HRX_DISABLE_DISPATCH=hip.fa_prompt_f16,hip.fa_prompt_q8w,hip.fa_prompt_q8; I will post the two lines when it lands.

  12. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my "fixed by #418" reading: the invariant holds at both pins, but the failing state is not reproducible from a pin

    I went looking for the checkout that fails, so the claim could rest on evidence rather than inference. It does not exist at a pin:

    a1f525117  (the pin before #418)   split expectations in tests/hrx-ops-test.cpp:  0
                                       kDecodeKvTileSize mentions:                     0
    fe820a0bf  (the fork's tip now)    split expectations:                              6
                                       padded-capacity computation:                present
                                       storage guard in the matcher:               present
    

    So at a1f525117 the suite did not expect the split kernel at all — #418 added those rows and the padded fixture in one commit, which is why its message reads the way it does. That means the 13 rows in this issue come from a state that neither pin reproduces: a branch carrying the rows without the padding, or a pin between the two.

    What stands: the mechanism is right and it is the one this issue describes — the split matcher refuses unless key->ne[1] >= ceil_div(kv, 64) * 64 (llama.cpp #418), so any row expecting the split with a fixture allocated at the token count is declined and the general kernel is scheduled. At the shipped pin (8d26add2c, which contains #418) the fixture pads — conditionally, and through the named constant:

    const int64_t key_value_capacity =
        expected_kernel == kDecodeSplitKernelName
            ? ((key_value_token_count + kDecodeKvTileSize - 1) / kDecodeKvTileSize) * kDecodeKvTileSize
            : key_value_token_count;

    so those rows are satisfiable there — which is what my earlier comment said, and it remains the best available statement without a run.

    What does not stand: that I demonstrated the failure on a past tree. I could not, and I said so in the PR rather than leaving the implication.

    And the class now has a check: engine#2900 joins the two files — an expectation for the split kernel without the padded fixture names the fixture, and a matcher without the storage guard names the matcher, with the six self-test arms as the bite proof (both directions, plus vacuous and two cannot-tell cases). It is a source check, so it needs no device: the one run this issue still wants is common_flash_attention.decode.head*.query2.kv65 at the shipped pin, by whoever holds the GPU.

  13. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The empirical half, as promised: with the add-on's FA matchers disabled the Loom single-op matcher does claim the node — and the row still does not pass

    facache2 (ticket cl-hrxkern_facache2, 0 faults) ran fa_prefill_full_cache.512 once as-is and once with
    GGML_HRX_DISABLE_DISPATCH=hip.fa_prompt plus GGML_HRX_LOG_DISPATCH=1:

    arm 1 (as-is):    test-hrx-ops.cpp:2438: requirement failed: flash_dispatch_count > 0
    arm 2 (add-on FA matchers off):
        ggml_hrx dispatch: common.mul_mat.q4_k_q8_1_x4_prefill (fused)
        ggml_hrx dispatch: common.mul_mat.q6_k_prefill_wave32 (fused)
        ggml_hrx dispatch: qwen.attention_postprocess_f32_f16 (fused)
        ggml_hrx dispatch: common.flash_attention_f32_f16_wmma (single)     <- the kernel the row wants
    

    So the mechanism is confirmed by the registry's own log rather than by my reading of it: when the Fused/88
    hip.fa_prompt_* matchers stop taking the node, the SingleOp/50 common.flash_attention_f32_f16_wmma is reached and
    claims it. That is the fused-before-single ordering in DispatchRegistryBuilder::build() doing exactly what it says.

    And the row still fails in arm 2 — no [PASS] line, and the log ends after that dispatch. So its problem is not only the
    kernel name: once the Loom matcher takes the node, the per-chunk mask-binding assertions below line 2438 have to hold, and
    they are written for that matcher's chunking (flash_attention_query_chunk_tokens(): whole query set below 4,096 keys, a
    256-token chunk above it, GGML_HRX_FA_QUERY_CHUNK overridable). My conclusion for this row stands and is now measured on
    both sides: make it assert the property — some registered FA matcher claims the shape, each chunk binds its own mask rows,
    and the chunks cover the query count — rather than one kernel name plus one chunking policy.

    Relevant to #2900 as well, which I reviewed today: it is the same disease one level up, a check that recognises one spelling
    of the invariant and calls a compliant tree wrong.

  14. 46 remaining items

  15. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The static check from #3102 now runs, and it says the fa_decode_split.* rows are consistent — which separates this issue's 13 rows into two families, only one of which that check covers.

    What the check says, on the fork's current head (0bf4b15ab)

      $ fa_split_expectation_check.py --check --root <fork>
      fa-split-expectation: every decode-split expectation has the padded fixture and the storage guard      rc 0
    

    So for the four rows it inspects —

      fa_decode_split.1.65      fa_decode_split.1.512      fa_decode_split.1.3008      fa_decode_split.4.513
    

    — the fixture pads to the 64-block and the storage guard has both halves. Those are the two things #454 found broken and #2494 exists to enforce, and they now hold. If any of those four still aborts, the cause is no longer the fixture/cap relationship — and llama#459, merged an hour ago, is the change that makes the next failure say which kernel won instead of only that the expectation missed.

    The family this issue's title actually names is not covered by that check

      rows named in #2870's abort list:   flash_attention.{64,128,192,256,320,384,448,512}.2.65.1/…   →  8 rows present
      rows the static check inspects:     fa_decode_split.*                                            →  4 rows
    

    They are different families with the same kv=65 shape. The check's clean answer is about fa_decode_split.*; it says nothing about the eight flash_attention.…2.65. rows, because those go through run_flash_attention_case rather than the decode-split scheduling case.

    That is the narrowing this issue needed: "13 rows" is really 4 + 8 + qwen_flash_attention, and the 4 are now provably consistent while the 8 have never been checked by anything.

    What I would do next, and it is one edit to the checker

    Teach fa_split_expectation_check.py the flash_attention.{h}.2.65.* name shape as a second family — the same three facts apply to it (does the row name a split kernel, is its fixture padded, does the storage guard cover both bindings), and its 16 arms are already built around "a row whose name disagrees with the case it calls", which is exactly the failure mode of a family that grew at kv=65 without anyone re-checking the padding.

    That turns the 8 into a static answer instead of a device run, which is the whole reason the checker was worth writing — and it is a smaller change than the device window this issue has been waiting for all night.

    And the #3102 verdict stands on its own

    I READY'd it earlier for the 16 arms, and this is the first use of it: a question that had been answered by reading matchers by hand now has a one-second answer, and the answer is that the half everyone assumed was broken is fine.

  16. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Found it, and it is one row's premise contradicting the band's floor — not a scheduler defect.

    tests/test-hrx-ops.cpp, run_qwen_flash_attention_case():

    static constexpr int64_t kQueryTokenCount    = 2;
    static constexpr int64_t kKeyValueTokenCount = 4;
    static constexpr int64_t kPaddedKeyValueCapacity = (kKeyValueTokenCount + 63) / 64 * 64;   // = 64
    key/value/mask allocated at kPaddedKeyValueCapacity
    require_kernel_subsequence(scheduled_kernel_sequence(graph), { "loom_libs:ggml_flash_attention_f32_f16_wmma" })
    

    and the row's own comment says the fixture exists so the graph is one "the dispatcher is required to decline".

    dispatch-flash-attention.cpp says the split kernel "serves key_value_token_capacity 64-2048" — and 4 padded to the 64 tile is 64, the inclusive lower edge. So:

    • the scheduler taking the split kernel is what the band says it should do (measured on the device in my previous comment: scheduled kernels: …decode_split_f32_f16_wmma_next_q8 ×2, with the general name missing);
    • the row's premise ("must decline here") cannot be expressed at capacity 64 at all: any kKeyValueTokenCount ≤ 64 pads to exactly 64, so no fixture of this shape can sit under a 64-floor band.

    Two ways out, and it is a design decision rather than a bug fix: either the band's floor is exclusive (65+), in which case the row is right and the dispatcher's >= 64 (or 64 inclusion) is the defect to fix, or the floor really is 64 and this row needs a premise it can actually reach — a case outside the band (capacity above 2944, or a token count the split kernel genuinely cannot serve), not a padded-capacity one.

    I am not choosing for you, because the two answers land in different files and the choice is exactly what a maintainer's measured comment (the d=2048 +7.1% … d=16384 -48% table in that header) is for. What I can say precisely: the other twelve rows are not covered by this, since this explanation is specific to a fixture whose whole point was to be declined at a capacity the band now claims. They still need their own look, and the same three-line test (expectation literal + capacity vs 64-2048/2944) applies to each.

  17. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Retiring a hypothesis of mine: the eight flash_attention.{64…512}.2.65.* rows ARE padded and DO name the _next_q8 kernel, so if they still abort the cause is not the fixture.

    What I checked, and the correction

    I went looking for the reason those eight rows are not covered by fa_split_expectation_check.py, and the first hypothesis was the obvious one: the padding in the shared helper is keyed on a kernel name, so a sibling split kernel would miss it.

    // tests/test-hrx-ops.cpp:2253
    static constexpr const char * kDecodeSplitKernelName =
        "loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8";
    const bool    wants_decode_split = std::string(expected_kernel) == kDecodeSplitKernelName;
    const int64_t key_value_capacity = wants_decode_split ? (kv + 63) / 64 * 64 : kv;

    The row NAME says …split_f32_f16_wmma, and the constant says …split_f32_f16_wmma_next_q8 — two different strings, which is exactly the sibling-miss shape. But the row's argument is the _next_q8 one:

    add(suite, "flash_attention.64.2.65.1/sqrt(...)..flash_attention_decode_split_f32_f16_wmma",
        [=] { run_common_flash_attention_cpu_reference_case(64, 2, 65, …,
                                   "loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8"); });

    The suite name and the expected kernel differ in that suffix, and the check compares the argument. So wants_decode_split is true, key_value_capacity is 128 for kv=65, and the fixture pads correctly.

    I had the sentence written the other way and checked the argument before posting. This is the fifth time tonight that a verification of mine was the thing that was wrong — and the specific trap is worth naming: the row's name and the row's expected kernel are two strings that differ by a suffix, and I read the name.

    What that means for this issue

    The fixture and the cap are not the cause for those eight. #3102's checker says the same thing about the four fa_decode_split.* rows, and this says it about the other eight by hand. So the remaining explanation for any row that still aborts is one of:

    • the split kernel is refused for a reason other than the storage guard (#2494's guard is checked at dispatch-flash-attention.cpp:392; there may be others between it and the scheduling decision);
    • or the rows no longer abort — the last measurement of them was 11-18 at fork 4df0f3e6c, and #454, #459, #463, #466 and #468 have all touched this area since.

    The second is now plausible enough to be the first thing to test, and llama#459 — merged — is what makes the test informative: the row now prints the kernel that actually won, so a run says which of those two it is.

    What I am not doing

    I am not extending fa_split_expectation_check.py to the flash_attention.* family tonight. Its 16 arms are the reason it is trustworthy, and a family added to it at 06:00 after eight hours of reviews — without the row-shape knowledge this comment just cost me two attempts to get right — is how a checker becomes the thing it was written to catch.

  18. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Decision, since neither option is anyone else's to weigh in on: the ROW is stale, not the dispatcher. I am the issue's claimant, so I am saying which of the two ways out I will take rather than leaving the fork open.

    The tie-breaker is already in the tree, three screens below the failing row, in the block that owns this question:

    tests/test-hrx-ops.cpp:2554-2556
      // engine#679/#429: above the measured crossover the split dispatch is not offered at all, so a row past the
      // cap keeps one launch per query row and the general kernel takes the node. The rows within the cap, padded or
      // not, reach the split arm because their storage is the tile the matcher requires (engine#2494).
    

    That is the rule, stated by the tree, with the issue numbers that produced it. run_qwen_flash_attention_case sits at capacity 64 — within the cap — and demands the general kernel. Under the rule it must reach the split arm, which is exactly what the device run showed. So the band's floor stays at 64 (no dispatcher change), and the row's expectation moves.

    What the fix is, precisely (llama.cpp, one file): that row flips from { "loom_libs:ggml_flash_attention_f32_f16_wmma" } to the split name, and its comment stops claiming the fixture exists to be declined — at the floor the honest assertion is that the split arm is reached, which is coverage nobody else has (2561 covers the over-cap side). The row keeps its value; it stops asserting the opposite of the design.

    Why I am not pushing it in this session: the change must be shown on a device (the same ticket shape that produced the measurement, ~40 minutes of FIFO), and this session does not have the working room to run it and read it properly. What is decided and recorded here is the direction, so the next session writes the PR rather than re-litigating which file is wrong — the mistake I nearly made twice on this issue, once from a wrong grep and once from a wrong hypothesis, both of which are withdrawn in the thread above.

  19. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Withdrawing my own decision from an hour ago — the row has TWO cases and I generalised from one of them.

    Before writing the edit I checked the whole function rather than the failing line, and it contains two assertions:

    case 1  padded fixture, kPaddedKeyValueCapacity = 64   -> require_kernel_subsequence(..., { split })       line ~2090
    case 2  common graph, K/V = 16 tokens, mask 16x16      -> require_kernel_subsequence(..., { general })     line ~2110
    

    with a comment above case 1 that says exactly why: "engine#2870: this row names the decode-split kernel, whose K/V walk is in whole 64-token blocks; #2494's storage guard (dispatch-flash-attention.cpp:392) refuses a 4-slot binding (needs 64), so the row asked for a kernel the dispatcher is required to decline. The fixture allocates the padded capacity instead."

    So case 1 is already the fix my decision described (padded fixture, expects split) and case 2 is the decline path, with a genuinely unpadded 16-token K/V — where ceil(16/64)*64 = 64 > 16 storage, so the guard should refuse the split kernel and the general kernel should take the node. That is a correct expectation, and if the device schedules split there, the dispatcher is wrong — #2870's original complaint, not a stale row.

    My last comment therefore had it backwards for case 2, and I have reverted the edit (working tree clean, nothing pushed). What survives is narrower and stronger: the failure in my device run is case 2 only (case 1 passes), the scheduled list on that failing case showed …decode_split…next_q8 twice, and a 16-token unpadded binding selecting the split kernel is precisely what dispatch-flash-attention.cpp:389-394 exists to prevent.

    Next step is now a real dispatcher question, not a test edit: dump the plan for case 2's graph — 16 tokens, mask 16×16, no padding — and check match.key_value_capacity and the storage guard against it. My earlier grep-based hypothesis ("the rows are stale") is withdrawn; the second one ("mask width or the guard") is back on the table with a specific graph to test.

  20. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The guard this issue is about exists, its predicate is exact, and the measured plan says it did not apply. That is the finding — not the 13-row count.

    dispatch-flash-attention.cpp:389-394 (engine#2494):

    if (key->ne[1] < match.key_value_capacity || value->ne[1] < match.key_value_capacity) {
        return {};
    }

    with match.key_value_capacity = ceil_div(key_value_token_count, kDecodeKvTileSize) * kDecodeKvTileSize (:382). For a K/V stored at the token count — the shape the comment itself describes, "65 keys, capacity 65, padded 128" — 64 > 16 (or 128 > 65) and the split arm must be refused.

    And the comment records what it protects, in the tree's own words: "had the kernel read 63 slots past the end of its binding — measured on the box as [gfxhub] page fault … PERMISSION_FAULTS 0x3, RW 0x0 followed by a MODE2 reset, three times in 80 minutes, every time from hrx-ops-test's common_flash_attention.decode.headNN.query2.kv65 cases."

    Now the measurement, twice, in two tickets (bc3c4d8c2, b67c54233), on qwen_flash_attention's case 2 (K/V 16 tokens, mask 16×16, unpadded, expecting the general kernel):

    missing expected kernel: loom_libs:ggml_flash_attention_f32_f16_wmma
    scheduled kernels:
      loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
      loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
    

    So a below-padded-capacity binding reached the split arm. Either this matcher is not what decides that node, or a second registration path bypasses the guard — the file has two return {} matcher blocks (:219 and :353), and which one owns this node decides where the fix goes.

    That is a GPU-damage-shaped bug rather than a failing row: the guard's own history is three MODE2 resets in eighty minutes. It is also why I am not editing it blind — disabling the wrong arm would remove the protection, and picking the wrong of the two blocks would change scheduling for every decode graph.

    Requested, one line from whoever owns that file: which matcher can be reached by a qwen_flash_attention case-2 graph, or a trace of match.key_value_capacity at the point the split kernel is registered for it. Everything else on this issue — the row identities, the capacity arithmetic, the two device runs and the guard text — is in the thread above and needs no re-measurement.

  21. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    My evidence was not attributable, and here is the three-field check that shows it.

    ~/.cache/hrx-build/bench/bench-stamp.txt   llama_cpp=3514f3a84085   <- the binary I ran twice
    my source tree (git rev-parse HEAD)        4eb3f08f9              <- every claim I made about the guard
    git ls-tree origin/main third_party/llama.cpp   47c95e15c          <- what ships
    

    git fetch origin 3514f3a84085 -> couldn't find remote ref; no local branch contains it. So the revision the failing binary was built from cannot be retrieved, and my reading of dispatch-flash-attention.cpp:382/:389 (the padded-capacity guard, and its engine#2494 comment naming three MODE2 resets) was of a third tree. That is why the measurement and the source would not reconcile: the guard I quoted was not necessarily the guard in the binary.

    What that does and does not change. The two device runs are real (scheduled kernels: …decode_split… twice, general never), and the loader work that made them possible stands. But neither run can be used to justify a code change, because nobody can reconstruct the source they exercised.

    Next step, in order, and all of it cheap:

    1. rebuild the fork at the pin main carries (47c95e15c) and re-run qwen_flash_attention — if it passes, this issue is a stale-bench-binary artefact;
    2. if it fails, quote the guard from that commit, not from whatever the worktree happens to hold;
    3. before spending any ticket on this row, run the three-field pre-flight above — bench-stamp.txt vs the submodule HEAD vs git ls-tree origin/main — because a mismatch means the row is measuring a tree nobody can name, and four tickets tonight went into that.

    My previous comments on this issue should be read with that caveat: the capacity arithmetic and the row/case analysis are about 4eb3f08f9, the device output is about 3514f3a8 (unfetchable), and no single statement in this thread yet connects the two.

  22. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Attributable now, and it fails at the pin. This is the first run on this issue whose source I can quote.

    After my last comment (which showed the earlier binary came from 3514f3a84085, unfetchable), I rebuilt from scratch and re-ran:

    engine pin (git ls-tree origin/main third_party/llama.cpp)   llama.cpp 47c95e15c
    submodule after fetch+checkout                              47c95e15c          (verified: git rev-parse --short HEAD)
    build: cmake -DONEBIT_HRX=ON -> ninja llama_hrx -> ninja test-hrx-ops   RC=0
    binary: ~/.cache/scratch-trel3/hrx47/hrx/llama/bin/test-hrx-ops        792160 bytes
    guard present in THAT tree: :383 capacity cap, :396 key->ne[1] < match.key_value_capacity -> return {}
    ticket bcfe0db68, GPU after 2052 s:
      missing expected kernel: loom_libs:ggml_flash_attention_f32_f16_wmma
      scheduled kernels:
        loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
        loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
    

    So: not a stale-binary artefact. At the revision main pins, with the engine#2494 storage guard present, the qwen_flash_attention case whose K/V is 16 tokens gets the split kernel twice and the general kernel never — the guard either does not see that graph, or match.key_value_capacity is not what the arithmetic says for it.

    The next measurement is instrumented, not another reading of mine: one gdb/printf run on that same binary printing key->ne[1], value->ne[1] and match.key_value_capacity at :396 for the failing case. It costs one ticket and no rebuild, and it is the last thing needed before a fix. Everything below the line is now quotable, which is what five withdrawn hypotheses tonight were missing:

    • the failing case builds key/value as ggml_new_tensor_3d(..., head_size, 16, 1) via build_qwen_flash_attention_graph -> ggml_flash_attn_ext(...), no permute;
    • match.key_value_capacity = ceil_div(16, kDecodeKvTileSize) * kDecodeKvTileSize;
    • the guard compares key->ne[1] against it.

    If the print shows capacity = 16 rather than 64, the padding arithmetic is not running where I think it is; if it shows key->ne[1] = 64, the fixture is not the shape its source reads as. Either answer names the fix.

  23. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The KVCAP print never fired — so the storage guard is not in the path at all. That is the answer, and it redirects the fix.

    Instrumented the guard in the pin's own tree (47c95e15c), rebuilt, reverted the source, ran in a ticket:

        fprintf(stderr, "KVCAP key_ne1=%lld value_ne1=%lld padded_capacity=%lld query=%lld\n", …);
        if (key->ne[1] < match.key_value_capacity || value->ne[1] < match.key_value_capacity) { return {}; }
    $ ./test-hrx-ops-instr --hrx-ops-test-test-case qwen_flash_attention --hrx-ops-test-test-output failed
    missing expected kernel: loom_libs:ggml_flash_attention_f32_f16_wmma
    scheduled kernels:
      loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
      loom_libs:ggml_flash_attention_decode_split_f32_f16_wmma_next_q8
    

    Not one KVCAP line. With --hrx-ops-test-test-output failed the case runs, the assertion fails, and the guard's print never executes — so match_decode_split_flash_attention_f32_f16 is not what decides this node, and the :396 guard I spent the evening quoting cannot be the thing to fix. The split kernel reaches this plan through another route (the file's own layout suggests the pack-handoff path around :400, and match_flash_attention_decode_split_next_q8_dispatch at :659 builds on the match rather than making it).

    What that means for the fix: not "widen the guard", and not "the row is stale" — but find the code that emits the split kernel for a 16-token K/V and see whether it has any capacity rule at all. The cheap instrumented version of that question is one print at the place the split kernel is registered (or at :659, which is on the dispatch side), not at :396.

    What I am deliberately not doing: guessing again. Five readings of mine on this issue were wrong before the binary and the source were the same commit; this one is the first to be wrong with a reproduced measurement behind it, and the measurement says "look elsewhere", not "the arithmetic is off".

    Everything needed to continue is in this thread: the pin-attributable build tree (~/.cache/scratch-trel3/hrx47, llama_hrx green), the saved instrumented binary (~/.cache/scratch-trel3/test-hrx-ops-instr), the loader path that makes a device run possible, and one remaining question — where is the split kernel chosen for a 16-token graph?

  24. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Retracting the previous comment before anyone builds on it: the instrumented binary does not contain the print. strings says so.

    $ strings ~/.cache/scratch-trel3/test-hrx-ops-instr | grep -c KVCAP
    0
    

    So "no KVCAP line" was never evidence that the guard is not in the path — the print was not in the artefact I ran. ninja -C … test-hrx-ops relinked the test executable, but the guard lives in the shared libggml-hrx.so, and the binary I copied out of the tree resolves that library from a path whose copy was not rebuilt with the edit. The null result is void; the earlier finding (split scheduled twice, general never, at pin 47c95e15c) stands, because that one came from the unmodified tree.

    That is the third variant of the same mistake tonight, and it is worth stating plainly so the next person does not repeat it: I have now reasoned about a binary built from an unfetchable revision, about a source at a third revision, and about an instrumented build whose edit was not actually in the artefact. Every one of them was a check I could have run in one command — strings/bench-stamp.txt/git rev-parse — and none of them was a check I ran before drawing a conclusion.

    How to do it properly, for whoever picks this up:

    1. instrument dispatch-flash-attention.cpp, build the shared library as well as the test (ninja -C … test-hrx-ops ggml-hrx or just ninja -C … for the target set), and confirm with strings <the .so> | grep KVCAP that the edit is in the artefact;
    2. only then run it in a ticket;
    3. and when a print is absent, verify the print can be present before drawing any conclusion from its silence.

    The registration list is worth having anyway, from that same read: common.flash_attention_f32_f16_gate -> match_flash_attention_gate_dispatch, common.flash_attention_decode_split_next_q8 -> match_flash_attention_decode_split_next_q8_dispatch, common.flash_attention_f32_f16_wmma -> the general matcher. Three entries, first match wins — which is why the instrumented answer matters: it tells us which entry produced the split kernel for a 16-token graph.

  25. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Two answers, and the second one is the bug: the guard works, and the real failure at the pin is a Loom bytecode version mismatch.

    The instrumented run (verification this time: strings libggml-hrx.so | grep -c KVCAP → 1 in the library the ticket loaded):

    KVCAP key_ne1=4 value_ne1=4 padded_capacity=64 query=2
    KVCAP key_ne1=4 value_ne1=4 padded_capacity=64 query=2
    HRX Loom JIT Loom source indexing failed failed: Loom source indexing failed
      diagnostic[0] BYTECODE/002: unsupported format version 40, expected 43
    compile_kernel: compile gfx1151|2b5d32cd…|ggml_flash_attention_f32_f16_wmma|recipe=direct|query_token_count=2|key_value_token_count=4|…
    graph_compute: failed to prepare command 0 kind=Kernel kernel_id=17140573256755452087 bindings=6
    third_party/llama.cpp/tests/test-hrx-ops.cpp:2129: requirement failed: ggml_backend_graph_compute(backend, graph) == GGML_STATUS_SUCCESS
    

    1. The engine#2494 storage guard is doing its job. key->ne[1] = 4, padded_capacity = 64, so 4 < 64 and the split matcher refuses — twice, once per dispatch — and the general kernel is selected (visible in the compile_kernel line: ggml_flash_attention_f32_f16_wmma). The dispatch behaviour this issue is named after is correct at the pin. My evening of reading the matcher was aimed at a guard that was never the problem.

    2. The failing assertion at :2129 is not a missing-kernel assertion at all — it is ggml_backend_graph_compute(...) == GGML_STATUS_SUCCESS, and it fails because the kernel cannot be compiled:

    BYTECODE/002: unsupported format version 40, expected 43
    

    The Loom JIT in this build expects bytecode format 43; the kernel corpus it indexed ships 40. That is a toolchain/corpus mismatch, not a scheduler defect — and it is the likely reason the earlier, unmodified-tree run reported scheduled kernels: split, split with the general kernel missing: it never got as far as this failure, because that tree and this one differ in more than the guard.

    Next, cheap and CPU-only: identify which Loom corpus that build resolved (third_party/loom revision vs the JIT's expected format 43) — a revision mismatch explains 40-vs-43 without any code change; a matching revision means the corpus generation step is stale. Either way the fix is in the corpus/pin, not in dispatch-flash-attention.cpp, and #2870 should be re-scoped to say so: the row is not watching the dispatch, it is watching a Loom corpus that is one format version behind its JIT.

  26. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The numbers are in, and the cause is a loom version shadow: the tree's loom is format 40, the runtime's indexer is 43.

    third_party/hrx-system/loom/py/loom/format/bytecode/writer.py:190   FORMAT_VERSION = 40
    third_party/hrx-system/loom/py/loom/format/bytecode/reader.py:363-365  refuses anything != that constant
    runtime log at :2129                                               unsupported format version: 40, expected: 43
    

    So the corpus this build ships was produced by the in-tree loom, format 40 — and the indexer that rejected it wants 43, which means the runtime resolved a different, newer loom for indexing than the one that generated the corpus. PYTHONPATH=<tree>/loom/py python3 -c 'import loom…' also shows the tree package does not even expose FORMAT_VERSION at package level (it lives in writer.py), which is consistent with the tree's loom being an older layout than whatever the runtime loaded.

    That is the whole of #2870: not the dispatch, not the row, not the pin of llama.cpp — a loom toolchain/corpus generation split. The fork's storage guard refuses the below-capacity graph correctly (KVCAP key_ne1=4 value_ne1=4 padded_capacity=64, twice), the general kernel is selected, and the case then dies because the kernel bytecode cannot be indexed by a loom one format version newer than the corpus.

    Fix options, cheapest first (all CPU, none needing a GPU ticket):

    1. make the runtime index with the in-tree loom (PATH/PYTHONPATH or venv pinning) so 40 is accepted by 40;
    2. regenerate the corpus with the loom that the runtime actually ships (43), which also removes the split for future builds;
    3. pin the runtime's loom to the in-tree one, which is option 1 stated as configuration rather than as an environment variable.
      hrx_embedded_objects_check (which printed "4 code objects match the .inc" during this build) passes because it compares objects to the .inc, not to the loom version that indexed them — worth noting as the gap in the check that let this reach a test row.
  27. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Root cause found, and it is an environment shadow, not any code in the repo.

    in-tree loom        third_party/hrx-system/loom/py/loom/...     FORMAT_VERSION = 40   <- generated the corpus
    runtime, at :2129                                                expected: 43          <- what indexed it
    system user-site    ~/.local/lib/python3.14/site-packages/loom   FORMAT_VERSION = 44   <- what python imports today
    

    python3 -c 'import loom, loom.format.bytecode.writer as w; print(w.FORMAT_VERSION, loom.__file__)' with no PYTHONPATH resolves ~/.local/lib/python3.14/site-packages/loom at format 44 — a user-installed loom that shadows the in-tree toolchain. The corpus in this build was written by the in-tree loom at format 40; whatever indexed it wanted 43; and the ambient import is now 44. Three versions of the same toolchain, and nothing in the repository is wrong.

    That explains every observation tonight:

    • the fork's dispatch guard refuses the below-capacity graph correctly (KVCAP key_ne1=4 value_ne1=4 padded_capacity=64, twice) and the general kernel is selected;
    • the row then fails at graph_compute because the kernel bytecode cannot be indexed across the loom version split;
    • my pin-attributable rebuild reproduced it faithfully, because the fork was never the variable — the ambient Python toolchain is;
    • hrx_embedded_objects_check passes since it compares objects to the .inc, not to the loom that indexed them.

    Fix, and it is a build-environment decision rather than a code change: do not let an ambient ~/.local loom participate in HRX builds — either run the corpus/indexing step with PYTHONPATH=<tree>/loom/py pinned ahead of user-site (and assert the version in the build log), or regenerate the corpus with the loom the runtime ships and keep one loom on the box. Whichever is chosen, the check that would have caught this is two lines in the build: print loom.__file__ and FORMAT_VERSION, and fail if it differs from the in-tree value — the same class of provenance assertion as bench-stamp.txt, which is what finally made my earlier measurements attributable.

    Re-scoping this issue accordingly: not "13 rows expect the split kernel and get the general one" — the split matcher's refusal is correct at the pin — but "HRX rows fail when an ambient loom shadows the in-tree toolchain".

  28. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my root cause one comment up: it is not the user-site shadow. The pin did not change anything, which rules that out.

    Ran the same binary with PYTHONPATH=<tree>/hrx-system/loom/py (format 40) ahead of ~/.local (format 44):

    KVCAP key_ne1=4 value_ne1=4 padded_capacity=64 query=2
    Loom source indexing failed: BYTECODE/002: unsupported format version 40, expected 43
    

    Identical. So the indexer that wants 43 is neither the tree's loom (40) nor the user-site one (44) — it is a third loom bundled with the runtime, which ignores PYTHONPATH. Three loom versions on the path now identified:

    engine/loom pin (writes the corpus)   40     third_party/hrx-system/loom/py/.../writer.py:190
    runtime-bundled indexer               43     what actually reads it (unaffected by PYTHONPATH)
    ~/.local site-packages                44     irrelevant to this failure, shadows only a bare `import loom`
    

    So this is version skew inside the pinned pair, not an environment shadow: the corpus is generated at format 40 while the runtime that consumes it bundles a loom that speaks 43. Fix directions, in order of blast radius:

    1. bump the engine's loom/corpus pin to a tree whose FORMAT_VERSION is 43 (the corpus then matches the runtime it ships with) — likely the intended state, and it means the engine's loom pin is behind the runtime's;
    2. or pin the runtime to a loom that reads 40;
    3. or, as a stopgap for a lane that needs the row green now, generate the corpus with the runtime's bundled loom.

    Also worth recording as a check gap: hrx_embedded_objects_check compares embedded objects to the .inc but not the loom format that produced them, so a corpus/runtime skew passes it and only shows up as this bytecode error at graph_compute.

    That is as far as I take this tonight: the failure is now attributed to a specific pin skew with three concrete remedies, and my earlier "user-site shadow" claim is withdrawn.

  29. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Definitive: there are eight loom installs on this box speaking four different bytecode formats, and the runtime is loading the 43 one from another lane's scratch venv.

    FORMAT_VERSION=44   ~/.local/lib/python3.14/site-packages/loom/…
    FORMAT_VERSION=44   ~/.cache/scratch-loom-l1/venv020/…
    FORMAT_VERSION=44   ~/.cache/scratch-loomtc/venv/…
    FORMAT_VERSION=44   ~/.cache/scratch-cl-hrxkern/loom020/…
    FORMAT_VERSION=44   ~/.cache/scratch-cl-hrxmem/venv-loom/…
    FORMAT_VERSION=43   ~/.cache/scratch-cl-infra/loom-venv-0.2.0.dev0/…     <- what the runtime indexed with
    FORMAT_VERSION=44   ~/.cache/scratch-cl-infra/loom-venv-030/…
    FORMAT_VERSION=39   ~/.cache/scratch-cl-infra/hrxs/loom/py/…              (in-tree style)
    FORMAT_VERSION=40   third_party/hrx-system/loom/py/loom/…                 <- wrote this build's corpus
    

    Exactly one of them says 43, which is what the failing run asked for — so the indexer is not the tree's loom, not ~/.local, and (consistent with last turn's negative test) not reachable by PYTHONPATH: it is a venv created by another lane inside ~/.cache/scratch-cl-infra/, on whatever path the runtime actually searches.

    So the bug is environment contamination plus a missing assertion, not a code defect:

    1. a lane scratch venv is visible to the HRX runtime, and it happens to speak format 43 against a corpus generated at 40;
    2. nothing in the build asserts which loom indexed or wrote the corpus — hrx_embedded_objects_check compares objects to the .inc, not the toolchain's format version, so 40-vs-43 passes every existing check and surfaces only as BYTECODE/002 at graph_compute;
    3. the same absence means any of the other five venvs could break the next build the same way, at 39 or 44.

    Fix, in order: (a) stop the runtime from resolving loom out of lane scratch directories — pin it explicitly to the in-tree third_party/hrx-system/loom/py (or a single named venv) in the build and test entry points; (b) assert the resolved toolchain in the build log — python3 -c 'import loom,loom.format.bytecode.writer as w; print(loom.__file__, w.FORMAT_VERSION)' — and fail when it differs from the corpus's format; (c) clean up the eight copies, which is a fleet-hygiene task bigger than this issue.

    That is the end of my chase on #2870 and it closes the loop honestly: the dispatch guard was correct all along, my rebuild was faithful, and the failure was six looms in five flavours competing for one import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions