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
71d1785f
Unverified
Commit
71d1785f
authored
Apr 23, 2025
by
fzyzcjy
Committed by
GitHub
Apr 22, 2025
Browse files
Remove unnecessary `torch.full` in DeepSeek (#5601)
parent
3f87f831
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
python/sglang/srt/models/deepseek_v2.py
python/sglang/srt/models/deepseek_v2.py
+7
-6
No files found.
python/sglang/srt/models/deepseek_v2.py
View file @
71d1785f
...
@@ -323,12 +323,6 @@ class DeepseekV2MoE(nn.Module):
...
@@ -323,12 +323,6 @@ class DeepseekV2MoE(nn.Module):
self
,
hidden_states
:
torch
.
Tensor
,
forward_mode
:
ForwardMode
self
,
hidden_states
:
torch
.
Tensor
,
forward_mode
:
ForwardMode
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
shared_output
=
None
shared_output
=
None
topk_idx
=
torch
.
full
(
(
0
,
self
.
top_k
),
-
1
,
dtype
=
torch
.
int
,
device
=
hidden_states
.
device
)
topk_weights
=
torch
.
empty
(
(
0
,
self
.
top_k
),
dtype
=
torch
.
float32
,
device
=
hidden_states
.
device
)
if
(
if
(
forward_mode
is
not
None
forward_mode
is
not
None
and
not
forward_mode
.
is_idle
()
and
not
forward_mode
.
is_idle
()
...
@@ -348,6 +342,13 @@ class DeepseekV2MoE(nn.Module):
...
@@ -348,6 +342,13 @@ class DeepseekV2MoE(nn.Module):
correction_bias
=
self
.
correction_bias
,
correction_bias
=
self
.
correction_bias
,
routed_scaling_factor
=
self
.
routed_scaling_factor
,
routed_scaling_factor
=
self
.
routed_scaling_factor
,
)
)
else
:
topk_idx
=
torch
.
full
(
(
0
,
self
.
top_k
),
-
1
,
dtype
=
torch
.
int
,
device
=
hidden_states
.
device
)
topk_weights
=
torch
.
empty
(
(
0
,
self
.
top_k
),
dtype
=
torch
.
float32
,
device
=
hidden_states
.
device
)
if
self
.
ep_size
>
1
:
if
self
.
ep_size
>
1
:
# TODO(ch-wan): allow users to set num_max_dispatch_tokens_per_rank value
# TODO(ch-wan): allow users to set num_max_dispatch_tokens_per_rank value
(
(
...
...
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