Skip to content

[Fix] weights update for deepseek when enabling cuda graph #4961

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions python/sglang/srt/models/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,8 +1472,14 @@ def load_weights(self, weights: Iterable[Tuple[str, torch.Tensor]]):
w_kc, w_vc = w.unflatten(
0, (-1, self_attn.qk_nope_head_dim + self_attn.v_head_dim)
).split([self_attn.qk_nope_head_dim, self_attn.v_head_dim], dim=1)
self_attn.w_kc = w_kc.transpose(1, 2).contiguous().transpose(1, 2)
self_attn.w_vc = w_vc.contiguous().transpose(1, 2)
self_attn_w_kc = w_kc.transpose(1, 2).contiguous().transpose(1, 2)
self_attn_w_vc = w_vc.contiguous().transpose(1, 2)
if self_attn.w_kc is not None:
self_attn.w_kc.copy_(self_attn_w_kc)
self_attn.w_vc.copy_(self_attn_w_vc)
else:
self_attn.w_kc = self_attn_w_kc
self_attn.w_vc = self_attn_w_vc
if (
hasattr(self_attn.kv_b_proj, "weight_scale")
and self_attn.w_scale is None
Expand Down
Loading