Repository navigation
gpu: gqa_prefill_flash_256_p2_lower, a first key a row - #234
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: The new gate does not detect removal of the equal-bound fault.
Must fix
1. Assert the equal-bound fault in an isolated launch
crates/gpu/src/flash_gqa_prefill.rs:3977 puts equality and past-count errors in one launch. This is a kind B gate defect: changing k0 >= c to k0 > c at line 791 leaves every assertion green. Row 37 still has zero weights and normalizes to NaN, while row 500 still raises the shared KeyCount fault. Staging, tile decisions and other rows' weight masks stay unchanged. With that mutant, an equal-bound-only launch returns NaN without the required fault.
Isolate this case now so a fault regression cannot pass the new gate. Insert this after let sink = ... and before the existing combined launch:
let equal = at(&count[37..=37], Some(&first[37..=37]), sink)
.expect("equal first key");
let f = gpu
.take_fault()
.expect("the fault word")
.expect("an equal first key raises a fault");
assert_eq!(f.layer, LAYER as u32);
assert_eq!(f.site(), Some(FaultSite::KeyCount));
assert!(equal.iter().all(|v| v.is_nan()));Non-blocking
⚠ Supply the add-class PTX proof: crates/gpu/src/flash_gqa_prefill.rs:686 also compiles the existing _p2, _p4 and _256_q8 entries.
Attach base/head ptx-scan output showing unchanged existing entries and exactly the new entry, plus gate-ptx-spill failing on the new rows before pinning. These are the add-class checks in base AGENTS.md; the reported lower-bound gate does not establish them.
Checked
Duplicates: all four dryer pairs read; entry wrappers delegate to the common body and launcher.
Complexity: diagnostics report prefill_256_p 49 → 65 and enqueue_packed 21 → 24. The diff adds lower-bound branches and launcher validation/dispatch; R12 exempts the kernel body from splitting.
Silent failure: refused bounds raise KeyCount and write NaN; absent k_first selects the plain entry.
Tests: the PR reports FAIL-first for lower-mask mutants. Source analysis and a host simulation of the combined fault case confirm the unchanged tile decisions and weight masks for the >= → > mutant. The proposed isolated launch checks its missing fault directly.
Gates: no existing numeric band moved. The unsafe-block ratchet has its dated PIN and reason.
Escape catalog: none of C1–C4 matched.
Notes
GPU evidence is incomplete: no nvidia-smi line or base/head gate-run hash pair. No GPU gate was run during validation.
Card check: needs-gpu. This pull request changes crates/gpu/src/flash_gqa_prefill.rs and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
prefill_256_p gains a const generic LOWER and a k_first_buf argument. With LOWER, row t attends over keys [k_first[t], n_keys[t]): the block starts its walk at the tile holding its smallest first key and stages zeros below it, a key below a row's first scores -inf and weighs 0, a warp skips a tile below all its rows' first keys, and a first key at or past the count raises key_count with NaN in that row. The _p4, _p2 and _256_q8 entries pass LOWER = false and never read k_first_buf. The new entry gqa_prefill_flash_256_p2_lower (FlashGqaPrefill:: enqueue_256_p2_lower) is the pack-of-two walk with LOWER: the window an encoder's symmetric sliding layer sets per row, the width host data. hw_p2_lower_is_each_rows_window holds each sampled row bit for bit its one-row launch over a cache NaN outside its window at half windows 256, 300 and 512, first keys of zero the plain entry's bits, a first key of 192 the plain entry's bits on the cache from row 192 on, a dominant key read exactly by the rows whose window holds it, the key_count fault and a short k_first refused by name. A mixed-slice launch holds the skipped NaN tiles below a slice's first keys and the softmax mask at a live tile's lower edge.
ad4537b to
750ab61
Compare
|
The branch is now at 1. The equal-bound fault. Applied as given: the gate now launches row 37 alone with its first key equal to its count and asserts the fault word, its layer, 2. The add-class proof. The description is updated to this head: the per-card gate results, a t1 |
There was a problem hiding this comment.
Verdict: CLEAN: No blocking behavior or quality defect was found in the lower-bound prefill change.
Non-blocking
⚠ Add-class verification is incomplete: crates/gpu/src/flash_gqa_prefill.rs:2444.
The body omits the owning gate runs that AGENTS requires when engine binaries gain an entry. Its PTX comparison uses base b3153d77, while this review's base is 9fc2cc0d.
Run the owning gates and PTX/spill comparison against the review base; attach commands and output. This closes integration coverage before the first engine caller lands.
⚠ Four clauses lack FAIL-first evidence: crates/gpu/src/flash_gqa_prefill.rs:3765.
The body reports no mutants for clauses 2, 3, 4 and 7; the add class requires FAIL-first per clause.
Exercise wrong plain-entry dispatch, shifted cache addressing, an exclusive lower boundary, and removal of the short-buffer guard. Attach each failing assertion while the gate is being introduced.
Checked
Duplicates: lower and existing packed entries share prefill_256_p; packed launchers share enqueue_packed.
Complexity: lower-bound guards extend the shared kernel; packed dispatch gains one arm and a buffer check.
Silent failure: invalid lower bounds raise KeyCount and produce row NaNs; a short k_first returns a named shape error.
Tests: the ignored hw_ gate covers windows, zero and shifted lower bounds, invalid bounds and short buffers. The body reports mutants failing clauses 1, 5 and 6. CUDA runs were not independently repeated.
Gates: unsafe ratchet 1769→1771 has a dated PIN and names both added blocks. No numeric band moved.
Escape catalog: no patterns matched.
Notes
GPU labeling evidence is incomplete: the body supplies isolated tools/gate.sh runs, without just gate-* recipe output.
Card check: needs-gpu. This pull request changes crates/gpu/src/flash_gqa_prefill.rs and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
Part of #59 (plan and PR order in #190), E4: the non-causal symmetric window in prefill, as a const generic. The head-512 prefill entries and the GELU-gated entry are separate PRs.
What and why
Release notes: Under the hood: a lower key bound per row in the pack-of-two prefill flash, for EmbeddingGemma 2's sliding layers; no engine path calls it yet.
EmbeddingGemma 2 is a non-causal encoder. Its sliding layers use a symmetric window: llama.cpp's
LLAMA_SWA_TYPE_SYMMETRICkeeps keyjfor queryiwhen|j - i| <= n_swa / 2, so rowtof a pass overntokens attends over keys[max(0, t - w), min(n, t + w + 1)). The pack-of-two prefill (gqa_prefill_flash_256_p2, the layout of four query heads over two key heads that EmbeddingGemma 2's sliding layers have) already takes the upper bound per row as data (n_keys[t]). It has no lower bound. This PR adds one.prefill_256_p, the body behind the_p4,_p2and_256_q8entries, gains a const genericLOWER: booland ak_first_bufargument. WithLOWER, rowtreads its first keyk_first[t]and attends over[k_first[t], n_keys[t]). The block starts its walk at the tile that holds its smallest first key and stages zeros below that key, as it already does at and past its largest count. A key below a row's first key scores-infand weighs 0, like a key at or past its count. A warp skips a tile that is below the first keys of all its rows. A first key at or past the row's count raiseskey_countand leaves the row NaN, like a count of zero.gqa_prefill_flash_256_p2_lower, is the pack-of-two walk withLOWER.FlashGqaPrefill::enqueue_256_p2_lowerlaunches it; it takes the sameGqaPrefillArgsplusk_firston the device and refuses a shortk_firstby name.LOWER = false, which never readsk_first_buf.The window width is not a kernel constant. The host computes
k_first[t]andn_keys[t]for each row, so one entry takes any width: EmbeddingGemma 2's GGUFsliding_windowof 1024 is a half-width of 512, and the gate also runs half-widths of 256 and 300. A layer with no window passesk_first = 0andn_keys = n. EmbeddingGemma 2's global layers have heads of 512 and use the head-512 entries instead.No engine path calls the entry yet. The E5 body of #190 (
gpu-gemma-embedding2) is its first caller, and it computes each row'sk_firstandn_keysas above.Code shape
gqa_prefill_flash_256and the 128 body are untouched.key_countand writes NaN in that row, and the launcher refuses a shortk_first.tools/unsafe-ratchet.txtmovesgpufrom 1769 to 1771 blocks with aPIN(2026-10-14):line: the new entry's call intoprefill_256_pand the walk's read ofk_first_buf, each with its SAFETY line.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line): none.What I ran
All runs are at the head
750ab61cb6d395059cf91ad28ed6fa0d35939224over the baseb3153d7749f34d1aaf1329ea5f11ee4fc62cb177, unless a line names another commit. The card runs used a DGX Spark (aarch64 Linux) in the project's dev container and an x86_64 Linux machine with an RTX 5090. The static checks ran on an Apple Silicon Mac.just contrib-check(t1, the default) on the RTX 5090:The one red is
check-recipes, whosestall-termself-test fails on this machine withFAIL stall-term: got [post 0 rc=124], want [post 0 rc=143]. The baseb3153d77gives the same line on the same machine (DONE tier=t1 total=100 red=1 wall=295s red: check-recipes), and this PR does not touchtools/.just mac-staticon the Mac: fmt-check 0 diff blocks, and lint at the ratchet:Gate.
hw_p2_lower_is_each_rows_windowincrates/gpu/src/flash_gqa_prefill.rs, a testgate-gpu-libruns. I ran it alone withbash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- --include-ignored hw_p2_lower_is_each_rows_window(BLOOMERY_ARCH=sm_121) on the DGX Spark and-- --ignored hw_p2_lower(BLOOMERY_ARCH=sm_120) on the RTX 5090. The shape is EmbeddingGemma 2's sliding layer: four query heads over two key heads, heads of 256, scale 1.0, 1,200 rows over 1,200 keys (a 16-row tail block and a 48-key tail tile). Every clause is bit for bit or exact, so no band is involved:_p2entry's output at the same counts._p2entry's output over the cache from key 192 on, with every count lowered by 192.ctx=192).key_countat the launch's layer and returns NaN. Launched with a first key past its count (row 500), both rows are NaN and every other row equals the clean launch bit for bit.k_firstone row short is refused by the launcher, with an error namingenqueue_256_p2_lowerandk_first.The references are the plain
_p2entry, which the engine gates already pin, and each row's own one-row launch. #190's table names host f64 rules for E4; this gate needs none, because every clause is bit for bit.DGX Spark:
RTX 5090:
FAIL-first. Each mutant was a temporary patch in
crates/gpu/src/flash_gqa_prefill.rs, run alone against the gate on the DGX Spark and reverted after its run. The first three ran atad4537be, whose kernel code is this head's (the two differ only in the test); the last ran at this head, whose tree was clean after it:row 8: a skipped NaN tile or a masked value reached its outputw=256 row 260: not its one-row launchctx=192only, so clause 1 stays greenrow 17: a skipped NaN tile or a masked value reached its outputk0 >= crelaxed tok0 > can equal first key raises a faultClauses 2, 3, 4 and 7 have no mutant of their own.
PTX (add class).
just ptx-scanofgenerate_ds41andgate_e2e, base against head, on the DGX Spark (sm_121, JIT on the GB10) and withBLOOMERY_ARCH=sm_86:Every existing entry's PTX is unchanged, and the one added entry is the new one. Before its rows went into
tools/ref/ptx-shapes.tsv,tools/ptx-spill-check.shon the GB10 reported it unpinned:The same run also reports
mamba2_stepunpinned in both binaries, and that row stays unpinned after this PR; this PR does not touch it, and I did not run the base's spill check. The cc 8.6 run has no card behind it: the spill check there readptxasstack frames in place ofjit_local, and before pinning it reported only the new entry.Gates
just affectedselects and I did not run.just affected b3153d77selects 114 of 161 gate recipes, all throughcrates/gpu/src/flash_gqa_prefill.rs. Since no existing entry's PTX moved and no engine path calls the new entry, the runtime gate is the new test above, and I did not run the other 113.Hardware (if the change is for a machine)
DGX Spark, dev container
nvidia/cuda:13.3.1-devel-ubuntu24.04:RTX 5090:
What I ran into
None of this blocks the PR.
tools/ref/ptx-shapes.tsvfor the new entry comes fromptxas -arch=sm_86 -vand was not read on a 3090. If a reading there differs, the row changes to it (model: EmbeddingGemma and EmbeddingGemma 2 on a side seat #190, open question 1).0 * NaN). The same already holds for a key between a row's count and the block's largest count; the module doc says so for both.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.