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
6b0aeb58
Unverified
Commit
6b0aeb58
authored
Feb 19, 2025
by
Cheng Wan
Committed by
GitHub
Feb 20, 2025
Browse files
[moe] optim: reduce memory consumption in fused_moe (#3692)
parent
bb3e5268
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
+6
-5
No files found.
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
View file @
6b0aeb58
...
...
@@ -933,20 +933,21 @@ def fused_experts_impl(
config
=
get_config_func
(
M
)
intermediate_
cache
1
=
torch
.
empty
(
(
M
,
topk_ids
.
shape
[
1
]
,
N
),
cache
=
torch
.
empty
(
M
*
topk_ids
.
shape
[
1
]
*
max
(
N
,
w2
.
shape
[
1
]
),
device
=
hidden_states
.
device
,
dtype
=
hidden_states
.
dtype
,
)
intermediate_cache1
=
cache
[:
M
*
topk_ids
.
shape
[
1
]
*
N
].
view
(
(
M
,
topk_ids
.
shape
[
1
],
N
),
)
intermediate_cache2
=
torch
.
empty
(
(
M
*
topk_ids
.
shape
[
1
],
N
//
2
),
device
=
hidden_states
.
device
,
dtype
=
hidden_states
.
dtype
,
)
intermediate_cache3
=
torch
.
empty
(
intermediate_cache3
=
cache
[:
M
*
topk_ids
.
shape
[
1
]
*
w2
.
shape
[
1
]].
view
(
(
M
,
topk_ids
.
shape
[
1
],
w2
.
shape
[
1
]),
device
=
hidden_states
.
device
,
dtype
=
hidden_states
.
dtype
,
)
compute_type
=
tl
.
bfloat16
if
hidden_states
.
dtype
==
torch
.
bfloat16
else
tl
.
float16
...
...
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