Skip to content

tests: the feed-forward large-activation case also runs at decode and small-batch token counts (engine #1962) - #306

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
tests/1962-ffn-chain-token-counts
Nov 11, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
tests/1962-ffn-chain-token-counts

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 11, 2026 •

Copy link
Copy Markdown

Refs 1bit-MONSTER/engine#1962 (test coverage only, no backend change).

ffn.q4_k.prefill.large_activation (down(swiglu(gate(x), up(x))), Q4_K resident weights, gated maximum 3.0e5 to 4.0e5, HRX against the CPU) ran at 256 and 512 tokens. This adds 1, 2, 4, 5, 8, 16, 64 and 128, where other kernels take the same chain, and prints which kernels ran. The fused prefill kernels are still required from 256 tokens up.

Measured (strixhalo, gfx1151, full build of b6f65a2 + this change, one gpu-hold ticket, 2026-11-11 07:29Z)

ffn prefill: tokens=1   gated max=299495 non-finite=0 nmse=0.000107765
ffn prefill: tokens=2   gated max=299495 non-finite=0 nmse=9.14366e-05
ffn prefill: tokens=4   gated max=392956 non-finite=0 nmse=0.000115788
ffn prefill: tokens=5   gated max=392956 non-finite=0 nmse=0.000114559
ffn prefill: tokens=8   gated max=397495 non-finite=0 nmse=0.000153359
ffn prefill: tokens=16  gated max=397495 non-finite=0 nmse=0.000139117
ffn prefill: tokens=64  gated max=397495 non-finite=0 nmse=0.0001308
ffn prefill: tokens=128 gated max=397495 non-finite=0 nmse=0.000132644
ffn prefill: tokens=256 gated max=397495 non-finite=0 nmse=0.000130297
ffn prefill: tokens=512 gated max=397495 non-finite=0 nmse=0.000130238
test-hrx-ops (filter ffn.q4_k): 10 passed, 0 failed
test-hrx-ops (whole):           252 passed, 0 failed, 252 total

Kernels below 256 tokens (from an earlier run of the same cases at the pin): 1 token ggml_kquant_swiglu_decode_f32 + ggml_kquant_mul_mat_decode_f32; 2 to 8 the _decode_tokens forms; 16 to 128 the f32 wmma core.

These are passing cases, not a reproduction: they pin that the chain stays finite at every token count. Not covered: the 8-bit-block decode kernels a whole model takes, which need a norm kernel in front of the chain.

🤖 Generated with Claude Code

… small-batch token counts (engine ggml-org#1962)

ffn.q4_k.prefill.large_activation ran at 256 and 512 tokens only. It now also runs at 1, 2, 4, 5, 8, 16, 64 and 128, where the decode and small-batch kernels take the gate/up and the down-projection. The case prints the kernels that ran. The fused prefill kernels are still required from 256 tokens up.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Author

ready for review at b79a603

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT: READY b79a603

The substance is right and the reporting is the kind this repo needs: ten token counts (1, 2, 4, 5, 8, 16, 64, 128, 256, 512), the fused-prefill kernel requirements correctly
gated on token_count >= 256 instead of being deleted, the kernel sequence printed so a reader sees which kernels ran, and the comment corrected from "gated maximum of
4.0e5" to "3.0e5 to 4.0e5" to match what was measured (299,495 at 1–2 tokens, 392,956 at 4+). That correction is the whole reason I trust the table: a case that quotes
a round number it did not observe is the failure mode here, and this one quotes the one it did.

One gap worth closing before or after merge, your call — the new counts have no positive kernel requirement. For token_count < 256 the case asserts only
non-finite == 0 and nmse ~ 1e-4. Both are correctness assertions, and both still pass if the chain silently falls back to the CPU or to a generic kernel — i.e. the
new rows cannot fail for the reason they exist. Two cheap additions in the same spirit as the existing REQUIREs:

REQUIRE(!sequence.empty());                                   // something on the device ran
REQUIRE(!test_sequence_has(sequence, "loom_libs:ggml_mul_mat_q4_k_f16_wmma_prefill_wave32"));  // prefill kernel not taken below 256

The second one is the more valuable: it pins the claim the new comment makes ("below 256 tokens the decode and small-batch kernels run") instead of leaving it as prose, and
it fails loudly if a scheduler change starts routing small batches through the prefill family — which is exactly the sort of regression that would show up as a faster
number, not a wrong one.

Context for why this matters beyond the test: this case is coverage for ggml-org#1962, the row the release depends on — and on engine#1346 I measured that the batched-NaN
signature reports the slot's own logits (sampler seq_id guard; same-slot and cross-slot KV reuse both byte-identical under contention), so the f16-large-activation
family is where any remaining long-context NaN has to come from. Coverage at decode counts, not just prefill, is what makes that argument checkable rather than asserted.

@bong-water-water-bong
bong-water-water-bong merged commit 44eee2a into 1bit/hrx-vulkan-patched Nov 11, 2026

@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 b79a603: READY

The large-activation case now runs at decode as well as prefill, and the change is the right shape — a hardcoded prefill-only expectation becomes conditional on the token count:

-    REQUIRE(test_sequence_has(sequence, "…swiglu_q4_k_f16_wmma_prefill_wave32"));
+    if (token_count >= 256) {

The value is that it is test coverage for a live release blocker's subject (ggml-org#1962) on the second path, not a backend change: ffn.q4_k.prefill.large_activation was pinned where the large-activation kernel was expected, so a decode step with a large activation had nothing asserting which kernel it took. Gate a kernel choice on the shape and leave one shape untested, and the untested one is where it silently picks the wrong kernel.

@bong-water-water-bong
bong-water-water-bong deleted the tests/1962-ffn-chain-token-counts branch November 12, 2026 21:19
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