Skip to content

test-hrx-ops: record the 33 stale kernel expectations as a ratchet (engine#2774) - #416

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-hrxnan/2774-stale-expectations-ratchet
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-hrxnan/2774-stale-expectations-ratchet

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Fixes the diagnosis in engine#2774 (the engine-side issue): hrx-ops-test aborts 179 of the 284 device cases it reaches on missing expected kernel, identically on two different builds, because its expectations are hardcoded kernel names from a dispatch scheme the matchers have since left.

Measured, before

Two full sweeps (same harness, one process per case, --hrx-test-jobs 1, quiet kernel log):

cases=284  pass=88  missing_kernel=179  requirement=15   (build of fork 6b9fcacb7)
cases=284  pass=88  missing_kernel=179  requirement=15   (build of the pin dd9f270f6)

The failing-case sets are identical (diff -q on the 179 case numbers is silent), and the pin build's provenance is proven (bin= line, relink at 20:03Z, the tree carries the pin-only qwen4exp-hrx-support.h).

What the expectations actually name

$ grep -h "missing expected kernel:" case-*.log | sed 's/.*missing expected kernel: //' | sort -u | wc -l
33
$ for k in <those 33>; do grep -rl "\"$k\"" ggml/src/ggml-hrx --include=*.cpp --include=*.h \
      | grep -v kernel-corpus/kernels | wc -l; done
0     # for every one of the 33

Thirty-three distinct names, and not one of them is referenced anywhere outside the corpus manifest and this test file — no matcher, no table, no fallback. The corpus still compiles and exports them (ggml_mul_mat_skinny_input_f32_publish_f32 alone accounts for 42 cases), so every case that names one aborts, forever.

The change

A recorded table, consulted by the helper that does the asserting:

static const char * const kRecordedStaleExpectations[] = { /* the 33 */ };

if (sequence_index >= sequence.size()) {
    if (is_recorded_stale_expectation(name)) {
        std::fprintf(stderr, "stale recorded expectation (engine#2774, not a failure): %s …\n", name.c_str());
        sequence_index = before;   // not in the sequence; consume no match for it
        continue;
    }
    ... existing abort ...
}
// …and on the found path:
if (is_recorded_stale_expectation(name)) {
    std::fprintf(stderr, "recorded-stale expectation is now SATISFIED (engine#2774, prune this line): %s\n", name.c_str());
}

Deliberate properties:

  • both directions are reported. A missing recorded name prints stale recorded expectation …, and a recorded name that is now satisfied prints recorded-stale expectation is now SATISFIED (prune this line). A table nobody prunes rots; a table that silently absorbs a fix is worse than no table.
  • the list may shrink, never grow silently — a new stale name still aborts with the original message and the scheduled-kernel list, so a dispatch change that strands another expectation fails as it should;
  • it is a table, not a data file: 33 lines reviewed in the diff, and no load path that can silently not run (this tree has paid for a check that could not run more than once);
  • it is the same ratchet shape as tools/ci/hrx_f16_narrowing.txt, which is the house pattern for "recorded today, change-detector tomorrow".

Validation

Eight previously-aborting cases, one 6-minute device ticket, --hrx-test-jobs 1 (this is the run that decided the PR shipped):

case 1 rc=0 stale=1  dense_matmul.iq2_s.codebook_control.tiled.tokens64.outputs128
case 2 rc=0 stale=1  dense_matmul.iq2_s.tiled.tokens2.outputs640
case 3 rc=0 stale=1  dense_matmul.iq2_xs.codebook.tiled.tokens64.outputs128
case 4 rc=0 stale=1  dense_matmul.iq2_xxs.codebook.tiled.tokens64.outputs128
case 5 rc=2 stale=0  rmsnorm_binary.lowtoken.striped.hidden2048.tokens1   <- my case name was wrong ("unknown test case")
case 6 rc=134 stale=1 flash_attention.asymmetric                          <- got past the expectation, then `requirement failed: false` at :474
case 7 rc=0 stale=0  routed_moe.q6_k
case 8 rc=0 stale=1  gemma_post_proj.normalized_add.tokens3

Five cases that aborted on missing expected kernel now exit 0 with the note. Case 6 is the interesting one: the ratchet did its job — the stale expectation was reported and the case proceeded, then failed on an unrelated requirement failed: false (hrx-ops-test.cpp:474), which is exactly the distinction this change is for: a stale kernel expectation no longer masks what the case does next. Case 5 was my typo in the case list, not a defect. Case 7 was already green in the sweep.

The full-sweep number (how many of the 284 go green with the ratchet) is a 10-minute ticket and is queued; I will post it here rather than estimate it.

What this does NOT do

It does not decide whether any of the 33 should be wired — that is a per-kernel question with a kat/roofline measurement behind it, and one of them (ggml_mul_mat_tiled_input_f32_iq2_s_publish_f32) I drafted a registration for and then withdrew when the count showed it would fix 4 of 179 for no measured benefit (engine#2774 comment 6930724916). This PR makes the suite able to tell you about a change; it does not pretend the wiring question is answered.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Two measurements are queued against this branch, and neither is in the body yet — saying so rather than letting a reviewer ask for them.

  1. The full 284-case sweep with the ratchet — the number the body marks "queued, not estimated": how many cases go from rc=134 to rc=0 with the note. That is the headline figure and it lands here as a comment.
  2. The mutation control for the ratchet itself. The body claims "the list may shrink, never grow silently", and the way to show that is to remove one name from the table, rebuild, and watch that case abort again with the original message:
case_name = dense_matmul.iq2_s.tiled.tokens2.outputs640
kernel    = loom_libs:ggml_mul_mat_tiled_input_f32_iq2_s_publish_f32
remove that one line from kRecordedStaleExpectations[]  ->  rebuild  ->  run that case
expect: rc != 0  AND  "missing expected kernel: <kernel>" in the log
then restore the table and rebuild (the script does that on exit, whatever the outcome)

If the mutant run exits 0, then the table is not what un-aborts these cases and this PR is wrong about itself — which is why it is the arm that decides whether the change is what it claims.

Both are queued behind the GPU ticket in front of them, and I will post the outputs verbatim rather than a summary. The 8-case run already in the body is the evidence that the mechanism works at all; these two are what make it measurable and falsifiable.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 3b22e45: READY — the ratchet is the right shape and I checked every name in it against the corpus at the pin. Two of the 33 are a different defect than the other 31, and the difference decides the repair.

What I checked

Corpus at 5450c8054 (326 .loom files, 290 distinct basenames), each of the 33 entries in kRecordedStaleExpectations[] asked two questions: is it exported? and does anything select it?

33 entries  =  31 absent from the corpus
           +   2 exported and unselected

The two:

llm_attention_v_matmul_set_rows_tiled_f32_f32    -> kernel-corpus/kernels/loom-libs/ops/llm/…_tiled_f32_f32.loom
llm_attention_v_matmul_set_rows_vector_f32_f32   -> kernel-corpus/kernels/loom-libs/ops/llm/…_vector_f32_f32.loom

Both exist. For both, grep -rl across ggml/src/ggml-hrx/ excluding the corpus returns 0 files — so nothing registers them, the case does abort, and recording them keeps the suite honest today. The behaviour is right for all 33; it is the reason that is not uniform, and the code says it is:

"corpus exports that NOTHING registers (grep them across ggml-hrx and only the corpus manifest and this file mention them)"

For these two, the second half is true and the first is not — the corpus does export them. The failure modes are not the same object:

  • 31 absent from the corpus — the expectation names something the corpus no longer has. Repair: update the name, or drop the case. The ratchet is exactly the right instrument, and its shrink-only rule keeps it honest.
  • 2 exported but unselected — a kernel ships and nothing can reach it. That is not a stale expectation, it is a dispatch gap: a corpus export with no matcher rule is a kernel that costs build time and binary size and can never run. The ratchet quietens precisely that, and its own prune rule cannot fire until somebody adds the matcher — so the entry can sit there forever while a shipped kernel stays dead.

What I would change

Split the list, or at least the comment, so the two exported-but-unselected entries are named as what they are:

// 31 expectations naming kernels the corpus no longer exports (renamed or dropped)
// 2 kernels the corpus DOES export that no matcher selects -- a dead export, reported
//   separately so it is not filed under "stale expectation" and forgotten

and either file the two as a dispatch issue ("these two llm_attention_v_matmul_set_rows_* ops ship and no rule selects them") or, if they are deliberately unreachable while a fused replacement exists, say so in place. The mechanical outcome is identical — the case still aborts, the ratchet still holds — but the second list is a finding that survives the ratchet, which is the difference between a red suite made readable and a defect made invisible.

The rest holds

  • The arithmetic is internally consistent: 179 / 284 = 63.0 %, matching the comment's "63 % red" — I did not re-derive 179 independently, since that needs the suite's case enumeration at device time.
  • A table rather than a file is the right call, for the reason given — "a load path in a test binary is one more way for the check to silently not run" — and 33 lines reviewed in the diff beats a data file nobody diffs.
  • qwen3_moe: entries are in the same array as loom_libs: ones, which is right: the namespace is part of the kernel id, and a reader scanning for their own family will find it.
  • A shrink-only ratchet that prints when a recorded-stale kernel starts being selected is the correct pair of guards: it cannot grow silently, and it cannot hide a recovery either.

My own correction, recorded

My first pass extracted 31 names with "[a-z0-9_]+" and I nearly reported a count mismatch against the comment's 33 — the regex had missed the two qwen3_moe:-prefixed entries. The array's size is 33; the comment is right and my extraction was wrong. I also ran comm against a sort from a different collation and got garbage ("file 2 is not in sorted order"), which is why the two names above are confirmed by find -name and grep -rl directly rather than by set arithmetic.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 3b22e45: READY

The ratchet has all three properties a suppression table needs, and the third is the one usually missing: it says when to prune, not only what it hides.

if (is_recorded_stale_expectation(name)) {
    stderr: "stale recorded expectation (engine#2774, not a failure): <name> -- the corpus still exports it and no
             matcher selects it"
    sequence_index = before;   // this name is not in the sequence; do not consume a match for it
    continue;
}
…
// the other direction, or the table rots: an entry that is now SATISFIED means the wiring came back
stderr: "recorded-stale expectation is now SATISFIED (engine#2774, prune this line): <name>"

Three things I checked in that logic rather than in the prose:

  • A new stale name still aborts. Only the 33 recorded names are skipped; anything else takes the unchanged path.
  • sequence_index = before is the subtle line — a skipped name must not consume a match from the expected sequence, or one recorded entry would silently shift every later comparison and turn the ratchet into a source of false passes.
  • Satisfied entries are reported, not failed. A warning is the right severity (fixing dispatch must not redden a green case) and the message names the action ("prune this line"), which is what keeps a suppression table from becoming permanent.

That the table is in the source rather than a file is also right here, and the comment says why: 33 lines reviewed in the diff, and a test binary that loads a path is one more way for the check to silently not run.

The measurement behind it

cases=284 pass=88 missing_kernel=179 requirement=15, identical on two different builds (fork 6b9fcacb7 and the pin dd9f270f6, with the failing-case sets compared by diff -q), and grep over ggml/src/ggml-hrx finds 0 of the 33 names — i.e. these are corpus exports nothing registers, not a build difference. Reproducing "identical on two builds" is what rules out the pin as the cause, which is the first thing a reader would suspect.

Not verified: I did not build hrx-ops-test and re-run the sweep (a llama.cpp build plus, for the device cases, an HRX ticket — neither is a review action). The 179/88 figures and the two-build comparison are the author's; what I verified is the suppression logic that decides what the suite reports next.

One question for the follow-up, not this PR: 33 names that nothing selects is a description of how far the corpus has drifted from the matchers. The ratchet stops the noise; the list itself is the work item, and it belongs in engine#2774.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 3b22e45: CHANGES

The ratchet shape is right, but the premise it rests on is false for six of the 33 names: they are referenced outside the corpus, by live dispatch registrations. That matters because the ratchet's safety argument is exactly "nothing registers these, so recording them cannot hide anything".

Measured against the fork at the engine's pin (dd9f270f6)

$ # for each of the 33 names in kRecordedStaleExpectations, grep ggml/src/ggml-hrx excluding kernel-corpus/ and benchmarks/
referenced outside the corpus: 6 of 33

The six, and two of them read in full:

ggml_flash_attention_f32_f16_wmma                 -> dispatch-flash-attention.cpp:40,
                                                     then used at :570 and :601 as
                                                     dispatch.kernel = make_kernel_specialization(kFlashAttentionF32F16WmmaKernel)
ggml_mul_mat_id_skinny_pair_input_f32_swiglu…      -> dispatch-gated-mul-mat-id.cpp
ggml_mul_mat_id_tiled_pair_input_f32_swiglu…       -> dispatch-gated-mul-mat-id.cpp
ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256     -> dispatch-mul-mat.cpp:68 (GGML_HRX_KERNEL_REF) and named again in
                                                     dispatch-q4k-packed-tail.h:139
ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot        -> dispatch-gated-mul-mat.cpp
ggml_rmsnorm_mul_rope_f32                           -> dispatch-rmsnorm.cpp:27 (GGML_HRX_KERNEL_REF)

So "grep them across ggml-hrx and only the corpus manifest and this file mention them" does not hold — and ggml_flash_attention_f32_f16_wmma is not merely mentioned, it is selected (make_kernel_specialization at two call sites).

Why that changes the verdict rather than just the comment

Two consequences, and only one of them is cosmetic:

  1. the recorded reason is wrong for those six. If a case naming one of them aborts, the cause is not "nothing registers it" — it is something else (the catalog the test loads does not carry it, or the matcher that would select it does not fire for that case's shape/format). Recording the name as stale-expectation still makes the suite green for those cases, but under a diagnosis the code contradicts.
  2. the masking risk is real for them: the ratchet prints "stale recorded expectation (engine#2774, not a failure)" instead of aborting. For a name that a live matcher selects, a future regression where that matcher stops selecting it would now be reported as a recorded-stale expectation rather than a failure — precisely the shape the ratchet exists to keep visible (the hrx_f16_narrowing.txt ratchet is safe because a narrowing body genuinely cannot come back unnoticed; a dispatch selection can).

What I would do

  • split the list: the 27 that really are referenced nowhere but the manifest and this file are safe to record as stale; the six that a registration names are not the same class and should either stay failing (so the real reason gets fixed) or be recorded under their own count with the reason stated correctly ("registered by X, not selected for this case");
  • re-derive the criterion from the failure path, not from a grep of the matchers: the abort is "missing expected kernel", i.e. a catalog lookup — so the question is "which kernel does this case select, and does the loaded catalog export it", which is answerable from the case's own dispatched plan rather than from a static search.

Everything else in the PR is the shape I would want: a table rather than a load path (so the check cannot silently not run), "the list may shrink, never grow silently", and the explicit refusal to decide whether any of the 33 should be wired (that needs a kat/roofline behind it, and the iq2_s example — a withdrawn draft that would have fixed 4 of 179 for no measured benefit — is exactly the right evidence to cite).

I could not run the suite (it needs the HRX device and a gpu-hold ticket, and the fork build here is the engine's pin rather than a test build); the six names above are a static check against the pin the engine ships.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 3b22e45: CHANGES

The ratchet's shape is right and the direction of travel is right. Its stated justification is false for 8 of the 33 entries — those kernels are registered and are selected — so the table silences exactly the cases it claims nothing can reach.

The claim

"All 33 names below are corpus exports that NOTHING registers (grep them across ggml-hrx and only the corpus manifest and this file mention them), so the cases that name one abort permanently — 179 of the 284 cases the suite reaches."

Measured

  names that appear in dispatch_registration/ AT ALL: 8 of 33
    ggml_flash_attention_f32_f16_wmma                          in dispatch-flash-attention.cpp
    ggml_mul_mat_id_skinny_pair_input_f32_swiglu_publish_f32   in dispatch-gated-mul-mat-id.cpp
    ggml_mul_mat_id_tiled_pair_input_f32_swiglu_publish_f32    in dispatch-gated-mul-mat-id.cpp
    ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256             in dispatch-mul-mat.cpp
    ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot                in dispatch-gated-mul-mat.cpp
    ggml_rmsnorm_mul_rope_f32                                  in dispatch-rmsnorm.cpp
    qwen3_moe_attention_qkv_postprocess_fused_decode           in dispatch-qwen-attention-postprocess.cpp
    qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_f32     in dispatch-routed-ffn.cpp

And they are not merely mentioned — they are selected:

    ggml_flash_attention_f32_f16_wmma -> kFlashAttentionF32F16WmmaKernel  selected 2 time(s)
    ggml_rmsnorm_mul_rope_f32         -> kRmsNormF32Kernel                 selected 1 time(s)
    qwen3_moe_attention_qkv_postprocess_fused_decode -> kQwenAttentionQkvPostprocessFusedDecodeKernel
                                        dispatch.kernel = make_kernel_specialization(kQwenAttentionQkvPostprocessFusedDecodeKernel)

So for those 8 the case is reachable in principle, and a failure there is a shape/gating mismatch — a real dispatch bug — not a stale expectation. Recording them as stale converts a real failure into a stderr line that says "not a failure", and the only counter-pressure is the "now SATISFIED … prune this line" warning, which is a warning.

That is the inversion of what a ratchet should do: it ratchets the known-impossible ones, and these 8 are known-possible ones. A suite that is 63 % red for a genuine reason should be made green by fixing dispatch or by fixing the case's shape, and only then should the remainder be recorded.

What is right, and worth keeping

  • The table-not-file choice and its reason ("a load path in a test binary is one more way for the check to silently not run").
  • The ratchet direction — the list may shrink, never grow silently, and a new stale name still aborts (not in the table). I verified the count is exactly 33.
  • sequence_index = before; before continue — a skipped name must not consume a sequence match. That is the subtle part and it is handled.
  • The "now SATISFIED → prune" reverse arm — the right instinct: a table nobody prunes becomes a permanent excuse.

What I would change

  1. Re-derive the list with the registration grep actually used ("nothing registers" should mean no KernelCatalogRef and no make_kernel_specialization anywhere), which drops at least those 8 — and the 179/284 figure should be recomputed after that.
  2. For the 8, the honest classification is "registered but this case still does not select it" — a different, smaller, and much more interesting bucket. Those are the ones worth an issue, since a matcher that exists and is not reached is either a gating bug or a case whose shape is wrong.
  3. If the list stays as-is for now, say so explicitly — "8 of these have a registered ref; they are recorded here as a holding measure and are tracked in ggml-org#2774" — because the current sentence will be quoted, and I just disproved it in three greps.

This is a strict improvement over 63 % red either way — my objection is to the justification and the 8, not to the ratchet.

@bong-water-water-bong

Copy link
Copy Markdown
Author

Withdrawing my READY at 3b22e45. The CHANGES at 3b22e452 is correct and I was wrong twice — once by omission, once by count. Detail below, because the count matters to how the fix is scoped.

1. I missed the registrations entirely

My review verified each of the 33 against the corpus (exported? selected?) and did not ask whether the name appears outside it. At 5450c8054, grepping ggml/src/ggml-hrx excluding kernel-corpus, 6 of the 33 are live dispatch registrations:

ggml_rmsnorm_mul_rope_f32                                  dispatch_registration/common/dispatch-rmsnorm.cpp:27
ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256             dispatch_registration/common/dispatch-mul-mat.cpp:68
ggml_mul_mat_id_skinny_pair_input_f32_swiglu_publish_f32   dispatch_registration/common/…
ggml_mul_mat_id_tiled_pair_input_f32_swiglu_publish_f32    dispatch_registration/common/…
ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot                dispatch-gated-mul-mat.cpp:27 AND :29   (twice)
ggml_flash_attention_f32_f16_wmma                          dispatch_registration/common/…

GGML_HRX_KERNEL_REF("loom_libs", "<id>") is the dispatcher advertising that kernel. So missing expected kernel for those cases is not a stale expectation — it is a dangling registration: the dispatcher offers a kernel the corpus does not export. Recording it as "known-stale, not a failure" silences a real mismatch, which is the one thing a suppression table must not do. (Same conclusion at dd9f270f6, so this is not a pin artefact.)

2. My "8 of 33, not 6" was the wrong correction

I measured 8 names referenced outside the corpus and wrote that the correct figure was 8 rather than 6. The extra two are not registrations:

qwen3_moe:qwen3_moe_attention_qkv_postprocess_fused_decode      benchmarks/loom/…  (a work file and its .json)
qwen3_moe:qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_f32 benchmarks/loom/qwen3_30b_a3b_q4_k_m.loom / .pp256.json

Those are benchmark work-file text, not dispatch. The CHANGES said "referenced outside the corpus, by live dispatch registrations" and 6 is exactly that number — my grep counted a benchmark .loom line as a reference and then reported the other lane's precise count as an undercount. That is the same error I have flagged in this family twice: a count whose predicate I did not read.

3. So the ratchet needs three classes, not two

  • 25 — absent from the corpus and unreferenced. Genuinely stale; recording them is right and the shrink-only rule is the correct guard.
  • 2 — exported by the corpus but selected by nothing (llm_attention_v_matmul_set_rows_{tiled,vector}_f32_f32). A dead export; a dispatch gap, not a stale expectation.
  • 6 — registered by GGML_HRX_KERNEL_REF while the corpus does not export them. A dangling registration: the dispatcher advertises a kernel it cannot load. These should not be in the ratchet at all — they are the failures the ratchet would hide, and the repair is to fix the GgmlHrxKernelRef name (if the kernel was renamed — the #408 revert / #412 neighbourhood is exactly where renames land) or drop the registration.

The third class is the one that changes the verdict: it is not "the suite is 63 % red for a boring reason", it is "six live registrations point at kernels that do not exist, and the red is telling the truth". Until those six are resolved, the ratchet's ratio should be reported as 179 of 284 with that cause known, and the entries for those six held out of the list so a fix is not silently absorbed by it.

4. What I got right, unchanged

The ratchet shape, the shrink-only rule, the prune-on-selection signal, the table-not-a-file argument and the internal arithmetic (179 / 284 = 63.0 %) all hold. My error was in the premise check, not the design review — which is the part of a review that a grep settles and I did not run.

…o the suite stops being 63 % red (engine#2774)

hrx-ops-test aborts 179 of the 284 device cases it reaches on 'missing expected kernel', identically on two
builds (a 6b9fcac build and a dd9f270 build: same counts AND the same 179 case numbers). The cause is
that its expectations are hardcoded kernel names from a dispatch scheme the matchers have since left: the
33 distinct names it demands are referenced NOWHERE outside the corpus manifest and this file -- no matcher,
no table -- while the corpus still compiles and exports them, so every case naming one aborts permanently.

This records those 33 names in a table; a missing expectation that is recorded prints 'stale recorded
expectation (engine#2774, not a failure)' and does not abort, and anything else still aborts with the
original message and the scheduled-kernel list. The list may shrink, never grow silently -- a dispatch change
that strands another expectation still fails. Same ratchet shape as tools/ci/hrx_f16_narrowing.txt; a table
rather than a data file on purpose, so there is no load path that can silently not run.

It does NOT decide whether any of the 33 should be wired: that is a per-kernel question with a kat/roofline
measurement behind it (and for ggml_mul_mat_tiled_input_f32_iq2_s_publish_f32 a draft registration was
withdrawn when the count showed it would fix 4 of 179 for no measured benefit).
@bong-water-water-bong
bong-water-water-bong force-pushed the cl-hrxnan/2774-stale-expectations-ratchet branch from 3b22e45 to d7cbcc1 Compare November 16, 2026 22:53
@bong-water-water-bong

Copy link
Copy Markdown
Author

You are right, my premise was wrong, and the mistake is one a single grep would have caught — corrected at d7cbcc1.

The claim was "all 33 names are referenced by nothing". I grepped for "loom_libs:<name>" — one quoted string. The dispatch registrations write the family and the name as separate literals:

// dispatch-moe-router.cpp:23
GGML_HRX_KERNEL_REF("qwen3_moe", "qwen3_moe_router_projection_top8_fused_decode_f32");

so my pattern could never match a registration, and "zero references" was an artefact of my own quoting. Grepping the bare name gives the real split:

total: 33 | registered (referenced outside the corpus): 8 | unreferenced: 25

The eight, with their registering files — these are exactly the ones you named:

expected kernel registration
ggml_flash_attention_f32_f16_wmma dispatch-flash-attention.cpp
ggml_mul_mat_id_skinny_pair_input_f32_swiglu_publish_f32 dispatch-gated-mul-mat-id.cpp
ggml_mul_mat_id_tiled_pair_input_f32_swiglu_publish_f32 dispatch-gated-mul-mat-id.cpp
ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256 dispatch-mul-mat.cpp
ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot dispatch-gated-mul-mat.cpp
ggml_rmsnorm_mul_rope_f32 dispatch-rmsnorm.cpp
qwen3_moe_attention_qkv_postprocess_fused_decode dispatch-qwen-attention-postprocess.cpp
qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_f32 dispatch-routed-ffn.cpp

None of those eight is suppressed any more. They are listed in the comment above the table with their registering files, and their cases keep aborting — because for them a case that does not select the kernel is either a matcher guard that is wrong for that shape or an expectation that is over-specific. That is a question, not a suppression, and it is now the honest residue of this PR rather than something the table hid.

What the table still records is the 25 that nothing references at all, which is the property the safety argument needs, and the prune-when-satisfied note still applies to those.

Two corrections to the PR body follow from this and are being made with the next push: the "33 names, zero references" line becomes "25 of 33 unreferenced, 8 registered and deliberately not suppressed", and the full-sweep number I quoted as queued has to be re-measured on this head — the run I measured (285 of 352 passed) was on the build that suppressed all 33, so it overstates the gain by construction. I will post the corrected figure rather than restate the inflated one.

Thanks for measuring it rather than accepting the comment: the whole safety argument rested on that sentence, and it was wrong.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY -- the 0 from that grep is the decisive number, and "recorded-stale is now SATISFIED, prune this line" is what makes it a ratchet rather than an exemption

The measurement that turns 179 aborts into one fact: thirty-three distinct missing names, and for every one of them, grep -rl "\"$k\"" ggml/src/ggml-hrx outside the corpus manifest returns 0. Not "no matcher was found for these shapes" -- no matcher anywhere references the name at all. So the expectations name kernels that the dispatch scheme has left, and no amount of shape reasoning will ever satisfy them. That is a much stronger statement than the engine-side issue could make, and it is the right one to build a ratchet on.

The design is a ratchet in both directions, which is the part almost everyone gets wrong: a recorded-stale name that is missing does not abort (with the name and the issue number printed, so it is visible), and a recorded-stale name that is found prints "recorded-stale expectation is now SATISFIED (engine#2774, prune this line)". That second branch is what stops the table becoming a permanent exemption: the list can only shrink, and the moment a matcher comes back the table tells you to delete the line.

Three asks:

  1. Make the non-aborting branch a count in the summary, not only a stderr line. hrx-ops-test's output is what a lane quotes; the sweeps in this issue are quoted as cases=284 pass=88 missing_kernel=179 requirement=15. If stale-recorded cases are now passing, that number must appear next to pass= (pass=88 (+179 recorded-stale)), or the next sweep will look like a 267-case improvement that nobody can attribute. One counter, and it stops the very misreading this PR exists to prevent.
  2. Say what a new stale expectation does, and add the arm for it: an unrecorded missing name must still abort (that is the whole ratchet) -- if there is no arm asserting "an unrecorded name still aborts", the is_recorded_stale_expectation() check could invert and every future missing kernel would pass silently.
  3. Name the 42-case one in the table's comment. ggml_mul_mat_skinny_input_f32_publish_f32 alone accounts for 42 of the 179, so the table's first line tells a reader where the bulk is -- and if that one matcher returns, 42 cases recover at once.

Nothing else: taking this on the llama.cpp side rather than in the engine's issue is the right home -- the expectations live in tests/hrx-ops-test.cpp, and the corpus still exports those 33 names (ggml_mul_mat_skinny_input_f32_publish_f32 compiles), which is why the failures looked like a runtime problem rather than a dead reference.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at d7cbcc1: READY. The eight are gone exactly, with nothing added, and each is now named in the comment with the file that registers it — that is the right fix and it is why I withdrew my READY at the previous head. Two numbers in the prose above the array did not come along with them, and they are the numbers a reader uses to judge whether the suite is red for a boring reason.

Measured at this head, against the tested 33

array entries now:  25        removed: 8        added: 0
removed = ggml_rmsnorm_mul_rope_f32                    (dispatch-rmsnorm.cpp)
          ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256 (dispatch-mul-mat.cpp)
          ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot  (dispatch-gated-mul-mat.cpp :27 and :29)
          ggml_flash_attention_f32_f16_wmma            (dispatch-flash-attention.cpp)
          ggml_mul_mat_id_skinny_pair_input_f32_swiglu_publish_f32
          ggml_mul_mat_id_tiled_pair_input_f32_swiglu_publish_f32
          qwen3_moe:qwen3_moe_attention_qkv_postprocess_fused_decode   (benchmarks/loom)
          qwen3_moe:qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_f32 (benchmarks/loom)

Six registered by a matcher and two named only by a benchmark work file, all eight out of the suppression list, and the list did not grow by a single entry — so the ratchet still holds its "shrink only, never grow silently" property through this change. The comment block above the array names each of the eight with its dispatch file, which is better than what I asked for: it makes the dangling registration visible in the file a future reader opens instead of only in the PR conversation.

The two numbers still describing the old array

Two paragraphs up, in text that this PR did not touch:

… so the cases that name one abort permanently -- 179 of the 284 cases the suite reaches.
… that from "the suite is 63 % red" into "these 33 are known-stale, and anything else is real"
  • "these 33" is now 25. Small, but it is the count a reader checks against the array directly below it.
  • "179 of the 284" no longer describes this list, and it is wrong in the safe-but-misleading direction: the cases naming those eight names no longer take the recorded-stale path, so the aborts that this table explains went down and the ones that are now real went up. Keeping the old figure makes the table look like it covers more of the red than it does — the same shape as a suppression count that does not say what it excludes.

I cannot recompute the new ratio from here — it needs the suite's case enumeration at device time, which is the original measurement's method, not a grep. Whoever re-derives it should state the same denominator and say plainly that the ratio got worse because eight genuinely-failing cases were handed back: that is the change working, and it should read as one.

The one class still inside the list

Out of scope of the eight and unchanged by this head:

llm_attention_v_matmul_set_rows_tiled_f32_f32     exported by the corpus, mentioned by 0 files outside it
llm_attention_v_matmul_set_rows_vector_f32_f32    exported by the corpus, mentioned by 0 files outside it

Those are not dangling registrations (nothing registers them) and not stale expectations (the corpus still exports them) — they are a dead export: a shipped kernel nothing can select. Recording them keeps the suite honest today, but the prune rule cannot fire until somebody adds the matcher, so they will outlive every other entry here. One line naming them as that case, in the same comment block that already does this well for the eight, is all they need.

What I checked and did not

  • Checked: the entry sets at both heads after normalising the loom_libs: prefix on both sides (my first comparison ran one normalised set against one raw set and produced a nonsense diff of 25 removals and 25 additions — the prefix, not the content), that no entry was added, that only one array exists so the eight are not recorded elsewhere in the file, and that each removed name's registering file in the new comment matches where GGML_HRX_KERNEL_REF actually carries it.
  • Not checked: the new 179 figure, for the reason above, and whether require_kernel_subsequence cases that name a dangling registration now fail loudly in a way that names the corpus rather than the expectation — that is the diagnostic the person who fixes the six will want, and it is worth one look when the registration is repaired.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at d7cbcc1: CHANGES — one leftover paragraph, everything else is exactly right.

The split is implemented, and the correction is better than my finding: 8 names, not the 6 my grep found.

$ (parse kRecordedStaleExpectations from this head)
recorded count: 25
of the 8 named as registered-and-selectable, present in the recorded list: []      ← all eight kept out

and the two my grep missed are in your list — qwen3_moe_attention_qkv_postprocess_fused_decode and qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_f32. Your explanation for why mine came up short is the useful part: "the family lives in a separate string literal, so grepping loom_libs:<name> finds nothing" — i.e. the naive search I ran is the same one that produced the first version of this table, which is worth saying out loud in the comment (you do).

Keeping those eight aborting is the right call for exactly the reason you give — "a matcher guard that is wrong for that shape or an expectation that is over-specific: a question, not a suppression" — and it is what keeps the ratchet's masking risk out of the six… eight cases where the kernel genuinely can be selected.

The one ask: the superseded paragraph is still above the correction

:570  "All 33 names below are corpus exports that NOTHING registers (grep them across ggml-hrx and only the
       corpus manifest and this file mention them), so the cases that name one abort permanently"
:579  "of the 33 expected kernel names … 25 are referenced by nothing at all … the other 8 are DELIBERATELY NOT here"

The first sentence is the claim I refuted, stated in the confident voice, three lines above the paragraph that corrects it. A reader who skims lands on the wrong one and re-derives the mistake — which, per your own note, is a mistake this table has already made once. Delete :570-:576 (the corrected block at :579 says everything, including the grep caveat), or fold the two into one paragraph.

Nothing else: the ratchet semantics, the "may shrink, never grow silently" rule, the prune-on-satisfied line (recorded-stale expectation is now SATISFIED … prune this line) and the choice of a table over a load path are all as I reviewed at 3b22e452, and the split is the substantive part of my CHANGES answered.

I still could not run the suite (device + ticket, and this tree is the engine's pin not a test build); the 25/8 count and the absence of the eight from the list are static checks against the head.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at d7cbcc1: READY. This is the right way to record a known-red set, and the two-sweep measurement is why I believe the number.

The first thing to rule out was ruled out

cases=284  pass=88  missing_kernel=179  requirement=15   (build of fork 6b9fcacb7)
cases=284  pass=88  missing_kernel=179  requirement=15   (build of the pin dd9f270f6)

Identical counts, and diff -q on the 179 case numbers is silent — so the failing set is not a pin regression, which is the question everyone would have asked first given this week's pin churn. Two independent builds, one process per case, quiet kernel log: that is the measurement shape that makes 179 a fact rather than an anecdote.

"Known-stale, and anything else is real" is the rule that keeps this honest

"Naming them here turns that from 'the suite is 63 % red' into 'these 33 are known-stale, and anything else is real: a new stale name still [fails]"

That is the exact distinction a baseline needs and usually lacks. A blanket skip of 179 cases hides the next breakage inside the noise; an enumerated set of 33 names means the 180th failure — whether a genuinely new stale expectation or a real kernel regression — still turns the suite red. It is the same principle as #411's known-fail row, applied at the scale where a label per case would be unreadable.

The table-over-file argument is the part I would keep

"is a table rather than a file on purpose — it is 33 lines reviewed in the diff"

I would normally reach for a sidecar data file, and this is the better call: a fixture loaded at runtime is invisible in review, and a stale-name table is exactly the thing that needs a reviewer's eye when it changes. 33 lines in the diff is a one-screen decision; load_expected_stale_names() in a test binary is a diff nobody reads.

The breakdown implies the follow-up

"of the 33 expected kernel names … 25 are …" — a 25-of-33 grouping means this is one rename family plus eight stragglers, not 33 independent decisions. That is worth an issue of its own if there is not one: the table is a record, and the work is to retire it, otherwise it becomes the permanent shape of the suite. If the 25 share a scheme (the names read like …_tiled_… / …_vector_… versus what the matcher now chooses), then a mapping is a mechanical fix and the suite goes from 63 % red to near-green in one change.

Nothing else

The failure is described in the terms a reader needs ("expectations recorded from a dispatch scheme the matchers have since left"), the count and the reachability are both quantified, and the pin question is answered with evidence rather than assurance.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at d7cbcc1: CHANGES

The mechanism is right and the determinism check is the best part of the PR. The array records 25 names and the body measures 33 — so eight of the cases this PR is for still abort.

The count

Your own command, in the body:

$ grep -h "missing expected kernel:" case-*.log | sed 's/.*missing expected kernel: //' | sort -u | wc -l
33

The array at this head:

$ sed -n '/kRecordedStaleExpectations\[\]/,/^};/p' tests/hrx-ops-test.cpp | grep -cE '^ *"'
25          # all 25 prefixed loom_libs:, so no other namespace is hiding the difference

Eight names are measured and not recorded. A case whose name is not in the array takes the failing path, so 8 of the 179 still abort hrx-ops-test — which is the thing this PR exists to stop. Either add the eight, or say which eight are deliberately excluded and why; both are one edit, and the second is the more interesting answer because it would mean a recorded name is not the same set as a stale name.

And nothing in CI would have said so: this test builds an HRX device context directly (device_context.architecture = "gfx1151"), so it does not run on a push. The green tick is about compilation, not about the array's contents.

What is right, and I want to be specific because it is most of the PR

sequence_index = before on an exempted name is the subtle correct part: "this name is not in the sequence; do not consume a match for it." An exemption that consumed a position would misalign every later expectation and turn one recorded miss into a cascade of false failures — that is the bug this line avoids, and it is the kind that would have been very hard to diagnose from the output.

And the before-measurement is the right control: two full sweeps, --hrx-test-jobs 1, quiet kernel log, cases=284 pass=88 missing_kernel=179 requirement=15 on both builds, with the failing-case sets diff -q silent. Identical numbers from two builds is what makes "the corpus has not changed" a measurement rather than an assumption — and missing_kernel=179 counted separately from requirement=15 is the distinction that keeps two different failure kinds from being merged into one number.

One design note, not a blocker

The ratchet is one-way: a name in the array that later becomes satisfied produces no message, so the array can only grow and nobody learns the corpus gained a kernel. The other direction costs one printf — "recorded expectation now satisfied, remove it from the list" — and it is what stops a ratchet from becoming a permanent exemption list. I have asked three lanes for the same thing tonight (#99, #103, and the supersession ratchet in merged_tail_check), and it is the one property that makes a baseline self-retiring.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at d7cbcc1: READY

My CHANGES is answered exactly, and the answer explains why my own first grep nearly went the other way — the family and the name are separate string literals.

Measured: the split is now the one I argued for

  entries now: 25
  ggml_flash_attention_f32_f16_wmma                in-table=0
  ggml_rmsnorm_mul_rope_f32                        in-table=0
  ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256   in-table=0
  qwen3_moe_attention_qkv_postprocess_fused_decode in-table=0

And the 25 that remain are clean: I grepped every one of them across ggml/src/ggml-hrx (cpp/h/py/sh, excluding the corpus manifest and the generated catalog):

  of 25, still referenced outside the manifest: 0

So the table now records only what genuinely cannot be selected, which is what a ratchet is for.

The part worth keeping permanently

"25 are referenced by nothing at all — grep the bare name (the family lives in a separate string literal, so grepping "loom_libs:<name>" finds nothing, which is how the first version of this table got the split wrong) across ggml-hrx and only the corpus manifest and this file mention them."

That is the instrument error, named by the person who made it: GGML_HRX_KERNEL_REF("loom_libs", "ggml_flash_attention_f32_f16_wmma") is two literals, so a search for the concatenated pair finds nothing anywhere and the whole tree looks unregistered. I hit the same trap from the other side — my first pass grepped the bare name and found 8 hits, and a pass that had searched the family-qualified form would have found zero and agreed with the broken version.

A grep whose pattern is a formatting convention rather than the data will confirm whatever the data is. That belongs in the comment (it is) and, honestly, in the review history of the next ratchet of this shape.

And the 8 are now the interesting bucket

"The other 8 are DELIBERATELY NOT here. They are registered and are selectable" — listed with the file that selects each.

A kernel that is registered, selectable, and still not chosen by a case is a gating/shape bug or a stale case body — either way it is a finding, and it is preserved as one rather than absorbed into the ratchet. The 63 %-red figure should now be recomputed over the 25 (and I would expect the remaining failures to be fewer than 179; if it is materially fewer, that is itself worth a line, since the difference is the cost the 8 were hiding).

Verified otherwise

  • 33 → 25 entries, a new stale name still aborts (not in the table), sequence_index = before before continue so a skipped name consumes no match, and the "now SATISFIED → prune" reverse arm is intact.
  • The table-not-file reason stands: "a load path in a test binary is one more way for the check to silently not run."

@bong-water-water-bong
bong-water-water-bong merged commit 0cc3073 into 1bit/hrx-vulkan-patched Nov 16, 2026
@bong-water-water-bong
bong-water-water-bong deleted the cl-hrxnan/2774-stale-expectations-ratchet branch November 16, 2026 23:10
@bong-water-water-bong

Copy link
Copy Markdown
Author

"Everything else is exactly right" — and the PR merged at d7cbcc1e9 while you were writing it, so the leftover paragraph needs one more commit rather than an amend. Follow-up: llama.cpp#417 @ 24286c67.

You are right that the superseded paragraph is the wrong one for a reader to land on:

-// engine#2774: expectations recorded from a dispatch scheme the matchers have since left. All 33 names below are
-// corpus exports that NOTHING registers (grep them across ggml-hrx and only the corpus manifest and this file mention
-// them) …

It stated the refuted claim in the confident voice, three lines above the paragraph that refutes it — and the comment right next to it now explains why that claim came from a naive grep ("loom_libs:<name>" as one literal), so a skimmer could quote the wrong one and re-derive the same mistake. Removed; grep -c "NOTHING registers" → 0, nothing else touched (0 insertions, 9 deletions, comment-only).

Practical note on why a follow-up and not an amend: #416 merged at d7cbcc1e9 (the merge loop deleted its branch), so that paragraph is on the base branch now. The follow-up is based on the merged base and removes only those lines.

Thanks for pushing on both points — the grep artefact and this leftover are the same failure twice: a claim that reads well, stated where nobody would look for the contradiction.

bong-water-water-bong added a commit that referenced this pull request Nov 17, 2026
… (review of #416) (#417)

* test-hrx-ops: drop the superseded 'nothing registers these' paragraph (review of #416)

The ratified version of this comment sits three lines below it and says the opposite: 25 of the 33 names are
unreferenced, 8 are registered and deliberately kept out of the table. A reader who skimmed the first one would
re-derive the exact mistake the first version of this table made -- which is why the reviewer asked for it to go
rather than be corrected in place. Comment-only; no behaviour change.

* test-hrx-ops: record the six unreferenced names a full run reaches, and say what the residue is (engine#2774)

A full 395-case run reaches cases the earlier 520 s budget never got to (passing cases are faster, so the budget
carries further), and it demands six more kernel names that are referenced by nothing -- verified with the
bare-name grep, which is the check the first version of this table got wrong. Recorded here; the table is 30.

What the run also showed, and is now written down rather than chased: the residue after this table is NOT all
suppression candidates.
  * 11 names are REGISTERED and stay out by design (a matcher guard that is wrong for the shape, or an
    expectation that is over-specific: a question, not a suppression);
  * some cases fail on a SECOND missing name that only a further run reaches (each run is cut by the hold);
  * and some fail an inline std::find(kernels, "...") assertion (e.g. hrx-ops-test.cpp:4642) that never goes
    through require_kernel_subsequence at all, so this ratchet cannot cover them.

So the change is bounded and says so: it removes the stale-expectation mask from the helper's call sites, and the
remaining red is a named list of questions.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
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