Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于deepseek中Multi Head Latent Attention 中的一些问题 #658

Open
huangjie-nlp opened this issue Feb 14, 2025 · 2 comments
Open

Comments

@huangjie-nlp
Copy link

1、为什么Query在升维后 分出需要rope位置编码部分和不需要rope编码部分,而Key是在降维后得到rope这部分?
2、为什么Value向量是kv升维后分出来的,Key和Value为什么不是独立的?

@skyduy
Copy link

skyduy commented Feb 21, 2025

1、为什么Query在升维后 分出需要rope位置编码部分和不需要rope编码部分,而Key是在降维后得到rope这部分? 2、为什么Value向量是kv升维后分出来的,Key和Value为什么不是独立的?

个人理解可能有2方面原因,不知道说得对不对:
1、成本节省方面,k的rope编码是多头共享的,这个时候输出维度只有per head dim,这种情况下即使用了kv的中间低秩结果节省量也不大。作为对比 query的rope输出不共享,要输出total head dim 节省很大
2、语义/效果方面,q的中间低秩结果仅为q自己服务;k的低秩结果是kv共享的,它俩反向传播都会影响中间低秩结果的更新,所以把仅和k相关的rope也耦合在上面可能会制约效果或训练稳定性(而kv在查询中同时发力,所以它俩中间结果耦合在一起语义上也说的通)

另外B站上有个老师讲的 MLA 很清楚

@rowstop
Copy link

rowstop commented Feb 22, 2025

🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants