Add Liger Kernel support for Muse Glimmer - #1390
Conversation
|
@vaibhavjindal FYI, thanks! |
|
@buffett0323 Interesting work. I am wondering if Liger kernel works out of the box for Muse Glimmer? Are you testing both Triton backend and CuteDSL backend? |
|
Thanks for your interest @PKUWZP
No, the softcap form, the scale-free RMSNorms, and the Gemma-style hidden_activation field each break a different part of the generic path. Also, this PR needs no backend-specific code and is on the same footing as Llama/Qwen w.r.t. CuTe DSL, but I'm happy to follow up with a B200 run to confirm the SM100 path is green or a PR adding the Triton fallback plus a model-level test under a non-default |
That makes sense. I think a B200 run would be interesting. We should merge this PR shortly after that. |
|
Hi @PKUWZP ,
Muse totals 8 passed / 6 failed, and every one of the 6 raises the same error: Muse Glimmer needs no backend-specific code and behaves the same to Llama/Qwen on both. I'm happy to open a separate PR adding the Triton fallback for the unsupported hardware/dtype cases, plus a model-level test under a non-default C.C. @vaibhavjindal , how do you think about this? Thanks!! |
This is awesome, great work! Yep, it would be great if we can have a separate PR adding the Triton fallback path. Muse Glimmer is a high profile open model, so supporting it is a big deal. |
Summary
Adds Liger Kernel support for Muse Glimmer (
model_type=muse_glimmer), covering both capabilities requested in #1378:[B, S, V]logits tensor (Muse Glimmer'svocab_sizeis 202,048)return_token_accuracy=True→outputs.token_accuracy, so TRL'sSFTTrainercan logmean_token_accuracywithout a trainer-side fallbackRegistered in
MODEL_TYPE_TO_APPLY_LIGER_FN, souse_liger_kernel=Truepicks it up. Patches RoPE, RMSNorm, SwiGLU, vision LayerNorm (instance path only), CrossEntropy and FusedLinearCrossEntropy.Details
Softcap. HF computes
T * tanh(logits * m / T)wherem = output_multiplierandT = final_logit_softcapping, but Liger's fused softcap only implementsT * tanh(logits / T).mis folded into the hidden states instead, since(m * h) @ W.T == m * (h @ W.T)— scaling[batch, seq, hidden]rather than[vocab, hidden].Two RMSNorm variants.
MuseGlimmerRMSNormscales byweightdirectly (gemma-style fp32 compute, offset 0);MuseGlimmerTextCenteredRMSNormscales by(1 + weight)from zero-init (offset 1). Thewith_scale=Falseinstances,qk_norm,embed_norm,perception_emb_norm, have no weight parameter and fall back to a torch implementation matching HF exactly; an assert guards against that fallback silently dropping a scale.in_place=Falseon the TextCentered norms is required, not conservative: each decoder layer handspre_feedforward_layernormthe same tensor it retains as the residual.Note that
token_accuracyis populated on the fused path only; withskip_logits=False(eval) it staysNone, matching existing patched models such as Qwen3.Testing Done
test/transformers/test_muse_glimmer.py(new) — instance-path numerical parity against the unpatched model: loss plus embedding / SwiGLU / RMSNorm gradients in fp32 and bf16, the non-fused softcap branch, vision LayerNorm, and thetoken_accuracy/predicted_tokenscontract. The convergence suite patches at module level, so this is what covers_apply_liger_kernel_to_instance— the path TRL actually takes.test/transformers/test_monkey_patch.py— instance patchingtest_mini_models,test_mini_models_multimodal,test_mini_models_with_logitsMemory
H100, bf16, forward + backward, no optimizer step. Randomly initialised (no public checkpoint), real
hidden_size=6656/vocab_size=202048,num_hidden_layersreduced from 52 so a 30B-class model fits on one GPU.The crossover sits near 3K: FLCE accumulates
grad_weightin fp32, a fixed 5.4 GB for[202048, 6656]against bf16's 2.7 GB. Below ~3K that outweighs the logits it avoids; above it the saving compounds, and 16K only runs at all with Liger.Throughput
FLCE trades speed for memory by design. End to end that penalty is diluted by the transformer body, and the reduced depth above overstates it:
lm_head shareis measured from the model's parameter split, which tracks the matmul FLOP split. The shipping model's 52 layers put it at ~5%, below the last row here.make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence