Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
b5e8d01e
Commit
b5e8d01e
authored
Feb 28, 2026
by
yangql1
Browse files
修复qwen3.5的使用dtype为fp16的picecwise的推理模式
parent
2544deb6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
vllm/model_executor/layers/layernorm.py
vllm/model_executor/layers/layernorm.py
+7
-3
No files found.
vllm/model_executor/layers/layernorm.py
View file @
b5e8d01e
...
...
@@ -458,6 +458,10 @@ class RMSNormGated(CustomOp):
- norm_before_gate=True: out = norm(x) * silu(z)
- norm_before_gate=False: out = norm(x * silu(z))
"""
orig_dtype
=
x
.
dtype
x
=
x
.
float
()
weight
=
self
.
weight
.
float
()
z
=
z
.
float
()
if
z
is
not
None
else
None
# Apply gating before normalization if needed
if
z
is
not
None
and
not
self
.
norm_before_gate
:
x
=
x
*
F
.
silu
(
z
)
...
...
@@ -467,7 +471,7 @@ class RMSNormGated(CustomOp):
# Standard RMS norm across the last dimension
variance
=
x
.
pow
(
2
).
mean
(
dim
=-
1
,
keepdim
=
True
)
x_normed
=
x
*
torch
.
rsqrt
(
variance
+
self
.
eps
)
out
=
x_normed
*
self
.
weight
out
=
x_normed
*
weight
else
:
# Group RMS norm
from
einops
import
rearrange
...
...
@@ -475,13 +479,13 @@ class RMSNormGated(CustomOp):
x_group
=
rearrange
(
x
,
"... (g d) -> ... g d"
,
d
=
self
.
group_size
)
variance
=
x_group
.
pow
(
2
).
mean
(
dim
=-
1
,
keepdim
=
True
)
x_normed
=
x_group
*
torch
.
rsqrt
(
variance
+
self
.
eps
)
out
=
rearrange
(
x_normed
,
"... g d -> ... (g d)"
)
*
self
.
weight
out
=
rearrange
(
x_normed
,
"... g d -> ... (g d)"
)
*
weight
# Apply gating after normalization if needed
if
z
is
not
None
and
self
.
norm_before_gate
:
out
=
out
*
F
.
silu
(
z
)
return
out
return
out
.
to
(
orig_dtype
)
def
forward_cuda
(
self
,
x
:
torch
.
Tensor
,
z
:
torch
.
Tensor
|
None
=
None
...
...
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