perf(pd): reduce qwen3next prefill linear-att state memory - #1421
Open
sufubao wants to merge 1 commit into
Open
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
PD 分离部署下,qwen3next 的 linear-att(conv/ssm)状态缓冲按
mtp_step + 1个槽/请求分配。但 MTP verify 只在 decode 节点发生,prefill 节点只做 prefill 并把 KV 交给 decode,从不运行 verify,所以第1..mtp_step个槽在 prefill 节点对每个请求都空着。引入
get_linear_att_state_mtp_size(args):run_mode == "prefill"返回 1,其余(normal / decode)仍为mtp_step + 1。prefill 节点上:(max_req + 1) * (mtp_step + 1)→(max_req + 1) * 1,约mtp_step + 1倍缩减;(kernel - 1) + mtp_step→(kernel - 1)。normal 与 decode 路径不变。
正确性:KV 搬运页
kv_move_buffer每个请求只承载一份 ssm 状态(ssm_shape来自单个状态,与 mtp 无关);_get_req_state_indexes用 stride 只是在各自节点的 gpu ssm 缓冲里定位每个请求的第 0 行(canonical 槽)参与搬运——prefill(stride=1)与 decode(stride=mtp_step+1)取到的是同一份状态,两侧页格式一致。kernelcopy_linear_att_state_to_kv_buffer的mtp_step形参相应改为ssm_state_stride,传入实际步长。只做了 py_compile / 静态检查;E2E PD 显存实测待补。