Repository navigation
gpu: raise faults for overflowing QSA sums and invalid f16 cache values - #976
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No blocking defect survives review of the cache checks and QSA sum check.
Non-blocking
⚠ Complete the GPU evidence: gate_flint_attn.rs:946 and gate_mimo2_flash.rs:1630 add cases absent from the supplied output.
Add their FAIL-first/PASS output, the nvidia-smi card/driver line, and exact before/after commit hashes.
This lets the changed writers be verified against the reported binaries.
Checked
Duplicates: 6 new items Grep-checked; all 6 dryer pairs read. They are existing norm/rotation/format kernel variants. The new cache validation has one device owner and a separate host oracle.
Complexity: Flint cache_value_case (24), Qwen cache_value_check (24), generic_cache_value_check (21), and score_sum_check (21) are new case runners with setup, launch, and verification stages. Qwen run 63→74 adds CLI dispatch; Flint run 21→23 adds case calls; MiMo append_clauses 31→40 adds A3 cases; qsa_score 25→26 adds one finite check. Kernel bodies need no split.
Silent failure: 8 writer/sum sites followed. Invalid values raise CacheValue or PoolSelect; token readback returns GpuError::Fault and poisons model state. Invalid cache lanes become NaN. Position guards and live-pool guards prevent invalid accesses and padding faults.
Tests: static mutation review. Bypass the cache calls at flash.rs:850, rope_neox.rs:719/921/1104, qk_rms.rs:174, or attention_h128_ring.rs:166/327: the corresponding cache clause fails. Delete the check at qsa.rs:851: score_sum_check fails. Drop NaN marking or alter finite/neighbor bits: cache assertions fail. Omitting CacheValue makes the amended overflow clauses fail.
Gates: no tolerance relaxed or clause removed. Unsafe budgets have dated PINs explaining the additional bounded scopes.
Performance: decode/prefill cache writers and the selector changed; no added launches, copies, allocations, locks, syncs, or float reduction reorder.
Escape catalog: C1–C4 have no matches.
Notes
Validation was static. GPU gates were not rerun. The supplied card table and gate excerpts do not satisfy the complete GPU evidence list.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_flint_attn.rs, crates/gpu-gates/src/bin/gate_mimo2_flash.rs, crates/gpu-gates/src/bin/gate_p0b.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. |
QSA 점수 합이 넘치거나 f16 KV 캐시 값이 유효하지 않을 때 이제 커널 fault를 올리도록 고쳤습니다.
What and why
Two kernel paths stored bad values without raising a fault. The QSA score kernel checked each head's dot product but not the sum of the four head dots, so four finite dots could add up to
infand be stored silently. The f16 KV cache writers (the 128-dim append, the K192 plane and ring append, andF16Sink) rounded to f16 with no check, so a NaN, an Inf or a value that overflows f16 (such as 65520) went into the cache.The QSA kernel now raises
PoolSelectwhen the final sum is not finite. A sharedcache_f16_pairincrates/gpu/src/rope_neox.rsraisesCacheValuewhen a source value or its f16 result is not finite and stores NaN for that lane only. The existingf32x2_to_f16x2_bitsandf16_finitehelpers are reused, and finite values keep their current rounding.gate_qwen35moe_attn --kernel-faultsgains the boundary inputs below.Release notes: Fixed: non-finite QSA score sums and invalid f16 KV cache values now raise a kernel fault instead of being stored silently.
Code shape
cache_f16_pair, used by all three cache writers. Duplication found or removed is listed below.rope_neox.rsstates the new fault behavior.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": the three inlinef32_to_f16_bitscache stores incrates/gpu/src/rope_neox.rsbecame onecache_f16_pair.What I ran
On a DGX Spark, one run built the new gate against the two kernel sources as they were before this change, then against this branch, and ran each:
Before (exit 1): the V and K cache NaN/Inf/65520 cases and the QSA sum overflow raise no fault.
After (exit 0): the same cases raise the expected fault and mark the lane NaN. Finite boundary values keep their host-exact cache bits. All 16 cases (K and V, dim 64 and 192, NaN, Inf, 65520, -65520) pass.
The K192 append gates, which exercise the changed cache writers, pass:
Hardware (if the change is for a machine)
sm_121a)AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.