Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
c3948ba6
Unverified
Commit
c3948ba6
authored
Apr 26, 2025
by
Ke Bao
Committed by
GitHub
Apr 25, 2025
Browse files
Reorder loop in shared expert weight loading (#5719)
parent
269c457e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
python/sglang/srt/models/deepseek_nextn.py
python/sglang/srt/models/deepseek_nextn.py
+6
-6
python/sglang/srt/models/deepseek_v2.py
python/sglang/srt/models/deepseek_v2.py
+6
-6
No files found.
python/sglang/srt/models/deepseek_nextn.py
View file @
c3948ba6
...
...
@@ -215,11 +215,11 @@ class DeepseekV3ForCausalLMNextN(DeepseekV3ForCausalLM):
"up_proj.weight_scale_inv"
,
]
names_to_remove
=
[]
for
num_repeat
in
range
(
self
.
n_share_experts_fusion
)
:
for
suffix
in
suffix_list
:
shared_expert_weight_name
=
(
f
"model.layers.0.mlp.shared_experts.
{
suffix
}
"
)
for
suffix
in
suffix_list
:
shared_expert_weight_name
=
(
f
"model.layers.0.mlp.shared_experts.
{
suffix
}
"
)
for
num_repeat
in
range
(
self
.
n_share_experts_fusion
):
weights_list
.
append
(
(
f
"model.layers.0."
...
...
@@ -229,7 +229,7 @@ class DeepseekV3ForCausalLMNextN(DeepseekV3ForCausalLM):
weights_dict
[
shared_expert_weight_name
],
)
)
names_to_remove
+=
[
shared_expert_weight_name
]
names_to_remove
+=
[
shared_expert_weight_name
]
weights
=
[
w
for
w
in
weights_list
if
w
[
0
]
not
in
names_to_remove
]
# Params for weights, fp8 weight scales, fp8 activation scales
...
...
python/sglang/srt/models/deepseek_v2.py
View file @
c3948ba6
...
...
@@ -1650,11 +1650,11 @@ class DeepseekV2ForCausalLM(nn.Module):
desc
=
f
"Cloning
{
self
.
n_share_experts_fusion
}
"
"replicas of the shared expert into MoE"
,
):
for
num_repeat
in
range
(
self
.
n_share_experts_fusion
)
:
for
suffix
in
suffix_list
:
shared_expert_weight_name
=
(
f
"model.layers.
{
moe_layer
}
.mlp.shared_experts.
{
suffix
}
"
)
for
suffix
in
suffix_list
:
shared_expert_weight_name
=
(
f
"model.layers.
{
moe_layer
}
.mlp.shared_experts.
{
suffix
}
"
)
for
num_repeat
in
range
(
self
.
n_share_experts_fusion
):
weights_list
.
append
(
(
f
"model.layers.
{
moe_layer
}
."
...
...
@@ -1664,7 +1664,7 @@ class DeepseekV2ForCausalLM(nn.Module):
weights_dict
[
shared_expert_weight_name
],
)
)
names_to_remove
+=
[
shared_expert_weight_name
]
names_to_remove
+=
[
shared_expert_weight_name
]
weights
=
[
w
for
w
in
weights_list
if
w
[
0
]
not
in
names_to_remove
]
# Params for weights, fp8 weight scales, fp8 activation scales
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment