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
d5d80ab4
Unverified
Commit
d5d80ab4
authored
Feb 21, 2025
by
chenxiaobing
Committed by
GitHub
Feb 21, 2025
Browse files
[Bugfix] Fix scores mask for moe topk (#3705)
parent
ddcf9fe3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
python/sglang/srt/layers/moe/topk.py
python/sglang/srt/layers/moe/topk.py
+3
-1
No files found.
python/sglang/srt/layers/moe/topk.py
View file @
d5d80ab4
...
...
@@ -141,7 +141,9 @@ def biased_grouped_topk(
.
expand
(
num_token
,
num_expert_group
,
scores
.
shape
[
-
1
]
//
num_expert_group
)
.
reshape
(
num_token
,
-
1
)
)
# [n, e]
tmp_scores
=
scores_for_choice
.
masked_fill
(
~
score_mask
.
bool
(),
0.0
)
# [n, e]
tmp_scores
=
scores_for_choice
.
masked_fill
(
~
score_mask
.
bool
(),
float
(
"-inf"
)
)
# [n, e]
_
,
topk_ids
=
torch
.
topk
(
tmp_scores
,
k
=
topk
,
dim
=-
1
,
sorted
=
False
)
topk_weights
=
scores
.
gather
(
1
,
topk_ids
)
...
...
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