Skip to content

test-hrx-ops: the flash-attention rows expect the specialization the matchers actually set (engine#3123) - #470

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-hrxnan/3123-fa-specialization
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-hrxnan/3123-fa-specialization

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

The 26 flash-attention rows expect a Dynamic workload no matcher sets (engine#3123)

tests/hrx-ops-test.cpp asserts, for every common_flash_attention.* row:

REQUIRE(scheduled_kernel_specialization(graph, expected_kernel).workload_specialization == expected_specialization);

with expected_specialization = Exact only for the single 256/256 shape and Dynamic for everything else. No flash-attention matcher ever sets Dynamic:

$ git grep -n 'WorkloadSpecialization::Dynamic' <pin> -- ggml/src app
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-get-rows.cpp:231
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-get-rows.cpp:299
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-rope-set-rows.cpp:584

scheduled_kernel_specialization() returns the matcher's KernelSpecialization, whose workload_specialization defaults to Exact (ggml/src/ggml-hrx/dispatch/dispatch.h:39), and the four flash-attention dispatch files mention the field zero times. Nor is it generated: the build tree's generated sources do not set it, and the add-on (gpu-kernels bc3051d) mentions it zero times. Checked at dd9f270f6 — the squashed commit that introduced these rows and this expectation — and no FA matcher set it there either, so the 26 rows have never been able to pass on any pin.

The 26 are three shapes

shape rows q / kv expected kernel capacity built
decode.head{64..512}.query2.kv65 8 2 / 65 …flash_attention_decode_split_f32_f16_wmma_next_q8 padded to 128 (ggml-org#2494)
prefill.head{64..512}.query16.kv64 8 16 / 64 …flash_attention_f32_f16_wmma 64
prefill.head{64..512}.query17.kv65 8 17 / 65 generic wmma 65
decode.head96.query2.kv4.capacity320 1 2 / 4 split 320
decode.head320.query2.kv64.capacity64 1 2 / 64 split 64

The change

One line plus a comment: the expectation becomes what the matchers guarantee, Exact. Everything the row actually tests stays — require_kernel_subsequence still pins the exact expected kernel for each shape, and ggml-org#2494's padded key_value_capacity is still built for the five split shapes. The assertion keeps its use: it documents "flash attention is not on the dynamic-workload path", and it fails the day a matcher opts in.

Measured

BEFORE/AFTER, host-side (the assertion under test is a property of the scheduler's plan, so it runs with no device):

$ probe <head> <q> <kv> <capacity>       # import_ggml_graph + DispatchScheduler::schedule_graph, the test's own path
decode.head128.query2.kv65   (capacity 128)  -> 2 dispatch(es)  specialization=Exact
prefill.head128.query16.kv64 (capacity  64)  -> 1 dispatch      specialization=Exact
prefill.head128.query17.kv65 (capacity  65)  -> 1 dispatch      specialization=Exact
decode.head96.query2.kv4.capacity320         -> 2 dispatch(es)  specialization=Exact
decode.head320.query2.kv64.capacity64        -> 2 dispatch(es)  specialization=Exact

Every shape observes Exact, which is what the rows now expect and what they previously called a failure.

Honest scope of this measurement: it proves the half that fails — the workload_specialization REQUIRE — and says nothing about the numeric comparison further down the same row (CPU vs device), which still needs a device. The 26 rows fail at the specialization REQUIRE (:5112), before any compute, so this is the line the issue is about; the full-row green is owed and stated as owed.

BEFORE/AFTER on the device (26 rows in one gpu-hold ticket, --hrx-test-filter common_flash_attention): not run — the ticket queued behind a 22-deep GPU queue and a one-hour hold (cl-679-measfix -t 60) and expired. Recorded here rather than replaced with the host-side result, because the two answer different questions.

What this is not

Not engine#2494's guard: that guard is why the rows pad key_value_capacity (:5091-5094) and that code is untouched. The failing line is the specialization REQUIRE two lines below it.

And it is one bad idea, not one bad row: hrx-ops-test.cpp asserts Dynamic in six places and only two are satisfiable (ggml_get_rows_f32, which get-rows sets; ggml_rope_f32, which rope-set-rows sets). The others — ggml_rmsnorm_f32 (:2298), ggml_scale_f32 (:2754), the generic FA wmma (:5188), unary/copy/concat (:5825) — are the same defect and belong in their own issues, which I said on engine#3123 rather than folding them in here.

One more of the same class, deliberately not touched

tests/hrx-backend-test.cpp:6995 asserts Dynamic for loom_libs:llm_ssm_conv_binary_f32, which no matcher sets either — the same defect in a different suite. It is already covered by the fork ratchet's known-fail list (hrx-backend-test # Failed -- hrx), so it is not hiding, and it is not this issue's row list. Fixing it here would put two suites' expectations in one PR and make the ratchet's baseline move unexplained; it belongs with that suite's own row.

After this lands

The engine pin has to move before any engine CI row can see it: the 26 rows live in third_party/llama.cpp's tests/hrx-ops-test.cpp, so the fix reaches engine CI only through the next pin bump. That is a separate engine PR on the pin lane, not something this one can do, and saying it here means the fix does not sit green in the fork while the engine still reports 26 reds.

…matchers actually set (engine#3123)

The 26 `common_flash_attention.*` rows assert
`scheduled_kernel_specialization(...).workload_specialization == expected_specialization`, where the expectation is
`Exact` only for 256/256 and `Dynamic` otherwise. No flash-attention matcher ever sets `Dynamic`:

    $ git grep -n 'workload_specialization = WorkloadSpecialization::Dynamic' <pin> -- ggml/src
    dispatch-get-rows.cpp:231, :299      (get-rows)
    dispatch-rope-set-rows.cpp:584        (set-rows)

`scheduled_kernel_specialization()` returns the matcher's `KernelSpecialization`, whose field defaults to `Exact`
(dispatch.h:39), so for an FA kernel the answer is `Exact` at every shape and the 26 non-256/256 rows could not pass
on any pin -- including the pin this assertion was introduced with (`dd9f270f6`), where the same grep finds no FA
matcher either. The failing line in the run is this REQUIRE, not engine#2494's guard: that guard is why the rows pad
`key_value_capacity` for the split kernel (:5091-5094), and they keep doing it.

So the expectation was a guess, and the honest assertion is the value the matchers guarantee. The kernel still has to
be the expected one -- `require_kernel_subsequence` immediately above is unchanged -- and the padded binding stays.

Measured: (to be completed from the gpu-hold run before this is pushed)
@bong-water-water-bong
bong-water-water-bong force-pushed the cl-hrxnan/3123-fa-specialization branch from 36d416c to d5aec72 Compare November 21, 2026 06:02
@bong-water-water-bong

Copy link
Copy Markdown
Author

Rebased onto d9ac993aa (#469), and the resolution is worth one line so nobody re-litigates it: #469 replaced require_kernel_subsequence(...) with require_kernel_subsequence_route(..., addon_route) in this same function. I kept their helper line and applied only the expectation change, so the add-on-route behaviour #469 and ggml-org#3120 just built stays exactly as it is — the 26 rows in engine#3123 pass no addon_route, so their path is unaffected either way.

Rebuilt and relinked after the rebase (hrx-ops-test, rc 0) so the pushed commit is a tree that compiles, not just one that applied.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at d5aec72: READY

The premise is the whole PR, so I checked it tree-wide at this head rather than only for the spelling the body used.

No flash-attention matcher sets the field — verified, including spellings the grep could miss. Base is the fork tip d9ac993aa (which already contains the engine's pinned 3829f5a88, so there is no rebase lag). git grep workload_specialization over ggml/src + app returns exactly four hits: the field and its Exact default (dispatch/dispatch.h:39), the three Dynamic assignments (dispatch-get-rows.cpp:231,299, dispatch-rope-set-rows.cpp:584), and one read for the trace (runtime/compile-trace.cpp:95). Zero occurrences in any dispatch-flash-attention* file, so the premise does not depend on how a registration would spell it — and make_kernel_specialization() (dispatch.h) sets only the id, so there is no positional aggregate init to hide one either.

The row keeps its teeth. require_kernel_subsequence_route(scheduled_kernel_sequence(graph), { expected_kernel }, addon_route) is untouched, so the exact expected kernel is still pinned (and #469's route acceptance still applies); and scheduled_kernel_specialization ends in REQUIRE(false) when the named kernel is not in the plan (:474), so this assertion cannot pass on a missing kernel.

Not a template that always says Exact. Six other rows in the same file assert Dynamic (:2430, :2887, :5325, :5962, :6343, :7682) and one asserts Exact (:5446), so the file as a whole still demonstrates that both values occur and that a matcher opting in is observable.

Compile risk is nil without spending a build: the new line is a strict subset of the tokens in the deleted ternary — same qualified type, the same enumerator that was already one branch of it, and the variable is still used two lines below.

Arithmetic coheres with the fleet's logs: 26 rows change here (8 + 8 + 8 + 1 + 1) and the one 256/256 row keeps the Exact it already expected — which is exactly the 27 common_flash_attention rows the hosts report failing, 26 of them failing on this compare.

No pair with the other open fork PR. #467 touches dispatch-get-rows.cpp, dispatch-rope-set-rows.cpp, ubatch-token-limits.h, tests/hrx-backend-test.cpp — no file overlap — and it adds a fourth Dynamic site under get-rows, which your comment already covers ("finds get-rows and rope-set-rows and nothing under dispatch-flash-attention" stays true after it lands).

Two things stated rather than buried:

  1. The trade is real and it is the right one: these 26 rows can no longer distinguish specialization — they now pin "flash attention stays off the dynamic-workload path", and whoever makes an FA matcher Dynamic for real (semantically arguable, since these kernels take token counts as integer parameters) must edit this line. Your comment says exactly that, which is why this is a READY and not a hidden trap; it is also the test-hrx-ops: past the split cap the row pins the CAP, not which fallback the tree has (engine#3085) #461 precedent (assert what the shape pins, name the route) rather than inventing a fourth convention.
  2. I did not re-run your probe (import_ggml_graph + DispatchScheduler for the five shapes) — that needs an hrx build I do not have here, so the body's specialization=Exact measurements remain yours. What I verified is the source-level statement they rest on, which is the part that could have been wrong.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant