Repository navigation
[Refactor] Reuse FP32 RMSNorm normalization in MAGI-2 - #7286
yeahdongcn wants to merge 1 commit into
Conversation
Signed-off-by: Xiaodong Ye <xiaodong.ye@mthreads.com>
|
This PR touches tests/diffusion/, vllm_omni/diffusion/ (2 files). Based on CODEOWNERS coverage of the changed files, the most-related reviewers appear to be: Could one of you take a look when you get a chance? Thanks! |
|
@yeahdongcn Final follow-up: are you planning to continue work on this PR? Please reply within 72 hours of this comment's published timestamp. A yes or a brief plan is enough; code changes do not need to be finished within these three days. If you are waiting on a review, CI, or other maintainer action, or need more time, please let us know. If there is no reply, new commit, or maintainer takeover after that period, we will recheck and close this PR as inactive. If you explicitly confirm that you will not continue, we will close it after checking that nobody has taken over. It can be reopened when work resumes. |
Summary
Use the existing PyTorch RMSNorm operation for MAGI-2's FP32 normalization, while keeping its checkpoint-specific affine operation outside the call.
F.rms_normreceives no affine weight; MAGI-2 still applies its flattened, modality-major(weight + 1)scales afterward, then casts to the requested output dtype.This is the normalization portion of the reference #7156 decomposition, without its BF16/FP16 intermediate downcasts or separate mHC overrides. Omni's standard RMSNorm parameter represents effective scale directly, so substituting it for MAGI-2's delta-scale parameter would change checkpoint semantics; only the unweighted normalization operation is reused here.
Numerical contract and investigation
This is not a bitwise-equivalence claim. An initial MUSA test used a uniform
rtol=atol=1e-6on all output dtypes: FP32 and BF16 cases passed, but 2 of 43008 FP16 values differed by one FP16 ULP.An independent same-source diagnostic compared outputs before and after the final cast. Across nine dtype/shape cases, all pre-cast FP32 comparisons passed the original
1e-6gate (largest absolute difference9.54e-7); both implementations' low-precision outputs exactly matched their own FP32 outputs cast at the end. The discrepant FP16 values straddled a rounding midpoint. For example, pre-cast1.6381838322versus1.63818359375rounded to1.638671875versus1.6376953125.The final test makes the acceptance contract explicit and expands coverage to three seeds:
rtol=atol=1e-6.This replaces the inappropriate uniform FP32 tolerance on quantized outputs; it is an explicitly documented gate adjustment, not a retroactive pass for the initial run. Separate FA3 numerical gates are unchanged. Full-model acceptance remains a separate requirement.
Validation
Tested commit
da47bf6772f7b91425d25045d8ea3e6e99a6fc19, one signed-off commit based on upstreamd59d1664858956976a12797a8613bd4b1d803097.5.2.0-server; no driver pin. Exact checkout installed editable without dependency changes.Stack: torch/torch_musa
2.11.0.post1+musa5.2.0, torchada0.1.83, vLLM0.28.0, vllm-musa0.1.28. MUSA entrypoint imports torchada first. The current dispatch table reports a composite RMSNorm registration; using this API alone does not establish that a particular kernel is fused or faster.For MUSA, run the new test file with
-m musafrom a torchada-first entrypoint with one visible GPU.Not run: CUDA hardware, GPU backward, Inductor/graph, full MUSA MAGI-2 checkpoint/video or performance. No DiT-step improvement is claimed; this remains Draft pending review and broader integration gates.