libr4d: review fixes -- the quantised stores apply v_scale; scales clamped so every code decodes finite; two more selftest shapes

kv_store_fp8v4 / k6v4 and the folds now read v_scale as the fp8 store does (attention already
applied v_descale). Scales are clamped to 8188 (V) and 2112 (K) so 7 or 31 times them stays an
f16: a group gone inf or NaN decodes finite, as E4M3's clamp to 448 does. r4d_selftest adds
decode at ctx 1000 (a partial last block) and q_len 7 (three waves) for both layouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-19 15:28:21 +02:00
1 parent 1823ccd5e9
commit 3e656f0b02
4 files changed
+27 -14

No files matched your search

+2 -1
View File
@@ -814,7 +814,8 @@ base belongs to the block manager, not the batch.
**`kv_dtype` `fp8_v4` and `k6_v4`** (device-only) are the quantised layouts of
`--kv-cache-dtype` (`RadBuildCtx::kv_quant`). A head's dims are grouped by 32, each group with an
f16 scale (its absmax over the largest code), codes two's complement. A token's row in a head, at
f16 scale (its absmax over the largest code, clamped so every code decodes finite in f16),
codes two's complement. A token's row in a head, at
head_dim HD:
| bytes | `fp8_v4` (25 HD / 16) | `k6_v4` (22 HD / 16) |