arch: audio pre_block feeds each branch the reference's norm (#14)

The reference AttnProjection (comfy/ldm/minimax/audio_vae.py:267) computes
proj(norm3(x)) + attn(norm1(x)), then + mlp(norm2(·)). The two 2048-wide
LayerNorms are not interchangeable: norm3's affine |w|mean is 0.60, norm1's
0.27, so the projection branch carries most of the block's magnitude (std 6.6
via norm3 vs 0.4 for the attention via norm1).

The device had them wired the other way -- it staged norm1 into the projection
and norm3 into the attention (qkv). Feeding the small-affine norm1 to the
projection shrank it 6.6 -> 1.8, collapsing the pre_block output and every
audio latent downstream to ~0.25-0.27x the reference.

Fix: stage norm1 for the attention (feeding p_op_qkv) and norm3 for the
projection (feeding p_op_proj). Both LN ops are the same ln(...,2048,b_apb->
b_aln3) kernel, so only the consumer wiring changed -- no kernel touched, no
re-convert (norm1.*/norm3.* weights are already loaded correctly).

Also adds a gated read-only R4D_ENC_SEL=amb readback (dbg_ae_amb = b_amb, the
f32 mean_proj input): the bf16 b_ax2 readback lags the arena and dumps garbage,
so b_amb is the reliable pre_block output used to localise the gap. Inert when
R4D_ENC_SEL is unset.

Device-verified (seed=7 tone, minimax-h3-ref2va-fp8, warm TP2): pre_block out
b_amb std 1.65 -> 6.43 (ratio 0.25 -> 0.97); final latent b_enca std 0.23 ->
0.546 vs reference 0.588 (ratio 0.39 -> 0.93), affine slope 0.385 -> 0.923,
R^2 0.975 -> 0.989. Host tier green (abi_layout/arch/ref/videos).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
gearwave00001andClaude committed 2026-10-19 17:15:30 -05:00
1 parent 0bfde46414
commit 39602c1c7b
6 files changed
+178 -11

No files matched your search

+16
View File
@@ -983,6 +983,22 @@ typedef struct RadVideoGenDecl {
int64_t dbg_enca_bytes;
rad_buf dbg_evc;
int64_t dbg_evc_bytes;
/* The audio mean_proj OUTPUT (b_amb2), i.e. the latent BEFORE the fixed (z-mean)/std norm —
* the mono, last-channel slice of it. Read only when R4D_ENC_MP names it in place of b_enca,
* to split whether a latent-scale gap is introduced by the body or by the norm op. Trailing
* since ABI 23 with the fields above: an older plugin declares none and keeps the 0 default. */
rad_buf dbg_ae_mp;
int64_t dbg_ae_mp_bytes;
/* The audio pre_block OUTPUT (b_ax2), one stage before mean_proj; bf16, the mono last channel.
* Read only when R4D_ENC_SEL=pre, to split a body-scale gap between pre_block and mean_proj.
* Trailing since ABI 23 with the fields above. */
rad_buf dbg_ae_pre;
int64_t dbg_ae_pre_bytes;
/* The audio mean_proj INPUT (b_amb), i.e. the pre_block output cast to f32. Read with
* R4D_ENC_SEL=amb: it is the reliable f32 twin of the arena-rotated bf16 b_ax2, and splits a
* body-scale gap between pre_block and mean_proj. Trailing since ABI 23 with the fields above. */
rad_buf dbg_ae_amb;
int64_t dbg_ae_amb_bytes;
} RadVideoGenDecl;
int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d);