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
a7c87168
Unverified
Commit
a7c87168
authored
Mar 16, 2024
by
Yang Fan
Committed by
GitHub
Mar 15, 2024
Browse files
Fix tie_word_embeddings for Qwen2. (#3344)
parent
429284dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
vllm/model_executor/models/qwen2.py
vllm/model_executor/models/qwen2.py
+12
-2
No files found.
vllm/model_executor/models/qwen2.py
View file @
a7c87168
...
...
@@ -299,7 +299,11 @@ class Qwen2ForCausalLM(nn.Module):
self
.
config
=
config
self
.
linear_method
=
linear_method
self
.
model
=
Qwen2Model
(
config
,
linear_method
)
self
.
lm_head
=
ParallelLMHead
(
config
.
vocab_size
,
config
.
hidden_size
)
if
not
config
.
tie_word_embeddings
:
self
.
lm_head
=
ParallelLMHead
(
config
.
vocab_size
,
config
.
hidden_size
)
self
.
sampler
=
Sampler
(
config
.
vocab_size
)
def
forward
(
...
...
@@ -318,7 +322,11 @@ class Qwen2ForCausalLM(nn.Module):
hidden_states
:
torch
.
Tensor
,
sampling_metadata
:
SamplingMetadata
,
)
->
Optional
[
SamplerOutput
]:
next_tokens
=
self
.
sampler
(
self
.
lm_head
.
weight
,
hidden_states
,
if
self
.
config
.
tie_word_embeddings
:
lm_head_weight
=
self
.
model
.
embed_tokens
.
weight
else
:
lm_head_weight
=
self
.
lm_head
.
weight
next_tokens
=
self
.
sampler
(
lm_head_weight
,
hidden_states
,
sampling_metadata
)
return
next_tokens
...
...
@@ -340,6 +348,8 @@ class Qwen2ForCausalLM(nn.Module):
model_name_or_path
,
cache_dir
,
load_format
,
revision
):
if
"rotary_emb.inv_freq"
in
name
:
continue
if
self
.
config
.
tie_word_embeddings
and
"lm_head.weight"
in
name
:
continue
for
(
param_name
,
weight_name
,
shard_id
)
in
stacked_params_mapping
:
if
weight_name
not
in
name
:
continue
...
...
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