[GH-ISSUE #23] Failure to reproduce MLA > MHA #22

Closed
opened 2026-10-26 21:06:53 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @faresobeid on GitHub (May 12, 2024).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-V2/issues/23

I tried out MLA and it was a good amount worse than MHA and wanted to try to find out why. Firstly, I am using a hybrid model therefore I am not using any Rope in either MLA or MHA, and therefore use the basic version of MLA. I suspect the issue could be due to the part saying:
"In addition, the low-rank compression and fine-grained expert segmentation
will impact the output scale of a layer. Therefore, in practice, we employ additional RMS Norm
layers after the compressed latent vectors, and multiply additional scaling factors at the width
bottlenecks (i.e., the compressed latent vectors and the intermediate hidden states of routed experts) to ensure stable training."
It is unclear if the additional scaling factor is done before or after the RMSNorm, also what this factor would be. Another reason could be that the rope version of MLA gives it a performance boost.

Any clarification on this scaling factor and its placement would be great, thanks!

Originally created by @faresobeid on GitHub (May 12, 2024). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-V2/issues/23 I tried out MLA and it was a good amount worse than MHA and wanted to try to find out why. Firstly, I am using a hybrid model therefore I am not using any Rope in either MLA or MHA, and therefore use the basic version of MLA. I suspect the issue could be due to the part saying: "In addition, the low-rank compression and fine-grained expert segmentation will impact the output scale of a layer. Therefore, in practice, we employ additional RMS Norm layers after the compressed latent vectors, and multiply additional scaling factors at the width bottlenecks (i.e., the compressed latent vectors and the intermediate hidden states of routed experts) to ensure stable training." It is unclear if the additional scaling factor is done before or after the RMSNorm, also what this factor would be. Another reason could be that the rope version of MLA gives it a performance boost. Any clarification on this scaling factor and its placement would be great, thanks!
Author
Owner

@luofuli commented on GitHub (May 14, 2024):

The following are factors that affect the final result:

  1. Rope positional embedding
  2. Scaling factors (you can check the open-source checkpoint)

@faresobeid

<!-- gh-comment-id:2109302753 --> @luofuli commented on GitHub (May 14, 2024): The following are factors that affect the final result: 1. Rope positional embedding 2. Scaling factors (you can check the open-source checkpoint) @faresobeid
Author
Owner

@faresobeid commented on GitHub (May 14, 2024):

Thank you!

<!-- gh-comment-id:2110338068 --> @faresobeid commented on GitHub (May 14, 2024): Thank you!
Author
Owner

@faresobeid commented on GitHub (May 23, 2024):

Sorry to reopen this issue but I have been having some issues with stability at scale with MLA. Like I said before I am using a hybrid model and therefore the MLA that I am using is the basic version with no Rope.

kv = W_b(rms_norm(W_a(x)))
I have also tried having

kv = W_b(rms_norm(W_a(ln(x))))
but that also has some issues with performance and stability. To be more specific, this is a 24 layer model with model dimension 2048 with the last third of layers using MLA (~300M params). Is there any recommended scaling factors or ways to mitigate this issue? Thank you

<!-- gh-comment-id:2126940356 --> @faresobeid commented on GitHub (May 23, 2024): Sorry to reopen this issue but I have been having some issues with stability at scale with MLA. Like I said before I am using a hybrid model and therefore the MLA that I am using is the basic version with no Rope. ` kv = W_b(rms_norm(W_a(x))) ` I have also tried having ` kv = W_b(rms_norm(W_a(ln(x)))) ` but that also has some issues with performance and stability. To be more specific, this is a 24 layer model with model dimension 2048 with the last third of layers using MLA (~300M params). Is there any recommended scaling factors or ways to mitigate this issue? Thank you
Author
Owner

@luofuli commented on GitHub (May 27, 2024):

24-layer dense model? @faresobeid

<!-- gh-comment-id:2133246120 --> @luofuli commented on GitHub (May 27, 2024): 24-layer dense model? @faresobeid
Author
Owner

@faresobeid commented on GitHub (May 27, 2024):

Yes, although stability has been fine without the inner rms norm but still any recommendations would be helpful

<!-- gh-comment-id:2133249022 --> @faresobeid commented on GitHub (May 27, 2024): Yes, although stability has been fine without the inner rms norm but still any recommendations would be helpful
Author
Owner

@LPeng625 commented on GitHub (Mar 3, 2025):

矩阵吸收的计算量反而比正常计算(不使用矩阵结合律)高?代码中的MLA似乎并没有使用矩阵吸收,请问是有什么特殊的考虑吗?

<!-- gh-comment-id:2694562011 --> @LPeng625 commented on GitHub (Mar 3, 2025): 矩阵吸收的计算量反而比正常计算(不使用矩阵结合律)高?代码中的MLA似乎并没有使用矩阵吸收,请问是有什么特殊的考虑吗?
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-V2#22
No description provided.