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
88f484ce
Unverified
Commit
88f484ce
authored
Jul 02, 2025
by
Baizhou Zhang
Committed by
GitHub
Jul 02, 2025
Browse files
Apply dsv3 router gemm kernel for deepseek-r1 fp4 (#7677)
parent
8e03b641
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
python/sglang/srt/models/deepseek_v2.py
python/sglang/srt/models/deepseek_v2.py
+21
-3
No files found.
python/sglang/srt/models/deepseek_v2.py
View file @
88f484ce
...
...
@@ -111,9 +111,16 @@ _is_fp8_fnuz = is_fp8_fnuz()
_use_aiter
=
get_bool_env_var
(
"SGLANG_USE_AITER"
)
and
_is_hip
_is_cpu_amx_available
=
cpu_has_amx_support
()
_is_cpu
=
is_cpu
()
_device_sm
=
get_device_sm
()
if
_is_cuda
:
from
sgl_kernel
import
awq_dequantize
,
bmm_fp8
,
dsv3_fused_a_gemm
,
merge_state_v2
from
sgl_kernel
import
(
awq_dequantize
,
bmm_fp8
,
dsv3_fused_a_gemm
,
dsv3_router_gemm
,
merge_state_v2
,
)
elif
_is_cpu
and
_is_cpu_amx_available
:
pass
else
:
...
...
@@ -225,7 +232,18 @@ class MoEGate(nn.Module):
True
,
# is_vnni
)
logits
=
F
.
linear
(
hidden_states
,
self
.
weight
,
None
)
if
(
hidden_states
.
shape
[
0
]
<
4
and
hidden_states
.
shape
[
1
]
==
7168
and
self
.
weight
.
shape
[
0
]
==
256
and
_device_sm
>=
90
):
logits
=
dsv3_router_gemm
(
hidden_states
,
self
.
weight
).
to
(
hidden_states
.
dtype
)
else
:
logits
=
F
.
linear
(
hidden_states
,
self
.
weight
,
None
)
return
logits
...
...
@@ -882,7 +900,7 @@ class DeepseekV2AttentionMLA(nn.Module):
and
self
.
fused_qkv_a_proj_with_mqa
.
weight
.
shape
[
0
]
==
2112
and
self
.
fused_qkv_a_proj_with_mqa
.
weight
.
shape
[
1
]
==
7168
and
is_cuda
and
get
_device_sm
()
>=
90
and
_device_sm
>=
90
)
self
.
qkv_proj_with_rope_is_int8
=
(
...
...
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