Add challenge 101: Adaptive Layer Normalization (Medium)#267
Open
claude[bot] wants to merge 1 commit into
Open
Add challenge 101: Adaptive Layer Normalization (Medium)#267claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
Implements the AdaLN modulation kernel that conditions diffusion transformers (DiT, Stable Diffusion 3, FLUX, OpenSora, SiT). Each token is layer-normalized along the feature dimension and then modulated by a per-batch scale and shift vector that is broadcast across the sequence. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Adds challenge 101 — Adaptive Layer Normalization (AdaLN), the conditioning kernel used in modern Diffusion Transformers (DiT, Stable Diffusion 3, FLUX, OpenSora, SiT). For each
(b, n)token, the solver layer-normalizes along the feature dimension and then modulates by a per-batchscaleandshiftvector that is broadcast across the sequence:The per-batch (rather than per-channel) modulation is what distinguishes AdaLN from BatchNorm/RMSNorm and is the core mechanism by which time-step / class embeddings condition diffusion transformers.
X (B, N, D),scale (B, D),shift (B, D)(B, N, D), fixedeps = 1e-5,float32throughoutB = 16, N = 4,096, D = 1,152(DiT-XL/2 inspired, ≈ 600 MB working set)Validated end-to-end against the live platform (T4) with a hand-written CUDA reference solution — all functional + performance tests pass. Reference impl matches
torch.nn.functional.layer_normto within float32 precision on the example.Test plan
pre-commit run --all-filespassespython scripts/run_challenge.py challenges/medium/101_adaptive_layer_normalization --language cuda --action run→ example test passespython scripts/run_challenge.py challenges/medium/101_adaptive_layer_normalization --language cuda --action submit→ all functional + performance tests pass on T4F.layer_norm+ per-batch modulationsolvegenerate_example_test()output🤖 Generated with Claude Code