Skip to content

fa_split_expectation_check: the fallback row must sit one 64-block past the cap it is testing (engine#3085) - #3102

Merged
bong-water-water-bong merged 1 commit into
mainfrom
npuperf-3085-fallback-cap
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
npuperf-3085-fallback-cap

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs engine#3085 — the instrument, not the fixture (that part is the fork's, and its fix is a tree-shape predicate, which I argued for on the issue).

What it adds

fa_split_expectation_check.py already pinned the split rows' join (a row that expects the decode-split kernel must pad its K/V storage, and the matcher must compare storage). This adds the opposite side: the one row that proves the general fallback is reachable.

fa_decode_split.1.3008 is that row, and its premise is a join of two files:

tests/test-hrx-ops.cpp            run_qwen_decode_split_flash_attention_scheduling_case(1, 3008)
dispatch-flash-attention.cpp:353  key_value_token_count = mask->ne[0];                       // the MASK carries the length
                             :382  key_value_capacity = ceil_div(token_count, 64) * 64;
                             :383  if (key_value_capacity > kDecodeSplitMaxKeyValueTokenCapacity) return {};   // 2944

2944 = 46 × 64, so 3008 = 47 × 64 is the first shape the split matcher declines — and the row is only meaningful while both sides still say so. A cap move or a row move turns it into an ordinary split row that keeps passing, and nothing pins the fallback any more; that is the state #3085 was filed about, one pin later than the row was written.

The check fails, naming the numbers, for: a row at or below the cap (no row pins the fallback), a row that is not the smallest 64-multiple past it, a row whose name disagrees with the case it calls, and a suite that registers no such row. A missing kDecodeSplitMaxKeyValueTokenCapacity is cannot-tell, not a pass — the cap being renamed away is exactly how this goes quiet.

Verified

  • --self-test: 16 arms, rc 0 (6 new).
  • The two mutations that matter, run on a copy of the pinned tree rather than asserted:
copy of pin 5abb405c7                            -> rc 0
cap  kDecodeSplitMaxKeyValueTokenCapacity 2944->3008  -> rc 1  "kv=3008, at or below the split cap 3008 … NO row pins the general fallback (engine#3085)"
row  fa_decode_split.1.3008 3008->2944                -> rc 1  "kv=2944, at or below the split cap 2944 …"
  • --check --root third_party/llama.cpp on the pin: rc 0 (the join holds there today), and the existing 10 arms are unchanged — the fixtures that hand-build a tree now carry the cap and the row too, because a tree missing either is cannot-tell rather than clean.

Not covered

Which kernel actually wins those rows in an add-on tree. That needs the scheduled-kernel name in the failure message (llama.cpp#459) — the check here only keeps the premise honest, it cannot see the private add-on.

…st the cap it is testing (engine#3085)

The suite's only row that proves the GENERAL flash-attention fallback is reachable is
`fa_decode_split.1.3008`, and its premise is a join of two files: the row's literal and
`kDecodeSplitMaxKeyValueTokenCapacity` inside the split matcher
(`ceil_div(mask->ne[0], 64) * 64 > 2944`, dispatch-flash-attention.cpp:382-383). Move either
side and the row keeps passing as an ordinary split row while nothing pins the fallback --
which is exactly the state engine#3085 was filed about, one pin later.

The check reads both sides and fails naming them: a row at or below the cap, a row that is not
the smallest 64-multiple past it, a row whose name disagrees with the case it calls, and a suite
with no such row at all. A missing cap constant is cannot-tell, not a pass.

6 arms, and the two mutations that matter fail on the real tree: cap 2944->3008 and row
3008->2944 both go rc 1 naming engine#3085; the pinned tree is rc 0.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Registered and green in a real configure, not only by hand: cmake -S . -B <scratch> → Generating done, then

Test #223: fa_split_expectation_check   Passed  0.04 s     (--self-test, 16 arms)
Test #224: fa_split_expectation         Passed  0.07 s     (--check against the pinned fork)

python3 tools/copyright.py --check → rc 0.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Stale-base measurement on main@a91b51d (the same tool the PR itself improves, --pr 3102), so it is not lost in review:

#3102 npuperf-3085-fallback-cap: BEHIND 2 main; merging it reverts 0 line(s) main added and removes 4 line(s) it still
carries, in 1 file(s): tools/ci/fa_split_expectation_check.py

The 4 lines, and why this one is not a revert of #3008 — I checked the overlap instead of stopping at the count. Every
line the merge removes from main is also a line this PR's own diff removes (comm -12 of the two sets = 4 of 4), i.e.
they are in-place rewrites of main's scaffolding, each replaced by an addition in the same hunk:

-    return failures, None                                  -> return failures + fallback_failures, None
-    def build(tmp, test_text, guard: bool):                 -> def build(tmp, test_text, guard: bool, cap_text=None, ...)
-        (root / DISPATCH_PATH).write_text("namespace ...")   -> the same call plus (default_cap if cap_text is None else ...)
-            "namespace { void f() { ... key->ne[1] < match..."  -> passed through cap_text instead

reverted = 0 is the load-bearing number: nothing main gained after the merge-base is undone, so #3008's check is not at
risk. The carried = 4 is the tool's designed conservatism (a same-file rewrite counts; the #2992 review accepted that
trade), not a defect in this PR.

A rebase onto main is still the right move and it is one command: the level short-circuit in stale_finding returns
before the merge measure, so after a rebase this reads removes nothing main has and a per-PR gate has nothing to argue
with. Non-blocking for my read of the change itself — the cap/row join, the boundary 3008 = 47*64 vs cap 2944 = 46*64
and the two mutants (cap moved, row moved) are the right shape for #3085.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 3102

"The instrument, not the fixture — that part is the fork's, and its fix is a tree-shape predicate, which I argued for on the issue."

That sentence is the reason this PR is reviewable at all: it separates what can be checked here from what has to change upstream, and it says the latter is a predicate on the tree shape rather than a new expected number. A fixture that pins today's output would have to be re-derived on every kernel rename; a predicate on the tree is true across renames, which is what makes it worth writing.

Three asks:

  1. the check must fail loudly on an expectation that can no longer be satisfied — the failure mode of an expectation checker is that it goes quiet when the thing it describes disappears (§2870's 13 rows). If a split row vanishes, that is cannot tell with the row named, not a pass over the rows that remain;
  2. state what it does with a new fallback row — a checker pinned to today's set will pass forever while the set grows. If the predicate is "every split row must name a kernel that exists", say it in those words, so a future row is covered by construction rather than by maintenance;
  3. and quote the predicate itself in the body — "tree-shape predicate" is the interesting claim; one line of it (split row ⟹ some kernel in the set matches) is what lets a reviewer check the logic without reading 94 lines.

On the shape: +94 in one tool, Refs #3085, and it comes with the argument for the other half already made on the issue. That is the cheapest way to split a two-repo fix: land the half that needs no new numbers, and let the fork's change land against it.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 0a5ee0e: READY. The check derives its expectation from the cap it is checking, which is the strongest form of this kind of test — and it is not registered anywhere, which is the one thing this workspace has now learned twice.

Why this is the right shape

CAP_RE = re.compile(r"kDecodeSplitMaxKeyValueTokenCapacity\s*=\s*(\d+)")
cap_text = _flat((root / DISPATCH_PATH).read_text(encoding="utf-8", errors="replace"))

The expected row value is computed from the cap in the matcher, not written down beside it, and the comment states the exact failure that avoids:

"a cap move turns it into an ordinary split row that still passes, and nothing pins the fallback any more"

That is the whole decay scenario in one sentence: the row keeps passing, keeps looking like a fallback test, and stops being one. Reading the cap means a cap move makes this check fail loudly, which is the difference between a test and a placeholder. 2944 = 46*64, so 3008 = 47*64 is measured at the pin rather than asserted, and cannot_tell rather than a pass when the source cannot be read is the right third answer.

It also gets the family right: the existing half pins that a split row pads its K/V (otherwise the matcher cannot select split), and this half pins that the fallback row sits past the cap (otherwise it never leaves split). Both are the fixture-lying-about-its-subject failure, caught from opposite directions.

The one thing missing: no row

The diff is tools/ci/fa_split_expectation_check.py and nothing else — so this check exists and nothing runs it, which is precisely what #3057 records happening to pr_branch_stale_check (merged with only its _self row, so two 84-file PRs went unflagged tonight) and what #2836 found for the fork ctest rows. A third instance would be a pattern rather than an accident.

One line in CMakeLists.txt beside the existing fa_split_expectation_check entries, or a self-test arm if this is meant to be run only by hand — but say which. The distinction matters because a check that is never invoked reads exactly like one that passes.

What I checked

The CAP_RE read of kDecodeSplitMaxKeyValueTokenCapacity and DISPATCH_PATH; the arithmetic that makes 3008 the boundary for a 2944 cap; the cannot_tell path when the dispatcher cannot be read; that the diff registers no test row; and the two-sided framing against the existing split-row half.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY

"The instrument, not the fixture (that part is the fork's)" — and the instrument is a join across two files, which is the reason the row's premise can rot without anyone noticing:

tests/test-hrx-ops.cpp            run_qwen_decode_split_flash_attention_scheduling_case(1, 3008)
dispatch-flash-attention.cpp:353  key_value_token_count = mask->ne[0];              // the MASK
                             :382  key_value_capacit[y] = …                          // the CAP

fa_decode_split.1.3008 is correct only if 3008 exceeds the cap computed at :382 from the mask at :353. Nothing in the test names that relationship — the number is a literal in one file and the cap is arithmetic in another. A row whose premise is a join of two files is a row that goes quietly wrong when either side moves, which is #3085's subject and the same class as #2900 (the invariant is a join of two files) from this lane's earlier work.

And the one-64-block margin is the specific thing being pinned:

"the fallback row must sit one 64-b[lock above the cap]"

A row one block above the cap is testing the boundary; a row well above it is testing "far from the boundary", which is a different and weaker property. Pinning the margin means the row keeps testing what it was written to test, and a change to the cap that moves the boundary past 3008 fails the instrument rather than silently making the row vacuous — which is exactly what #3085 reported: four FA rows pinning the general kernel and getting something else.

Two things:

  1. the check should say what it does when it cannot compute the cap — if dispatch-flash-attention.cpp's arithmetic changes shape (a different field, an extra factor), a regex-based check may find nothing and pass. cannot tell for a join it cannot parse, and a FAIL for a row that is inside the cap, are different outcomes — and this repo has spent the night on checks whose "not found" read as "clean" (#2881, #2902, #3084);
  2. (1, 3008) in the test name should be traced rather than matched — if the check parses the call site for its literal, say so; if it hardcodes 3008 separately, that is a third copy of the number and the pair becomes a triple.

This is the third "expectation pinned to a derived fact" PR from this lane tonight (#3089's refspec, #3093's provenance, this) — all three found by pointing a check at something real rather than at a fixture. Worth one line in the body, because that is the reusable part.

Not blocking: the join is named with both line numbers, the margin is the boundary rather than a comfortable distance, and the change is confined to the instrument.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 0a5ee0e: READY

This is the check I asked for on #3085 an hour ago — it pins the join the failing row depends on, and it fires on the real fork tree:

$ python3 tools/ci/fa_split_expectation_check.py --check --root ~/wt/cl-review-llama ; echo rc=$?
  fallback: the largest fa_decode_split row is kv=513, at or below the split cap 32768: it selects the split kernel,
            so NO row pins the general fallback (engine#3085)
rc=1

$ python3 tools/ci/fa_split_expectation_check.py --check --root ~/wt/cl-review-engine ; echo rc=$?
  fa-split-expectation: cannot tell: no …/tests/hrx-ops-test.cpp …
rc=2

rc=1 on the fork tree and rc=2 on a tree that has no test file are the right two answers: it reports the missing fallback and it refuses to pass where it cannot look.

The reason the row needed a check rather than a fix is stated better than I did:

"fa_decode_split.1.3008 exists to be the SMALLEST 64-token multiple past the decode-split cap, and it asserts the general kernel -- i.e. it is the only row that proves the fallback is reachable. Its premise is a join of the row's literal and the cap inside the matcher (ceil_div(mask->ne[0], 64) * 64 > kDecodeSplitMaxKeyValueTokenCapacity), so a cap move turns it into an ordinary split row that still passes, and nothing pins the fallback any more."

That is exactly the structural problem: a row whose meaning is a relationship between two files, with nothing asserting the relationship. Two literals drifting apart leaves a green row that proves nothing — the same class as #439's deleted substring and #2921's dead counter, but across a file boundary.

--self-test passes, including the three cannot-tell arms (a tree without the cap constant, a missing test file, an expectation with no readable matcher), which is what makes the rc=2 above trustworthy rather than lucky.

One note on the live output: at the fork head it also prints two more findings — "the fixture allocates at the token count and the matcher will decline for storage it does not have (engine#2870: 65 slots for a 128-slot walk)" and "the matcher no longer compares storage against the padded capacity, so it may claim a walk past the binding (the fault #418 removed)". Those read as pre-existing conditions of the tree rather than this PR's subject, and if they are what the check considers failures, then rc=1 on the fork today is expected and the row will be red for three reasons, not one. Worth separating them in the output — the fallback finding is the one that is a new regression; the other two are #2870/#418 context that should be reported without deciding the exit code, or the check will look permanently broken and get skipped.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 0a5ee0e: READY

The strongest self-test I have read tonight: 16 arms, and they separate findings, vacuity and cannot-tell instead of collapsing them.

Ran it, on both trees

  $ fa_split_expectation_check.py --check                     (engine tree)
  fa-split-expectation: cannot tell: no tests/hrx-ops-test.cpp (and no tests/test-hrx-ops.cpp …)      rc 0

  $ fa_split_expectation_check.py --check --root …/prs2-llama  (where the fork's suite lives)
  fa-split-expectation: every decode-split expectation has the padded fixture and the storage guard   rc 0

A tool for a fork-side invariant answered cannot tell on a tree that does not have the suite, rather than passing — which is the first thing it had to get right, because the engine repo is where a CI row would plausibly call it.

The arms, and why they are the best I have seen

  ok   a padded fixture beside the guard passes
  ok   a fixture that pads nothing is a FAILURE naming the fixture
  ok   a matcher that kept the key guard and dropped the value one is a FAILURE
  ok   a matcher without the storage guard is a FAILURE naming the matcher
  ok   no expectation at all is vacuous, not a failure
  ok   a third *hrx* suite is a FAILURE naming the file, not a silent pass
  ok   an exemption that no longer names the kernel is a FAILURE
  ok   the three pinned suites plus the two listed LoomJIT files are clean
  ok   the fallback row sits exactly one 64-block past the cap
  ok   a fallback row at or below the cap is a FAILURE naming the row
  ok   a cap that moved under the row is a FAILURE naming the new boundary
  ok   a row whose name disagrees with the case it calls is a FAILURE
  ok   a suite with no fallback row is a FAILURE, not a vacuous pass
  ok   a tree without the cap constant is cannot-tell, not a pass
  ok   a missing test file is cannot-tell
  ok   an expectation with no readable matcher is cannot-tell, not a pass

Four of these are checks I would not have thought to write:

  • kept the key guard and dropped the value one — #2494's guard has two halves and dropping one is the failure that took three MODE2 resets; an arm that only tested "the guard is present" would pass a matcher with half of it.
  • a row whose name disagrees with the case it calls — that is #2870's other half: the row name and the shape it runs drifted apart, and the failure was read as a missing kernel.
  • vacuous, not a failure vs a suite with no fallback row is a FAILURE — two different situations that both look like "nothing to check", and the tool distinguishes an empty expectation list (fine) from a missing fallback row (not fine).
  • a cap that moved under the row — the invariant is a relationship, and this arm pins the other side of it: moving the constant is as much a failure as moving the row.

And a tree without the cap constant is cannot-tell, not a pass is the one that makes the whole thing usable across repos: the engine tree has no such constant, and a check that treated that as success would be green everywhere and useful nowhere.

Why this matters for #2870

That issue's rows abort with missing expected kernel, and every review of them has had to reason by hand about where the cap is, whether the fixture pads, and whether the guard has both halves. This turns all of it into a static check with 16 arms — and it needs no device, which is the part that has blocked #2870 all night.

What I could not test

A mutation of the real tree — I started one (copying tests/ and ggml/ aside to move a row below the cap) and stopped: the arms already construct each failure from a fixture, and a mutation of the real 7 000-line file would be testing git rather than the tool. What I verified is that it runs clean on the tree it targets, refuses to answer on a tree that lacks the suite, and that each of the 16 failure modes has an arm.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 0a5ee0e: CHANGES

Content looks right — the fallback row moved one 64-block past the cap it is testing, which is what makes the fallback the kernel under test rather than the split one — but the branch is stale and the tool says so in its own terms:

#3102 npuperf-3085-fallback-cap: BEHIND 2; merging it removes 4 line(s) main still carries in 1 file(s)

Two commits behind, four lines, in the same file #3089/#3098/#3094 have all been editing (tools/ci/fa_split_expectation_check.py shares nothing with those, but the point stands: this branch was cut before today's queue moved). Rebase and I will re-verdict at the new head; the hunk to watch is the row's key_value_token_count arithmetic, since a conflict resolved by taking either side can move the row back onto the cap it is supposed to sit past.

One thing I could not do from here and would want before calling it READY: run the check against the pinned fork. This tool's verdict depends on the fork's fixture text (PADDED/SPLIT patterns in tests/test-hrx-ops.cpp), and a rebase can leave the file consistent while the fixture moved underneath it. The self-test covers the tool; only --check --root <fork> covers the claim.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 1270075b: READY — the premise checks out against the pinned fork, and I drove all three ways the row can stop pinning the fallback.

The arithmetic, verified against the fork in this tree (third_party/llama.cpp, dispatch-flash-attention.cpp):

:65   kDecodeSplitMaxKeyValueTokenCapacity = 2944          // 46 * 64
:382  key_value_capacity = ceil_div(token_count, kDecodeKvTileSize) * kDecodeKvTileSize;
:383  if (key_value_capacity > kDecodeSplitMaxKeyValueTokenCapacity) { … }        // the general fallback

so 3008 = 47 × 64 is the smallest multiple above the cap, and the row that proves the fallback is reachable must be exactly that. The row is where the PR says it is (tests/test-hrx-ops.cpp:6841, run_qwen_decode_split_flash_attention_scheduling_case(1, 3008)).

Three mutations, each caught — and the third is the one a reviewer would not think of. I copied the fork's two files into a scratch root (so the real tree is untouched) and ran --check:

pristine                              → rc=0  "every decode-split expectation has the padded fixture and the storage guard"
row moved to the cap (3008 → 2944)    → rc=1  "… is kv=2944, at or below the split cap 2944: it selects the split kernel, so NO row pins the general fallback"
row moved past the boundary (→ 3072)  → rc=1  "… is kv=3072; the smallest 64-multiple past the cap 2944 is 3008 -- move the row (or the cap moved under it)"
cap moved to 4096, row left at 3008   → rc=1  "… is kv=3008, at or below the split cap 4096: … NO row pins the general fallback"

That third case is the whole point of the check: a cap move silently turns the fallback row into an ordinary split row that still passes, and the message says which of the three situations it is (at-or-below the cap, one block from the boundary, or further out) instead of "the fixture looks wrong".

--self-test exits 0, including its two cannot-tell arms (a missing test file is cannot-tell, an expectation with no readable matcher is cannot-tell, not a pass) — and --check --root third_party/llama.cpp on the real fork returns rc=0, so it passes on the tree this box actually pins.

One operational note, not about the code: --check --root . from the engine root answers cannot tell: no tests/hrx-ops-test.cpp (and no tests/test-hrx-ops.cpp …, because TEST_PATHS are relative to the fork root. That is correct behaviour (cannot-tell, not a pass) but the invocation is easy to get wrong; a line in the module docstring saying "run with --root third_party/llama.cpp" would save the next person the minute I just spent.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT at 0a5ee0e: READY

I ran it against the real fork tree and then moved the cap by one 64-block: rc 1, naming the lost property. That is the failure mode the row exists to prevent, caught before it happens.

$ # at pin 84ab5dae8 (the fork's 1bit/hrx-vulkan-patched)
$ grep kDecodeSplitMaxKeyValueTokenCapacity = …dispatch-flash-attention.cpp:65   → 2944   (= 46 × 64)
$ grep '"fa_decode_split.1.3008"' tests/test-hrx-ops.cpp:6873                     → 3008   (= 47 × 64)
$ python3 fa_split_expectation_check.py --check --root <fork>    → rc 0, "every decode-split expectation has the padded fixture and the storage guard"

$ # mutant: cap 2944 → 3008  (one 64-block, exactly the edit that silently disarms the row)
$ python3 fa_split_expectation_check.py --check --root <fork>    → rc 1
  fallback: the largest fa_decode_split row is kv=3008, at or below the split cap 3008: it selects the split
  kernel, so NO row pins the general fallback (engine#3085)

Why this check is the right shape

"fa_decode_split.1.3008 exists to be the SMALLEST 64-token multiple past the decode-split cap, and it asserts the general kernel -- i.e. it is the only row that proves the fallback is reachable. Its premise is a join of the row's literal and the cap inside the matcher… so a cap move turns it into an ordinary split row that still passes, and nothing pins the fallback any more."

The row's purpose lives in a relation between two files' literals. Nothing in the test suite can express that relation, because each side is locally consistent: the row still passes, the cap is still a valid cap. So the check reads both literals and asserts the join — which is the "verify the input, not just the mechanism" rule applied to a test's premise rather than its behaviour.

And the message names the consequence rather than the mismatch: "it selects the split kernel, so NO row pins the general fallback". A lane reading that knows what was lost, not just which number moved.

The three verdicts are all cannot-tell-aware

The self-test's 16 arms include "a missing test file is cannot-tell" and "an expectation with no readable matcher is cannot-tell, not a pass", and running it against the engine root produced exactly that:

fa-split-expectation: cannot tell: no /…/tests/hrx-ops-test.cpp (and no tests/test-hrx-ops.cpp (and no …hrx-backend-test.cpp

So a checkout without the fork tree does not read as clean — which matters because the engine repo is where CI will run it and the fork is a submodule: the common misconfiguration is "run it in the wrong tree", and it says so instead of passing.

Two notes, neither blocking

  1. The cap is parsed with (\d+) and the row with a literal-shape regex ("fa_decode_split\.(\d+)\.(\d+)" plus the scheduling call's two numbers). A future row written via a different helper (e.g. a case-table entry) would not be seen — the check would report "no expectation found" and, if that is a cannot-tell, it stays honest; if it becomes a pass, the guarantee evaporates. Worth an arm for "the row moved to another spelling" so the answer is cannot-tell rather than silent.
  2. It belongs in pre-pr-checks.sh alongside the other device-free rows: its whole value is running on a machine with no GPU, and the cap/row pair is exactly what a pin bump can silently break — which is the PR type that lands most often in this repo.

Duplicate check

Nothing else open covers engine#3085, and the four FA rows it protects are the same family as #2870's thirteen — worth a line in that issue so its owner knows one of the four now has a pin on its premise.

@bong-water-water-bong
bong-water-water-bong merged commit 5affed1 into main Nov 21, 2026
10 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the npuperf-3085-fallback-cap branch November 21, 2026 02:18
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 0a5ee0e: READY — the new fallback check has all five postures as arms, and it fires on the real fork

I ran it both ways: against a llama.cpp checkout (where it can measure) and against an engine-only tree (where it must not pretend).

$ python3 tools/ci/fa_split_expectation_check.py --check --root <llama.cpp checkout> ; echo rc=$?
  fallback: the largest fa_decode_split row is kv=513, at or below the split cap 32768: it selects the split kernel,
            so NO row pins the general fallback (engine#3085)
rc=1                                        ← a gate, not a note

# main's version on the same checkout
rc=1   … matcher: … (and a stale `tests/hrx-ops-test.cpp` path that does not exist)

# an engine-only tree: no checkout to read
$ python3 tools/ci/fa_split_expectation_check.py --check
fa-split-expectation: cannot tell: no /tmp/…/ggml/src/ggml-hrx/dispatch_registration/common/dispatch-flash-attention.cpp
                                (a suite expects the split kernel, so the matcher has to be readable)       rc=2

The arms are the right five, and they are what makes this a check rather than a message:

ok   the fallback row sits exactly one 64-block past the cap
ok   a fallback row at or below the cap is a FAILURE naming the row
ok   a cap that moved under the row is a FAILURE naming the new boundary
ok   a suite with no fallback row is a FAILURE, not a vacuous pass
ok   a tree without the cap constant is cannot-tell, not a pass

The third one is the one I would have asked for: the cap has moved between pins — the docstring measures cap 2944 = 46*64 → 3008 is the boundary at 5abb405c7, and the checkout I ran against reports 32768, i.e. a different pin entirely. A check that hard-coded 2944 would be silently wrong on today's pin; this one reads it out of the matcher and fails naming the new boundary. The fourth ("no row is a FAILURE, not a vacuous pass") is the posture #3085 needs, since the whole defect is a suite that pins four rows and none of them the fallback.

Also worth keeping: a malformed fixture of mine — a row whose name says 32832 while its case still calls (4, 513) — was caught by a different arm, the row's NAME disagrees with the case it calls (4, 513), so neither can be trusted. That is a join this file now enforces at two levels (name↔case, row↔cap), which is exactly the shape #3085 describes.

Nothing to change. One merge note: it needs --root pointing at a llama.cpp checkout, so in CI it only runs where such a tree exists — the cannot tell above is the honest answer elsewhere, and it names the missing file rather than passing quietly.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

First real exercise of the row: the pin moved under it an hour after this PR opened, and it holds. main is now 4d2933b8 (llama.cpp 5abb405c7752 → 84ab5dae8ed2, #3101) — the bump that carries the per-name dispatch count and #459's scheduled-kernel message. Re-ran against the new submodule rather than assuming:

$ git submodule update --init third_party/llama.cpp
$ python3 tools/ci/fa_split_expectation_check.py --check --root third_party/llama.cpp ; echo rc=$?
fa-split-expectation: every decode-split expectation has the padded fixture and the storage guard
rc=0

kDecodeSplitMaxKeyValueTokenCapacity is still 2944 at 84ab5dae8 (dispatch-flash-attention.cpp:65) and the fallback row is still fa_decode_split.1.3008 = 47 × 64, so the join the check pins is unchanged — which is the answer this row exists to give at every bump, now given once.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY -- the arm set is better than the one I would have specified, and the check is derived rather than pinned

The rule is the right one: the fallback row must sit at (cap // 64 + 1) * 64, i.e. the smallest 64-multiple past the split cap, because that is the only band where the general matcher accepts the padded storage and the split matcher declines -- which is exactly what fa_decode_split.1.3008 is for. Crucially it is read from kDecodeSplitMaxKeyValueTokenCapacity in the dispatcher, not hardcoded, so a cap move is caught rather than silently making the row meaningless.

The arms are the part worth calling out, because they cover the cases that make a check like this rot. Six of them for this one rule:

  • the row sits exactly one 64-block past the cap (positive);
  • a cap that moved under the row is a FAILURE naming the new boundary -- this is the arm that makes the check derived, and it is the one I would have asked for last;
  • a row at or below the cap fails, naming the row;
  • a row whose name disagrees with the case it calls fails;
  • a suite with no fallback row is a failure, not a vacuous pass;
  • a tree without the cap constant is cannot-tell, not a pass.

Proof the arms bite, mutation verified to have applied ((cap // 64 + 1) * 64 -> (cap // 64) * 64):

FAIL a padded fixture beside the guard passes
     [[('fallback', 'the largest fa_decode_split row is kv=3008; the smallest 64-multiple past the cap 2944 is 2944
        -- move the row (or the cap moved under it)')]]

The message names the boundary and the possibility that the cap moved -- which is the sentence someone will need at 3 a.m.

One note on reading this diff: against origin/main two-dot it shows other lanes' merged work as additions; the PR's actual change is the three-dot view, one file, +94/-5. Not a defect, just the shape a branch cut for one file has an hour into a busy night.

Nothing to change.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3085 - Partially compliant

Compliant requirements:

  • The PR addresses the core issue of the fallback row being incorrectly positioned relative to the cap
  • The PR adds a check to ensure the fallback row sits exactly one 64-block past the cap
  • The PR verifies the cap value (2944) is correctly measured on the hardware
  • The PR ensures that the fallback row's premise is correctly validated

Non-compliant requirements:

  • The PR does not explicitly mention updating documentation or README files

Requires further human verification:

  • Verification that the hardware-specific measurements (2944 = 46 × 64) are accurate on the AMD Strix Halo's XDNA 2 NPU
  • Confirmation that the fix does not introduce regressions in other parts of the system
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect fallback row positioning

The fallback row fa_decode_split.1.3008 was incorrectly positioned relative to the decode-split cap, causing it to select the split kernel instead of the general fallback kernel. The check now ensures that the fallback row sits exactly one 64-block past the cap to maintain the intended behavior.

smallest_past_cap = (cap // 64 + 1) * 64
if biggest <= cap:
    failures.append(("fallback", f"the largest fa_decode_split row is kv={biggest}, at or below the split cap {cap}: "
                                  f"it selects the split kernel, so NO row pins the general fallback (engine#3085)"))
elif biggest != smallest_past_cap:
    failures.append(("fallback", f"the largest fa_decode_split row is kv={biggest}; the smallest 64-multiple past "
                                  f"the cap {cap} is {smallest_past_cap} -- move the row (or the cap moved under it)"))
return failures, None
Cap value verification

The PR verifies that the cap value is correctly measured on the hardware (2944 = 46 × 64) and ensures that the fallback row's premise is validated against this value. This prevents the row from being incorrectly positioned if the cap moves.

CAP_RE = re.compile(r"kDecodeSplitMaxKeyValueTokenCapacity\s*=\s*(\d+)")
ROW_RE = re.compile(r'"fa_decode_split\.(\d+)\.(\d+)"\s*,\s*\[=\]\s*\{\s*'
                    r"run_qwen_decode_split_flash_attention_scheduling_case\((\d+)\s*,\s*(\d+)\s*\)")


def fallback_cap(root: Path):
    """(failures, cannot_tell) for the row that must sit exactly one 64-block past the split cap."""
    try:
        cap_text = _flat((root / DISPATCH_PATH).read_text(encoding="utf-8", errors="replace"))
    except OSError:
        return [], f"no {root / DISPATCH_PATH} (the fallback row's premise is the cap in that file)"
    cap_match = CAP_RE.search(cap_text)
    if cap_match is None:
        return [], f"no kDecodeSplitMaxKeyValueTokenCapacity in {DISPATCH_PATH} (the cap moved or was renamed)"
    cap = int(cap_match.group(1))

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant