Repository navigation
gpu: retain both BF16 parts in the chunked delta products - #816
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect was found in the changed code.
Non-blocking
⚠ Supply the precision-change proof: crates/gpu/src/linear/delta.rs:1545.
Prompt processing increases from 448 to 1,344 warp MMA instructions per value head per complete 16-token chunk: +56 per head per token [derived]. Prepared shared memory also grows from 45,760 to 48,832 B per block [derived].
Before this becomes the timing baseline, attach the error model, count-pin gate and timed A/B required by AGENTS' “float sum order or precision” class, plus the final affected Qwen class gates. Include resource counts, both tested hashes and the exact model file.
⚠ Exercise the remaining residual paths: crates/gpu-gates/src/bin/gate_linear.rs:3023.
With Q = K = e0, the Q/K, inverse and causal matrices have zero residuals. Dropping those residual paths leaves both new state assertions green.
Extend this clause with non-BF16, multi-key inputs and check output as well as state. Attach FAIL-first output. Identify a reusable state/argmax probe, or explain why the gate output supplies the fix's debugging layer.
Checked
Duplicates: 5 new items checked (3 helpers, 2 offsets); no duplicate owner found. Dryer reported 0 model pairs; GPU code was checked manually.
Complexity: prompt_clauses 35→41 adds fixture setup and two cases; gdn_delta_prepared 45→51 adds precision passes. The kernel was checked for correctness without proposing a split.
Silent failure: 0 new default/error-suppression sites; 2 new conversion/product paths followed. Non-finite output/state raises LinearDelta; token readback returns GpuError::Fault.
Tests: scalar mutation checks of the state-residual selection at delta.rs:1566 and solved-row cross product at delta.rs:623 turn the respective new assertions red. No device test was run here.
Gates: bands unchanged; unsafe ratchet has a dated PIN and reason. Record bounds and the 133,124 B extra scratch peak were checked [derived, Qwen3.8, m=1..4096, carry=0..15].
Escape catalog: C1–C4 do not match.
Notes
Dryer did not scan crates/gpu or crates/gpu-gates. The reported GB10 run lacks both tested commit hashes and an exact checkpoint path, so gpu.json records incomplete evidence.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_linear.rs, crates/gpu/src/arch/qwen3moe/scratch38.rs, crates/gpu/src/linear/delta.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. |
긴 프롬프트를 chunk로 처리하는 선형 어텐션 커널이 BF16 반올림 때문에 상태를 잘못 갱신하던 문제를 고칩니다.
What and why
The chunked prompt form of the Gated DeltaNet kernels (
crates/gpu/src/linear/delta.rs) rounded each F32 operand ofits matrix products to one BF16 value. A state that sits between two BF16 values was therefore treated as if it had
moved, and the rule produced a false update on every chunk. With Q = K = e0, beta = decay = 1 and v = 1.00390625 the
state must stay at v, and it did not. On the FP4-Local checkpoint the error is large enough to flip the argmax at
position 4,128.
This change splits each F32 operand into a BF16 high part and a BF16 residual, and accumulates the high-high product
and the two cross products in F32 through the existing
chunk_mma. Q and K, the inverse, and the solved update keeptheir low parts. The already consumed Q tile is reused for the low K transpose, so the prepared kernel stays at
48,832 B of shared memory. The chunk record grows from 304 to 560 words per chunk; the short-walk reserve in
scratch38.rsandplace.rsis recounted, and the 32 MiB reserve still holds it. Launch counts, carry, lanes, stampsand the gate bands are unchanged.
gate_lineargains two clauses for the fixed point above, one starting at v and onestarting at zero.
tools/unsafe-ratchet.txtmoves the GPU pin to 2621 blocks and 326 unsafe fns for the new blocks,each with its SAFETY line.
Release notes: Fixed: Long prompts on Qwen3.8 linear-attention layers no longer accumulate BF16 rounding error in the chunked state update.
Code shape
chunk_mma.cargo fmtis clean on what I touched, andcargo clippyis clean forbloomery-gpu-gatesandbloomery-model.bloomery-gpuneeds CUDA, so clippy did not run on it here; its code was built and exercised by the gate below.Duplication found or removed (
path:line), or "none": none.What I ran
Format and lint on a Mac, on this head:
The unsafe ratchet check accepts the new GPU counts.
The owning GPU gate, on a DGX Spark. The run used this branch's kernel code; the head that is posted differs from it only in SAFETY comment text.
The 4,096-row state error is 5.164e-6, inside the existing 2e-2 band, and the kernel has no local-memory spill.
On the FP4-Local checkpoint served by the feature server, the argmax at position 4,128 is token 364, the same token the f32 reference picks.
Hardware
DGX Spark with one GB10, driver 595.84, CUDA 13.3,
sm_121abuild. The gate above ran on it with the synthetic Qwen3.6-35B-A3B-shaped inputs thatgate_linearuses; the argmax check ran against the FP4-Local checkpoint.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.