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
d3d6bb13
Unverified
Commit
d3d6bb13
authored
Jan 23, 2025
by
Russell Bryant
Committed by
GitHub
Jan 24, 2025
Browse files
Set weights_only=True when using torch.load() (#12366)
Signed-off-by:
Russell Bryant
<
rbryant@redhat.com
>
parent
24b0205f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
6 deletions
+10
-6
vllm/assets/image.py
vllm/assets/image.py
+1
-1
vllm/lora/models.py
vllm/lora/models.py
+2
-1
vllm/model_executor/model_loader/weight_utils.py
vllm/model_executor/model_loader/weight_utils.py
+5
-3
vllm/prompt_adapter/utils.py
vllm/prompt_adapter/utils.py
+2
-1
No files found.
vllm/assets/image.py
View file @
d3d6bb13
...
...
@@ -26,4 +26,4 @@ class ImageAsset:
"""
image_path
=
get_vllm_public_assets
(
filename
=
f
"
{
self
.
name
}
.pt"
,
s3_prefix
=
VLM_IMAGES_DIR
)
return
torch
.
load
(
image_path
,
map_location
=
"cpu"
)
return
torch
.
load
(
image_path
,
map_location
=
"cpu"
,
weights_only
=
True
)
vllm/lora/models.py
View file @
d3d6bb13
...
...
@@ -273,7 +273,8 @@ class LoRAModel(AdapterModel):
new_embeddings_tensor_path
)
elif
os
.
path
.
isfile
(
new_embeddings_bin_file_path
):
embeddings
=
torch
.
load
(
new_embeddings_bin_file_path
,
map_location
=
device
)
map_location
=
device
,
weights_only
=
True
)
return
cls
.
from_lora_tensors
(
lora_model_id
=
get_lora_id
()
...
...
vllm/model_executor/model_loader/weight_utils.py
View file @
d3d6bb13
...
...
@@ -93,7 +93,7 @@ def convert_bin_to_safetensor_file(
pt_filename
:
str
,
sf_filename
:
str
,
)
->
None
:
loaded
=
torch
.
load
(
pt_filename
,
map_location
=
"cpu"
)
loaded
=
torch
.
load
(
pt_filename
,
map_location
=
"cpu"
,
weights_only
=
True
)
if
"state_dict"
in
loaded
:
loaded
=
loaded
[
"state_dict"
]
shared
=
_shared_pointers
(
loaded
)
...
...
@@ -381,7 +381,9 @@ def np_cache_weights_iterator(
disable
=
not
enable_tqdm
,
bar_format
=
_BAR_FORMAT
,
):
state
=
torch
.
load
(
bin_file
,
map_location
=
"cpu"
)
state
=
torch
.
load
(
bin_file
,
map_location
=
"cpu"
,
weights_only
=
True
)
for
name
,
param
in
state
.
items
():
param_path
=
os
.
path
.
join
(
np_folder
,
name
)
with
open
(
param_path
,
"wb"
)
as
f
:
...
...
@@ -447,7 +449,7 @@ def pt_weights_iterator(
disable
=
not
enable_tqdm
,
bar_format
=
_BAR_FORMAT
,
):
state
=
torch
.
load
(
bin_file
,
map_location
=
"cpu"
)
state
=
torch
.
load
(
bin_file
,
map_location
=
"cpu"
,
weights_only
=
True
)
yield
from
state
.
items
()
del
state
torch
.
cuda
.
empty_cache
()
...
...
vllm/prompt_adapter/utils.py
View file @
d3d6bb13
...
...
@@ -89,6 +89,7 @@ def load_peft_weights(model_id: str,
adapters_weights
=
safe_load_file
(
filename
,
device
=
device
)
else
:
adapters_weights
=
torch
.
load
(
filename
,
map_location
=
torch
.
device
(
device
))
map_location
=
torch
.
device
(
device
),
weights_only
=
True
)
return
adapters_weights
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