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
c5b4b11d
Unverified
Commit
c5b4b11d
authored
Jan 23, 2025
by
Isotr0py
Committed by
GitHub
Jan 23, 2025
Browse files
[Bugfix] Fix k_proj's bias for whisper self attention (#12342)
Signed-off-by:
Isotr0py
<
2037008807@qq.com
>
parent
8ae5ff20
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
vllm/model_executor/models/whisper.py
vllm/model_executor/models/whisper.py
+18
-3
No files found.
vllm/model_executor/models/whisper.py
View file @
c5b4b11d
...
...
@@ -729,7 +729,22 @@ class WhisperForConditionalGeneration(nn.Module, SupportsMultiModal):
def
load_weights
(
self
,
weights
:
Iterable
[
Tuple
[
str
,
torch
.
Tensor
]])
->
Set
[
str
]:
loader
=
AutoWeightsLoader
(
self
,
skip_prefixes
=
[
"proj_out."
])
loaded_weights
=
[(
name
,
loaded_weight
)
for
name
,
loaded_weight
in
weights
]
mapper
=
WeightsMapper
({
".fc1."
:
".mlp.fc1."
,
".fc2."
:
".mlp.fc2."
})
return
loader
.
load_weights
(
loaded_weights
,
mapper
=
mapper
)
# add fake zeros bias for k_proj to state_dict
weights
=
_create_fake_bias_for_k_proj
(
weights
)
return
loader
.
load_weights
(
weights
,
mapper
=
mapper
)
def
_create_fake_bias_for_k_proj
(
weights
:
Iterable
[
Tuple
[
str
,
torch
.
Tensor
]]
)
->
Iterable
[
Tuple
[
str
,
torch
.
Tensor
]]:
"""
Create full zeros bias for k_proj weight in self-attention layers.
So that the bias for k_proj in qkv_proj can be initialized with zeros.
"""
for
name
,
weight
in
weights
:
if
".self_attn.k_proj.weight"
in
name
:
bias
=
torch
.
zeros
(
weight
.
size
(
0
))
bias_name
=
name
.
replace
(
"weight"
,
"bias"
)
yield
from
[(
name
,
weight
),
(
bias_name
,
bias
)]
yield
name
,
weight
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