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
21313e09
"docs/vscode:/vscode.git/clone" did not exist on "755b85359be910fabe39a75299439fc11beb57d4"
Unverified
Commit
21313e09
authored
Aug 15, 2024
by
Michael Goin
Committed by
GitHub
Aug 15, 2024
Browse files
[Bugfix] Fix default weight loading for scalars (#7534)
parent
f4da5f7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
vllm/model_executor/model_loader/weight_utils.py
vllm/model_executor/model_loader/weight_utils.py
+11
-5
No files found.
vllm/model_executor/model_loader/weight_utils.py
View file @
21313e09
...
...
@@ -516,11 +516,17 @@ def default_weight_loader(param: torch.Tensor,
loaded_weight
:
torch
.
Tensor
)
->
None
:
"""Default weight loader."""
try
:
assert
param
.
size
()
==
loaded_weight
.
size
(),
(
f
"Attempted to load weight (
{
loaded_weight
.
size
()
}
) "
f
"into parameter (
{
param
.
size
()
}
)"
)
param
.
data
.
copy_
(
loaded_weight
)
if
param
.
numel
()
==
1
and
loaded_weight
.
numel
()
==
1
:
# Sometimes scalar values aren't considered tensors with shapes
# so if both param and loaded_weight are a scalar,
# "broadcast" instead of copy
param
.
data
.
fill_
(
loaded_weight
.
item
())
else
:
assert
param
.
size
()
==
loaded_weight
.
size
(),
(
f
"Attempted to load weight (
{
loaded_weight
.
size
()
}
) "
f
"into parameter (
{
param
.
size
()
}
)"
)
param
.
data
.
copy_
(
loaded_weight
)
except
Exception
:
# NOTE: This exception is added for the purpose of setting breakpoint to
# debug weight loading issues.
...
...
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