minimaxh3: fuse the int8 modulated-norm producer, dropping the bf16 plane

b025018's W8A8 DiT path unfused the norm: rms_mod wrote a bf16 plane and
each int8 linear re-quantised it. That bf16 plane grew the activation arena
14.41->15.54 GiB, which left vram_kv=0 and the server aborted at startup.

Mirror the E4M3 path instead. rms_mod_kernel gains a third quant mode (i8),
sharing r4d_q8.h's q8_top/q8_pack4 with the int8 quantiser, exposed as the
new rms_mod_quant_i8 op; the block's modulated norm now writes a_hm's int8
code pair directly (a_hm is q8_fed, so qkv/gate_up read the codes with no
per-linear quantiser) and a_hm carries no bf16 plane. ActFP8::cq()/cs()
resolve the pair by trunk format, so the norm producer and both step issues
collapse to one path. LinearFP8's int8 guard now demands the bf16 plane only
when it quantises itself, matching the fp8 branch, which never required it.

Arena is back to fp8 parity (243 buffers, vram_kv 938 MiB); the container
serves at TP2 and renders all five task types device-clean.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-20 10:40:03 -05:00
1 parent cbbab03183
commit 0fe7771210
5 files changed
+82 -85

No files matched your search

+8 -4
View File
@@ -993,10 +993,14 @@ inline int LinearFP8::declare(RadBuilder* b, Names& nm, const Geom& g, const cha
* set reads_x). The model must have declared the pair (ActFP8::declare_qs's `i8`). */
i8 = known && linear_is_w8(enc);
if (i8) {
if (!a.x || !a.q8 || !a.s8) {
fprintf(stderr, "radiance: '%s' is an int8 weight and its input lacks the bf16 plane "
"or the int8 code pair (the model declared its input before learning "
"the trunk is int8)\n", wn);
/* The codes come from the producer (`q8_fed`, which declares no `op_q` and so needs no bf16
* plane) or from this linear's own `op_q` over `a.x`. Either way the int8 pair must exist;
* the bf16 plane is required only when this linear quantises, exactly as the fp8 branch
* needs `a.q`/`a.s` without demanding `a.x`. */
if (!a.q8 || !a.s8 || (!a.q8_fed && !a.x)) {
fprintf(stderr, "radiance: '%s' is an int8 weight and its input lacks the int8 code "
"pair%s (the model declared its input before learning the trunk is "
"int8)\n", wn, a.q8_fed ? "" : " or the bf16 plane it quantises");
return RAD_E_DTYPE;
}
if (N % 16 || K % RAD_FP8_BLOCK) {