Repository navigation
fa_split_expectation_check: the fallback row must sit one 64-block past the cap it is testing (engine#3085) - #3102
Conversation
…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.
|
Registered and green in a real configure, not only by hand:
|
|
Stale-base measurement on The 4 lines, and why this one is not a revert of #3008 — I checked the overlap instead of stopping at the count. Every
A rebase onto |
|
VERDICT: READY "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:
On the shape: |
|
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 shapeCAP_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:
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. 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 rowThe diff is One line in What I checkedThe |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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:
- 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 tellfor 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); (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
left a comment
There was a problem hiding this comment.
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.3008exists 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
left a comment
There was a problem hiding this comment.
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 failurevsa 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
left a comment
There was a problem hiding this comment.
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.
|
VERDICT at The arithmetic, verified against the fork in this tree ( 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 ( 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 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".
One operational note, not about the code: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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.3008exists 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
- 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 iscannot-tellrather than silent. - It belongs in
pre-pr-checks.shalongside 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.
VERDICT at
|
|
First real exercise of the row: the pin moved under it an hour after this PR opened, and it holds.
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.pyalready 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.3008is that row, and its premise is a join of two files:2944 = 46 × 64, so3008 = 47 × 64is 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
kDecodeSplitMaxKeyValueTokenCapacityis 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).--check --root third_party/llama.cppon 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.