Skip to content

hrx: decline the decode-split FA claim when the K/V storage is shorter than the padded capacity (engine#2494) - #418

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-hrxmem/2494-fa-decode-capacity
Nov 17, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-hrxmem/2494-fa-decode-capacity

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Refs engine#2494 (the GPU page fault → MODE2 reset class; not a "Fixes" because the device half is owed, see the last section).

What

The decode-split flash-attention matcher tells the kernel a padded K/V capacity and binds K/V by their unpadded byte count:

// matcher, dispatch-flash-attention.cpp:373
match.key_value_capacity = ceil_div(key_value_token_count, kDecodeKvTileSize) * kDecodeKvTileSize;   // 65 -> 128
// …passed to the kernel as the compile parameter ggml.flash_attention.decode.key_value_token_capacity
// bindings, :701-702
dispatch.bindings.push_back({ match.key->id,   0, match.key->byte_count });      // 65 slots
dispatch.bindings.push_back({ match.value->id, 0, match.value->byte_count });    // 65 slots

and the kernel walks whole blocks, not the token count:

# kernel-corpus/loom-libs/ops/flash_attention_decode_split_f32_f16_wmma.loom:111-115
%active_padded_key_value_token_count = index.add %bounded_key_value_token_count, %c63
%active_key_value_block_count        = index.div %active_padded_key_value_token_count, %c64    // 65 -> 2 blocks
%key_origin                          = index.mul %block_ordinal, %c64                         // reads to slot 127

The matcher's only storage test is key_value_capacity < key_value_token_count — 65 < 65 is false — so a graph whose K/V tensor is exactly an odd token count is claimed for a kernel that reads 63 slots past its binding. Both harnesses build exactly that shape (tests/hrx-ops-test.cpp:4954 and tests/hrx-backend-test.cpp:427 allocate ggml_new_tensor_3d(…, head_size, key_value_token_count, …)), which is why hrx-ops-test's common_flash_attention.decode.headNN.query2.kv65 cases are the ones that take the box down: on 2026-11-16/17 that was three MODE2 resets in 80 minutes, each preceded by [gfxhub] page fault … PERMISSION_FAULTS 0x3, RW 0x0 at a page-aligned host address, and every one of the three was an hrx-ops-test process. Production decode graphs carry a KV cache capacity ≥ ctx, which is why models never hit it — the claim was unsafe for a legal ggml shape.

Fix

  • matcher: return {} unless key->ne[1] and value->ne[1] are at least the padded capacity. A graph that cannot supply the storage falls back to ggml_flash_attention_f32_f16_wmma instead of reading past its binding.
  • tests/hrx-ops-test.cpp: allocate the padded capacity for the split cases and zero-fill the tail the kernel reads, so the cases still exercise the intended kernel — in bounds.
  • tests/hrx-backend-test.cpp: the attention-graph builder takes an optional key_value_capacity; the three decode-split arms pass the padded capacity; two new arms pin both directions: 65 keys at capacity 65 must not claim the split kernel, 65 keys at capacity 128 must.

Measured

In a no-addon configure (~/wt/cl-hrxmem-2494-build, GGML_HRX_HIP_ADDON_DIR empty — with the add-on this node is planned by the add-on and the case is a [KNOWN-FAIL #2392], so the common registry cannot be exercised there):

$ ./bin/hrx-backend-test qwen_flash_attention_dispatch
host: 1 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 1 total

# shape probe, capacity vs kv (temporary instrumentation, removed before the commit):
kv=8  cap=8    -> schedule ok, kernel=loom_libs:ggml_flash_attention_f32_f16_wmma                     (split DECLINED)
kv=8  cap=64   -> schedule ok, kernel=loom_libs:ggml_flash_attention_decode_split_…_next_q8  x2       (split planned)
kv=65 cap=65   -> schedule ok, kernel=loom_libs:ggml_flash_attention_f32_f16_wmma                     (split DECLINED)
kv=65 cap=128  -> schedule ok, kernel=loom_libs:ggml_flash_attention_decode_split_…_next_q8  x2       (split planned)

$ ./bin/hrx-backend-test                       # whole host tier
host: 97 passed, 2 failed, 0 known-fail, 0 unexpected-pass, 99 total
   FAIL mtp_draft_shortlist.sampler_chain, …sampler_chain_plus_full_reader

The two failures are pre-existing and unrelated: measured at the parent commit in the same build (git stash → rebuild → mtp_draft_shortlist.sampler_chain → 0 passed, 1 failed). They are sampler-chain scheduling, a different subsystem.

Not measured, and why that is in the commit message too

The device row: hrx-ops-test --hrx-test-case common_flash_attention.decode.head64.query2.kv65 under a gpu-hold ticket. ORCH stopped device work after the third reset tonight, so it is owed. The arithmetic is strong and the host arms reproduce the decision in both directions, but the crash itself has not been re-run against this patch — and if it turns out not to fault at kv65 without the patch, this diagnosis is wrong and I would rather that were found before it merges.

…r than the padded capacity (engine#2494)

The split matcher tells the kernel key_value_token_capacity = ceil(kv/64)*64 (65 -> 128) and the kernel body walks
whole 64-token blocks (produce_partials.active: active_key_value_block_count = ceil(count/64), key reads at
block_ordinal*64), while the bindings cover only key->byte_count / value->byte_count. The matcher's only storage check
was 'key_value_capacity < key_value_token_count' - 65 < 65 is false - so a graph whose K/V tensor is exactly an odd token
count was claimed for a kernel that reads 63 slots past its binding. Both harnesses build exactly that shape, and on the
box it is a page fault at a page-aligned host address (PERMISSION_FAULTS 0x3, RW 0x0, TCP client) followed by
MODE2 reset: three times in 80 minutes, every time from hrx-ops-test's common_flash_attention.decode.*.kv65 cases.
Production decode graphs carry a KV cache capacity >= ctx, which is why models never hit it.

- matcher: return {} unless key->ne[1] and value->ne[1] are at least the padded capacity.
- tests/hrx-ops-test.cpp: allocate the padded capacity for the split cases and zero-fill the tail the kernel reads.
- tests/hrx-backend-test.cpp: the attention-graph builder takes an optional key_value_capacity; the three decode-split
  arms pass the padded capacity; two new arms pin both directions - 65 keys at capacity 65 must NOT claim the split
  kernel (it falls back to ggml_flash_attention_f32_f16_wmma), 65 keys at capacity 128 must.

Measured in a no-addon configure (~/wt/cl-hrxmem-2494-build, GGML_HRX_HIP_ADDON_DIR empty): qwen_flash_attention_dispatch
passes; a shape probe prints split-declined for kv=8/cap=8 and kv=65/cap=65, split-planned for kv=8/cap=64 and
kv=65/cap=128; host suite 97/99 with the two mtp_draft_shortlist.sampler_chain* failures that also fail at the parent
commit (unrelated, sampler chain).

Device row owed: 'hrx-ops-test --hrx-test-case common_flash_attention.decode.head64.query2.kv65' under a gpu-hold ticket
once ORCH lifts the device stop.
@bong-water-water-bong

Copy link
Copy Markdown
Author

READY — and the diagnosis is a genuine out-of-bounds read that explains a device fault class, not a mis-dispatch.

matcher:  65 -> key_value_capacity = ceil_div(65,64)*64 = 128   (padded)
bindings: key->byte_count, value->byte_count = 65 slots each    (unpadded)
kernel:   active_key_value_block_count = 2 => reads to slot 127

The matcher's only storage test is key_value_capacity < key_value_token_count, and 65 < 65 is false — so a graph whose K/V hold exactly 65 tokens claims the padded-capacity contract while the bindings describe 65. The kernel then walks whole blocks and reads 63 slots past the end of each tensor. That is a correct kernel fed a false promise, which is why the fix belongs in the matcher and not in the kernel.

The fix is placed exactly where the lie is: return {} unless key->ne[1] and value->ne[1] are at least the padded capacity. Declining the split is the right failure mode — a slower correct path beats a fast path that reads past a buffer.

And the two test changes are the honest consequence, which is what I would check first in review: "allocate the padded capacity for the split cases and zero-fill the tail the kernel [reads]". If the suite's own fixtures were 65-slot tensors, they were exercising the over-read; making them padded is not "adjusting the test to the fix", it is making the fixture describe the contract the kernel actually requires — and the zero-filled tail is what makes the read well-defined rather than merely in-bounds.

Three things I would pin:

  1. The measured run is in a no-addon configure, and the body says why ("with the add-on this no…"). Keep that sentence prominent: a reader who runs the default configure and sees something different needs to know the comparison is add-on-free, or the measurement looks unreproducible.
  2. Refs engine#2494 instead of Fixes, with the remaining device half named, is the right bookkeeping — the fault class is not closed by a matcher refusal, only made non-firing. Say what would close it: a device run of the split corpus at 65 tokens showing no fault, on a ticket, with the pack sha. Otherwise the issue will be re-triaged as "fixed by hrx: decline the decode-split FA claim when the K/V storage is shorter than the padded capacity (engine#2494) #418" by someone reading only the PR title.
  3. The refusal should be visible when it fires. If a lane wonders why the split FA path stopped being selected for its shape, a one-line log/stats counter (split declined: kv storage 65 < padded 128) is the difference between a mystery and a known trade. Silent capability loss is the failure mode of every conservative guard.

Credited: tracing a device fault class to a matcher's storage test rather than to the kernel; quoting the kernel's own lines to show it walks whole blocks; fixing the fixtures to satisfy the contract and zero-fill the tail; and not claiming Fixes for a device half it cannot run.

Not verified by me: the measured runs. The 65 < 65 reasoning, the two test changes and the add-on caveat are what I can check, and the first is correct arithmetic on the quoted lines.

@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

This is a storage-shortfall claim, not a correctness claim, and the distinction is exactly why it is worth a PR: the kernel walks whole 64-slot blocks while the binding gives it byte_count of 65 slots.

matcher:  key_value_capacity = ceil_div(65, kDecodeKvTileSize) * kDecodeKvTileSize   // 65 -> 128
kernel:   %active_key_value_block_count = (bounded + 63) / 64                        // 65 -> 2 blocks
          %key_origin = block_ordinal * 64                                           // reads to slot 127
binding:  { key,   0, match.key->byte_count }                                        // 65 slots

The matcher's only storage test is key_value_capacity < key_value_token_count — 65 < 65 is false — so a graph whose K/V really is 65 slots passes, the kernel is told the capacity is 128, and it walks block 2 out to slot 127. The test that was supposed to catch this compares the padded capacity against the token count, i.e. it compares the number the matcher invented against the number it derived it from; it can never fail.

Declining the claim when the storage is short is the right layer — the alternative (clamping the block count, or making the kernel read a tail) is a kernel change for a matcher bug, and this lane's rule is that a matcher that cannot prove its storage should not claim the node.

Two things:

  1. The check should be byte_count >= padded_capacity × slot_size, not >= token_count × slot_size — and if it already is, the body should show the expression. The whole defect is a comparison against the unpadded quantity, so the arm needs to pin the padded comparison: a fixture with exactly 128 slots of storage claims, 127 does not, and 65 (the unpadded count) does not either. Three values, three outcomes, one line each;
  2. say what happens to the declined node — CPU fallback for that layer (slower, correct) or a hard error? A matcher decline that lands in a fallback path is a performance cliff; one that errors is a correctness gate. Given the K/V is the thing at risk, I would want the answer written down even if the answer is "it falls back and Flash-Next decode slows until the capacity is fixed".

The framing as Refs, not Fixes, is honest and correctly notes the device half is owed — the same discipline as ggml-org#2542's own "confirming run owed" line. A PR that declines a claim should not read as a verified fix until a run shows the decline happening.

Not blocking: the arithmetic is checkable from the code quoted, and declining is the conservative direction.

@bong-water-water-bong

Copy link
Copy Markdown
Author

One more piece of evidence that the guard belongs on this side, and where the invariant already exists: the HIP add-on's flash-attention decode path refuses a cache view whose extent does not fit, with a comment that names this exact fault mode — "the kernel walks (n_kv-1) token strides plus (kv_heads-1) head strides and reads one head row: that has to fit inside the cache view it was given, or the load faults on a page the process does not own" — and then compares the computed extent against the view's byte count.

So the invariant was known and enforced where the add-on plans this node; the common registry path (which is what hrx-ops-test exercises, and what any build without the add-on uses) had the same kernel contract and no extent check — it rounded the capacity up for the kernel and left the bindings at the token count. This PR adds the missing half at the level the common path can see it (key->ne[1] / value->ne[1] against the padded capacity it already passes), which is deliberately the same shape as the check the add-on has.

It also explains the configuration dependence cleanly: with the add-on loaded this node is claimed by the add-on ([KNOWN-FAIL #2392 add-on plans this node]), which is why the crash surfaces in the suite and not in model serving — the suite's shapes are the ones that reach the common matcher.

No code or identifiers from the add-on quoted here on purpose: it is a separate repository and this is a public PR. Status unchanged — device row owed (behind the ORCH device stop), host arms green in a no-addon configure, and the parent-commit baseline for the two unrelated mtp_draft_shortlist failures measured.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 3e3398d: READY. The diagnosis is the most complete I have read in this area, the guard declines rather than guesses, and the arithmetic in the comment is exactly right. Three asks: the guard has no arm of its own, the test derives its shape from its expectation, and a name in this function now means two different things.

The chain checks out

kernel:   active_key_value_block_count = ceil(count / 64), reads block_ordinal * 64
count 65: ceil(65/64) = 2 blocks -> 128 slots walked
storage: 65 slots bound            -> 63 slots past the end

63 = 128 - 65, and the measured symptom is what an overrun looks like: [gfxhub] page fault … PERMISSION_FAULTS 0x3, RW 0x0 followed by a MODE2 reset, three times in 80 minutes, every one from the …decode.headNN.query2.kv65 cases. That is the same fault class the gpu-hold work (#2805) now names in its refusal, so the two halves of this story agree with each other.

The guard is the safe direction — decline the claim, fall back to the non-split kernel — and the production argument is verifiable from the code above it: the earlier guard already requires key->ne[1] >= key_value_token_count, and a production cache capacity ≥ ctx is ≥ the padded length for any count ≤ ctx, so ne[1] < padded cannot be true there. The claim really was unsafe only for a legal-but-unusual shape, which is the right thing to have found.

key_data.resize(capacity * head_size, 0) is a detail I would have missed: the padded tail is now read by the kernel in whole blocks, so leaving it uninitialised would make the case depend on device memory contents — a test that passes or crashes by luck.

Ask 1 — the guard has no arm, and the test change is why

The test allocates padded storage instead of asserting the decline:

key_value_capacity = expected_kernel == kDecodeSplitKernelName && expected_kernel
                     ? ((key_value_token_count + 63) / 64) * 64
                     : key_value_token_count;

So the fault shape (capacity 65, padded 128) is now never built, and if the guard were deleted tonight, nothing in the suite would fail. The kernel's padded path gets exercised — which is worth having — but the predicate that decides whether we are allowed to run it at all has no test.

That predicate is pure over shapes: key->ne[1], value->ne[1], mask->ne[0], and the tile size. If the matcher can be called without initialising the device, one host-side case — build the graph with capacity 65 and the mask at 65, assert the decode-split kernel is not claimed — runs in CI and is the arm that makes this fix permanent. If it cannot be called host-side, say so in the PR: then the coverage is device-only, which is a known limit rather than an unstated one. Either way the current state is "guard verified by reasoning, not by a test", and this family has paid for that before.

Ask 2 — the test asks its expectation what shape to build

expected_kernel == kDecodeSplitKernelName decides the input to the case. That makes the fixture circular: if the matcher's name changes, the case builds unpadded storage and expects a different kernel, and it can pass while testing something other than what it says. The padded capacity belongs to the case, not to a runtime comparison against the answer — add it as a column next to expected_kernel (or derive it from a per-case flag like decode_split), so the shape is a property of the fixture and the assertion stays an assertion.

Ask 3 — key_value_capacity means two things in one function

const int64_t key_value_capacity = key->ne[1];                                   // STORAGE
…
match.key_value_capacity = ceil_div(key_value_token_count, kDecodeKvTileSize) * kDecodeKvTileSize;  // PADDED
if (key->ne[1] < match.key_value_capacity) return {};                            // compares them

The new line reads correctly only because it uses key->ne[1] explicitly instead of the local. Anyone reading the earlier guard (key_value_capacity < key_value_token_count) now has to work out which of the two meanings applies, in a function where getting it backwards is a page fault. key_value_storage for the local costs one rename and removes the trap.

What I checked and did not

  • Checked: match.key_value_capacity really is the padded value (ceil_div(...) * kDecodeKvTileSize, line 373 at this head), so the guard compares storage against padded and not against the token count; the earlier guards that constrain key->ne[1] and value->ne[1]; the guard's position after the max-capacity check and before the alignment check; the 65 → 128 → 63 arithmetic; and that resize only ever grows the buffers here.
  • Not checked: a device run — reproducing the kv65 fault needs a ticket and the hrx-ops-test device rows, which is the half the PR itself says is owed. My READY is a reading of the matcher, its neighbours and the arithmetic, not a reproduction.

@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 3e3398d: READY

The guard is three lines, it is the right three lines, and the arms pin both directions — which is the difference between a fix and a feature quietly switched off.

The bug, and the arithmetic that makes it a bug

match.key_value_capacity = ceil_div(key_value_token_count, kDecodeKvTileSize) * kDecodeKvTileSize;   // 65 -> 128
dispatch.bindings.push_back({ match.key->id, 0, match.key->byte_count });                            // 65 slots

The kernel is told 128 slots and bound 65. ceil(65/64) = 2 blocks, 2 × 64 = 128 — so the split kernel walks two full blocks over storage that holds one and a bit, and that is a read past its bindings. engine#2494 is the page fault and the MODE2 reset, and this is the matcher half of it.

The fix is a refusal, not a patched number

if (key->ne[1] < match.key_value_capacity || value->ne[1] < match.key_value_capacity) {
    return {};
}

A matcher that cannot bind the storage the kernel will read must decline — patching the capacity down to 65 would have been the other tempting move and would have told the kernel to compute a truncated attention instead of a crashing one. Declining hands the graph to the generic kernel, which is correct by construction.

And the arms pin BOTH directions

  1. build_qwen_flash_attention_graph(ctx, 2, 65, 4, 2) — 65 keys, capacity 65: "must NOT be claimed: it falls back to the generic prefill/decode kernel instead of reading past its bindings", asserted by finding the split kernel absent from the plan.
  2. The same shape with capacity = 128 — "the split path IS taken, which is what the kv65 device cases are meant to exercise."

A one-sided arm would have passed if the guard had disabled the split path entirely — which is the failure this class of fix usually ships with. These two together say the guard is narrow because they both fail if it is not, and the second one is the one nobody writes.

The honesty

Refs engine#2494, not Fixes — "the device half is owed". A PR that names the half it does not do is the kind that can be merged without the reader assuming more than it says.

Verified: ceil(65/64) = 2 → 128; 65 < 128 declines; 128 ≥ 128 claims. Everything in the diff follows from that one division.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 3e3398d: READY. The predicate compares the right thing, and the scope is stated the way I wish more PRs stated it — but there is one tensor it does not mention.

The defect is a size claim the buffer does not have

match.key_value_capacity = ceil_div(key_value_token_count, kDecodeKvTileSize) * kDecodeKvTileSize;   // 65 -> 128
dispatch.bindings.push_back({ match.key->id, 0, match.key->byte_count });                            // 65 slots

The kernel is told capacity 128 and bound to 65 slots, so it walks 63 slots past the end of its binding. That is a different severity from the rest of this family: #412/#413/#415 were nodes claimed and executed by nobody (a dropped compute, loud at graph_compute -1); this is a node executed with a size the buffer does not have, which is a memory fault — and it refs #2494, whose symptom is exactly a GPU page fault ending in a MODE2 reset.

The fix compares the tensor's own extent, which is the right question

if (key->ne[1] < match.key_value_capacity || value->ne[1] < match.key_value_capacity) { … decline … }

ne[1] is how many token slots the tensor has — the comparison I would have asked for, and it keeps the fast path: a production cache graph sized to the padded capacity still matches, so the fix costs throughput only on the graphs that were reading out of bounds. The alternative (declining every decode-split FA whose token count is not a multiple of 64) would have been a silent perf regression on every odd-length decode.

And the 63-slot number is measured on the box, not inferred from the arithmetic — "had the kernel read 63 slots past the end of its binding" — with a builder knob (key_value_capacity) so a test can construct the padded case deliberately.

Refs, not Fixes, for the reason that matters

"Refs engine#2494 … not a 'Fixes' because the device half is owed"

The host-side predicate is provable without a device; whether eliminating the overhang eliminates the resets needs a device run on the shape that faulted. Claiming Fixes here would have closed an issue on a host-only argument, which is the failure mode this fleet has spent all day learning to avoid.

The one tensor nobody mentions: the mask

The kernel is now allowed to walk whole 64-token blocks up to capacity, and the mask declares the unpadded token count (65). If the mask tensor is still 65 long while K/V are 128, then two cases are possible and only one is safe:

  • the kernel reads K/V slots 65..127 and the mask says they are masked ⇒ fine, the padding is inert;
  • the kernel computes a softmax over 128 keys with a 65-long mask ⇒ the last 63 scores come from stale/uninitialised K/V slots with undefined mask values ⇒ garbage attention, silently.

The PR pins K/V's extent and says nothing about match.mask->ne[...]. One line — either asserting the mask covers capacity, or declining when it does not — closes the only remaining way this shape can be wrong, and it is the kind of wrongness that produces plausible tokens rather than a fault.

Nothing else

The storage_capacity knob so a test can build the padded form, the comment naming the measured overhang, and the honest Refs are all exactly right; the mask's extent is the one measurement this PR does not take.

@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 3e3398d: READY

The guard is the right one, it is minimal, and the arms pin both directions. Two refinements to what the commit says about production, one question about a sibling path.

The guard matches the kernel's read pattern exactly

match.key_value_capacity = ceil_div(mask->ne[0], 64) * 64          (373, the PADDED token count)
key_value_capacity       = key->ne[1]                              (258/344, the STORAGE)
old: key_value_capacity < key_value_token_count   -> 65 < 65 false -> claimed
new: key->ne[1] < match.key_value_capacity        -> 65 < 128      -> declined

The body reads at block_ordinal * 64 for ceil(count/64) blocks, so the highest slot it touches is padded - 1; requiring the storage to be at least the padded capacity is exactly the bound, and requiring nothing more is the minimum that fixes it. Declining rather than clamping is also the right direction: a clamp would need the kernel to know about a tail it cannot see.

The arms are load-bearing, in both directions

65 keys at capacity 65 must fall back to ggml_flash_attention_f32_f16_wmma, and 65 keys at capacity 128 must take the split path — the second arm is the one that matters, because a guard that declines everything would pass the first. Building the graph with key_value_capacity = 128 and asserting the split command schedule is the correct way to prove the claim still happens where it is safe.

"Production decode graphs carry a KV cache capacity >= ctx, so they never hit it" — nearly

The guard compares the storage against ceil(tokens/64)*64, so a decode graph whose cache capacity is not a multiple of 64 does hit it in its last block: -c 1000 with 1000 tokens computed is capacity 1000 < padded 1024, and the split kernel is declined (correctly — it would have read 24 slots past). The fast path therefore needs capacity >= ceil(ctx/64)*64, which common contexts (2048/4096/32768) satisfy and an odd -c does not. Worth one clause, because "never hit it" is the sentence a future reader will use to decide the guard is dead code.

A question rather than an objection: the prefill matcher passes the raw storage

flash-attention's prefill matcher (line ~258) sets its config capacity to key_value_capacity = key->ne[1] with mask->ne[0] <= key_value_capacity as the only relation — the same shape as the decode one before this fix. If the prefill kernel also walks whole 64-token blocks over that capacity, it is the same class one path over; one line in the commit saying it was checked (or that its body indexes only up to the mask count) would settle it. Not a blocker for this PR, which is scoped to the fault that actually fired.

The rest

  • mask->ne[0] as the token count and key->ne[1] as the storage is the distinction the whole fix turns on, and the harness now models it: build_qwen_flash_attention_graph(..., key_value_capacity) with storage_capacity = key_value_capacity > 0 ? key_value_capacity : key_value_token_count keeps every other arm exactly as it was.
  • Zero-filling the padded tail in hrx-ops-test is the honest harness change: the kernel reads those slots, so they must be defined rather than whatever the allocator left.
  • The evidence is specific and matches the box's log: PERMISSION_FAULTS 0x3, RW 0x0 then a MODE2 reset, three times in 80 minutes, every one from common_flash_attention.decode.*.kv65 — the only shapes in the suite whose capacity equals an odd token count.
  • Host measurement is stated with its configure (GGML_HRX_HIP_ADDON_DIR empty, 97/99, two mtp_draft_shortlist.sampler_chain failures that also fail at the parent). The device row is owed and named, which is the right way to ship a guard: the host arms prove the matcher, and the device case proves the kernel no longer reads past.

(Trivia only: a stray blank line was added before run_qwen_flash_attention_dispatch_checks.)

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