fix(deepseek): pass rms_norm_eps to MLA q/kv layernorms#44317
Closed
sxu75374 wants to merge 1 commit into
Closed
Conversation
The q_a_layernorm and kv_a_layernorm in DeepSeek V2/V3 MLA attention are constructed without passing eps, falling back to the class default (1e-6). All other RMSNorm instances in these models correctly use config.rms_norm_eps. While DeepSeek's published configs happen to use eps=1e-6 today, omitting the explicit parameter is a latent bug: any fine-tuned checkpoint or future model variant with a different rms_norm_eps would silently use the wrong epsilon, causing precision drift. Aligns transformers with vLLM and SGLang, which both pass config.rms_norm_eps explicitly. Fixes huggingface#44261 Signed-off-by: sxu75374 <imshuaixu@gmail.com>
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: deepseek_v2, deepseek_v3 |
Member
|
I'm closing this PR: It's not just you — it's me. |
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.
What does this PR do?
Passes
config.rms_norm_epsexplicitly toq_a_layernormandkv_a_layernormin both DeepSeek V2 and V3 MLA attention.Currently these two norms are constructed without
eps, falling back to theRMSNormclass default (1e-6). Every otherRMSNormin these models correctly usesconfig.rms_norm_eps.Why it matters: While DeepSeek's published configs happen to set
rms_norm_eps=1e-6, omitting the explicit parameter is a latent bug — any fine-tuned checkpoint or future variant with a different epsilon would silently use the wrong value for these two norms, causing precision drift that's extremely hard to track down.This aligns transformers with vLLM and SGLang, which both pass
config.rms_norm_epsexplicitly.Fixes #44261
Changes
modeling_deepseek_v2.py: passeps=config.rms_norm_epstoq_a_layernormandkv_a_layernormmodeling_deepseek_v3.py: same fix4 lines changed across 2 files — minimal, zero-risk.
Before submitting
No new tests — this is a parameter-passing fix. Existing model tests cover the affected code paths.
Who can review?
@ArthurZucker @Cyrilvallez