feat: add AdaLN-Zero conditioning as alternative to FiLM#24
Open
tashapais wants to merge 1 commit into
Open
Conversation
Adds AdaLNZeroNorm to norms.py: pre-norm with zero-initialized MLP that produces (scale, shift, gate). Gate starts at zero so residual paths are identity at init, stabilizing early training (DiT-style). Each sublayer (SpatialAttention, TemporalAttention, SwiGLUFFN, MoESwiGLUFFN) gains a use_adaln_zero flag. When enabled, the forward switches from post-residual FiLM norm to pre-norm + gated residual: x + gate * sublayer(adaln(x, conditioning)) use_adaln_zero=False by default, preserving all existing behavior. Wired through STTransformer, all three model classes, training scripts, and configs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AdaLNZeroNormtomodels/norms.py: a pre-norm module that produces(scale, shift, gate)from a zero-initialized MLP. The gate starts at zero so all residual paths are identity at initialization, matching the DiT paper's stabilization trick.use_adaln_zerothroughSpatialAttention,TemporalAttention,SwiGLUFFN,MoESwiGLUFFN,STTransformerBlock,STTransformer, and all three model classes (VideoTokenizer,LatentActionModel,DynamicsModel).norm(x + sublayer(x), cond)to pre-norm + gated residual:x + gate * sublayer(adaln(x, cond)).use_adaln_zero=Falseby default, preserving all existing behavior and checkpoints.Test plan
use_adaln_zero: trueintraining.yamland verify loss decreases normallyuse_adaln_zero: false(default) produces identical results to mainuse_adaln_zero: trueininference.yaml)