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
541a985f
Unverified
Commit
541a985f
authored
May 29, 2025
by
fzyzcjy
Committed by
GitHub
May 28, 2025
Browse files
Fuse routed_scaling_factor in DeepSeek (#6710)
parent
5170b010
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
python/sglang/srt/models/deepseek_v2.py
python/sglang/srt/models/deepseek_v2.py
+7
-3
No files found.
python/sglang/srt/models/deepseek_v2.py
View file @
541a985f
...
@@ -526,9 +526,13 @@ class DeepseekV2MoE(nn.Module):
...
@@ -526,9 +526,13 @@ class DeepseekV2MoE(nn.Module):
def
op_output
(
self
,
state
):
def
op_output
(
self
,
state
):
final_hidden_states
=
state
.
pop
(
"hidden_states_after_combine"
)
final_hidden_states
=
state
.
pop
(
"hidden_states_after_combine"
)
final_hidden_states
*=
self
.
routed_scaling_factor
if
(
s
:
=
state
.
pop
(
"shared_output"
))
is
not
None
:
if
(
shared_output
:
=
state
.
pop
(
"shared_output"
))
is
not
None
:
final_hidden_states
=
final_hidden_states
+
s
x
=
shared_output
x
.
add_
(
final_hidden_states
,
alpha
=
self
.
routed_scaling_factor
)
final_hidden_states
=
x
else
:
final_hidden_states
*=
self
.
routed_scaling_factor
state
.
hidden_states_mlp_output
=
final_hidden_states
state
.
hidden_states_mlp_output
=
final_hidden_states
...
...
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