Archived
docs(ref2va): localize the ~0.37x under-gain to the final norm/conv; record GN-extent gap (#14/#20)
Architecture refutes the "per-level attenuation compounding" reading: both encoders TERMINATE in a normalisation that re-writes activation scale (video norm_out=venc_gn before conv_out/quant_conv; audio pre-block norm1/2/3 LayerNorms before proj/mean_proj). A GroupNorm/LayerNorm output has std ~= its per-channel gamma regardless of input, so any gain accumulated in the encoder BODY is erased before the latent is emitted. The ~0.37 can therefore only originate in the FINAL norm's affine application or the final conv/linear: video norm_out(gamma)->conv_out->quant_conv; audio norm3(gamma)->proj-> mean_proj. The two families' scale differing slightly (0.385 vs 0.369) is simply those final chains differing per arch. Re-explains encoder-confinement cleanly: the DiT uses RMSNorm (rmsnorm_op), the encoders use GroupNorm/LayerNorm kernels (shared with the latent upscaler) -- a defect in those kernels is invisible to the DiT's RMSNorm path, consistent with the DiT generating correctly. Narrowed confirming step recorded: dump per-channel std of norm_out output and conv_out/quant_conv output (and audio norm3/mean_proj) -- post-final-norm std ~0.37 pins the norm affine/kernel; ~1.0 with collapse only after conv_out/quant_conv pins those conv weights. Not blind-fixed (shared with live image/plain + upscaler paths). Also records a SEPARATE real fidelity gap found while localising (task #20): the device GroupNorm reduces statistics over a level's whole clip volume, but the reference TemporalIsolatedGroupNorm normalises per frame. Exactly neutral for the single-image parity measurement (T=1) but it biases real multi-frame video reference encodes -- what DaSiWa actually feeds -- as a shape change stacked on the 0.37. Recorded, deliberately not touched (shared kernel; whole-volume pooling may be an intentional temporal choice). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
04440dd3a9
commit
0bfde46414
1 file changed
+35
-17
+35
-17
@@ -252,24 +252,42 @@ as point 6 / point 4. Nothing here claims to match ComfyUI's timings.
|
||||
"suspect the strided conv1d temporal reduction" readings above**: a conv-reduction or structural transform
|
||||
bug would *not* collapse to a clean global scale. The device encoders are computing the *right shape* of
|
||||
latent, just damped to ~0.37× amplitude (video additionally carries a small positive offset and slightly
|
||||
more tail-compression — its R² 0.912 and residual 0.114 are the structural remainder). Because the scale
|
||||
is ~0.37 for both but *not* bit-identical (0.385 vs 0.369), it is not one shared post-hoc multiply; it
|
||||
reads as a **fixed per-level attenuation compounding across each architecture's own depth** (≈0.83× per
|
||||
level over ~5–6 levels lands near 0.37, and the two archs' depths differ slightly).
|
||||
more tail-compression — its R² 0.912 and residual 0.114 are the structural remainder).
|
||||
|
||||
Crucially, the DiT — which shares the container's fp8 weight path and the engine's normal conv / GroupNorm
|
||||
/ activation kernels — **generates correctly**, so this is *not* a global kernel or quant fault: the
|
||||
under-gain is **confined to the encoder pass**. The prime suspect is therefore the encoders' per-level /
|
||||
per-frame normalisation (the §5.13 per-frame GroupNorm `CS∈{8,4}` template) applying a near-constant
|
||||
sub-unit gain that compounds level-over-level, or an encoder-path weight/activation dequant scale mismatch
|
||||
that the convert-time quant round-trip does not see. If it is a fixed encoder-norm gain, a correct fix is
|
||||
**confined to the encoder path and never touches the DiT's norms** — which is precisely why this is worth
|
||||
localising rather than shipping. The **confirming step is cheap and read-only** (no math change, gated):
|
||||
dump one encoder block's GroupNorm *input and output* on-device and test whether the output std is a fixed
|
||||
fraction (~0.8×) of the reference GN's — that single dump pins the op. **Not blind-fixed** (the encoder
|
||||
kernels are shared with the live image / plain encode paths; the standing rule is never ship a
|
||||
merely-*different* latent). Reproduce: `--evc/--encpx/--encg` or `--enca/--encsm` as above; each harness
|
||||
now prints the `a`/`b`/R²/after-affine line alongside the raw sorted relFro.
|
||||
**Where the gain can and cannot be (architecture-narrowed).** A code sweep ruled the *body* out: both
|
||||
encoders terminate in a **normalisation that re-writes the activation scale** before the latent is
|
||||
emitted — video's last op before `conv_out`/`quant_conv` is `norm_out` (`venc_gn`,
|
||||
`arch/minimaxh3/minimaxh3.cpp:2278`); the audio pre-block's `norm1/2/3` LayerNorms precede `proj`/
|
||||
`mean_proj`. A GroupNorm/LayerNorm output has std ≈ its per-channel gamma *regardless of input
|
||||
magnitude*, so **any gain accumulated in the encoder body is erased by that final norm — the earlier
|
||||
"per-level attenuation compounding across depth" reading is therefore wrong** (it could not reach the
|
||||
latent). The ~0.37 can only originate in the **final norm's affine application, or the final
|
||||
conv/linear**: video `norm_out`(gamma `ve_now`)→`conv_out`→`quant_conv`; audio pre-block `norm3`(gamma)→
|
||||
`proj`→`mean_proj`. The two families' scale differs slightly (0.385 vs 0.369) simply because those final
|
||||
chains differ per arch.
|
||||
|
||||
**Why encoder-only is consistent with the DiT generating correctly:** the DiT's norms are **RMSNorm**
|
||||
(`rmsnorm_op`, `minimaxh3.cpp:638`), whereas the encoders use the **GroupNorm / LayerNorm** kernels
|
||||
(`r4d_upscaler.hip`, shared with the latent upscaler). A defect in *those* kernels is invisible to the
|
||||
DiT's RMSNorm path — so an encoder-norm-kernel scale fault remains the leading suspect, and a fix could
|
||||
stay confined to the encoder/upscaler norm path. The **narrowed confirming step** (device, gated, read-
|
||||
only — no math change): dump the **per-channel std of `norm_out`'s output and of `conv_out`/`quant_conv`'s
|
||||
output** (and audio's pre-block `norm3` output and `mean_proj` output). If the *post-final-norm* std is
|
||||
already ~0.37× the reference, the fault is the final affine / norm kernel; if it is ~1.0× and the collapse
|
||||
appears only after `conv_out`/`quant_conv`, the fault is those final conv weights. **Not blind-fixed**
|
||||
(those kernels are shared with the live image / plain encode paths and the upscaler; standing rule: never
|
||||
ship a merely-*different* latent). Reproduce: `--evc/--encpx/--encg` or `--enca/--encsm` as above; each
|
||||
harness now prints the `a`/`b`/R²/after-affine line alongside the raw sorted relFro.
|
||||
|
||||
**Separate real fidelity gap found while localising (its own ticket, not the 0.37):** the device
|
||||
GroupNorm reduces statistics over a level's **whole clip volume** (one mean/rstd per group;
|
||||
`ref_video.cpp:472-495`, `r4d_upscaler.hip:540-565`), but the reference `TemporalIsolatedGroupNorm`
|
||||
normalises **per frame** (time merged into batch; `comfy/ldm/minimax/vae.py:122-130`). This is exactly
|
||||
neutral for the single-image parity measurement above (`T=1`), but it **biases real multi-frame video
|
||||
reference encodes** — which is what DaSiWa feeds (ref videos are many frames). It changes per-frame
|
||||
statistics (shape), not a clean scale, so it is a second, independent divergence stacked on the 0.37 for
|
||||
video refs; recorded here, deliberately **not** touched (shared kernel; may be an intentional
|
||||
temporal-consistency choice).
|
||||
|
||||
What still differs from the DaSiWa reference (hence not pixel-for-pixel reproducible):
|
||||
- **The text encoder only *names* a moving picture; it never sees its pixels.** DaSiWa also shows
|
||||
|
||||
Reference in new issue
Block a user