Fold HYV3 residual adds into the following norms

Reuse the existing BF16-rounded add/norm fusion while retaining final output materialization and the original collective positions. Cover TP1, TP2 and multi-pass prefill without introducing calibration hooks.
This commit is contained in:
Constantin authored and StillDeadcode committed 2026-10-27 18:28:46 +01:00
1 parent d59cdce040
commit 36c39efdca
4 files changed
+81 -16

No files matched your search

+7 -3
View File
@@ -348,7 +348,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
}
#endif
RAD_ARCH_TRY(rad_bind_layer_kv(b, (int)l, m.kv_full));
status = lay.attn.declare(b, nm, g, (int)l, m.kv_full, aw, as);
// Each norm folds its predecessor's residual add. The first attention reads the
// embedding directly; the final feed-forward keeps its add for the plain output norm.
// Keep the collectives in the same places and the routed/shared FP32 combine separate.
status = lay.attn.declare(b, nm, g, (int)l, m.kv_full, aw, as, l > 0, false);
if (status < 0) {
fprintf(stderr, "radiance: hyv3: attention layer %lld declaration failed (%d)\n",
(long long)l, status);
@@ -369,7 +372,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
ds.up = nm.ckpt("%s.up_proj.weight", mlp);
ds.down = nm.ckpt("%s.down_proj.weight", mlp);
#endif
status = lay.dense_mlp.declare(b, nm, g, (int)l, dw, ds);
status = lay.dense_mlp.declare(b, nm, g, (int)l, dw, ds, true,
l + 1 == g.n_layer);
if (status < 0) {
fprintf(stderr, "radiance: hyv3: dense MLP declaration failed (%d)\n", status);
return status;
@@ -403,7 +407,7 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
return status;
}
#endif
status = lay.moe.declare(b, nm, g, (int)l, m.mw, ms);
status = lay.moe.declare(b, nm, g, (int)l, m.mw, ms, true, l + 1 == g.n_layer);
if (status < 0) {
fprintf(stderr, "radiance: hyv3: MoE layer %lld declaration failed (%d)\n",
(long long)l, status);