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
ec7da6fc
Unverified
Commit
ec7da6fc
authored
Apr 09, 2025
by
Lucia Fang
Committed by
GitHub
Apr 09, 2025
Browse files
[BugFix] llama4 qknorm should be not shared across head (#16311)
Signed-off-by:
Lu Fang
<
fanglu@fb.com
>
parent
819d548e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
vllm/model_executor/models/llama4.py
vllm/model_executor/models/llama4.py
+7
-12
No files found.
vllm/model_executor/models/llama4.py
View file @
ec7da6fc
...
...
@@ -155,14 +155,8 @@ class Llama4Attention(nn.Module):
self
.
rope_theta
=
rope_theta
self
.
max_position_embeddings
=
max_position_embeddings
self
.
n_rep
=
self
.
num_heads
//
self
.
num_kv_heads
self
.
q_norm
=
RMSNorm
(
hidden_size
=
self
.
q_size
,
eps
=
config
.
rms_norm_eps
,
has_weight
=
False
,
dtype
=
torch
.
float32
,
)
if
self
.
use_qk_norm
else
None
self
.
k_norm
=
RMSNorm
(
hidden_size
=
self
.
kv_size
,
self
.
qk_norm
=
RMSNorm
(
hidden_size
=
self
.
head_dim
,
eps
=
config
.
rms_norm_eps
,
has_weight
=
False
,
dtype
=
torch
.
float32
,
...
...
@@ -226,10 +220,11 @@ class Llama4Attention(nn.Module):
if
self
.
rotary_emb
is
not
None
:
q
,
k
=
self
.
rotary_emb
(
positions
,
q
,
k
)
if
self
.
q_norm
is
not
None
:
q
=
self
.
q_norm
(
q
.
float
()).
to
(
q
.
dtype
)
if
self
.
k_norm
is
not
None
:
k
=
self
.
k_norm
(
k
.
float
()).
to
(
k
.
dtype
)
if
self
.
qk_norm
is
not
None
:
q
=
q
.
reshape
(
-
1
,
self
.
num_heads
,
self
.
head_dim
)
q
=
self
.
qk_norm
(
q
.
float
()).
reshape
(
-
1
,
self
.
q_size
).
to
(
q
.
dtype
)
k
=
k
.
reshape
(
-
1
,
self
.
num_kv_heads
,
self
.
head_dim
)
k
=
self
.
qk_norm
(
k
.
float
()).
reshape
(
-
1
,
self
.
kv_size
).
to
(
k
.
dtype
)
# We are applying temperature tuning (https://arxiv.org/abs/2501.19399)
# to NoPE layers, where the inference-time temperature tuning function
...
...
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