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
1937e298
Unverified
Commit
1937e298
authored
May 20, 2024
by
Aurick Qiao
Committed by
GitHub
May 20, 2024
Browse files
[Core] Sharded State Loader download from HF (#4889)
parent
f0eecee6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
vllm/model_executor/model_loader/loader.py
vllm/model_executor/model_loader/loader.py
+15
-1
No files found.
vllm/model_executor/model_loader/loader.py
View file @
1937e298
...
...
@@ -423,6 +423,16 @@ class ShardedStateLoader(BaseModelLoader):
result
[
k
]
=
t
return
result
def
_prepare_weights
(
self
,
model_name_or_path
:
str
,
revision
:
Optional
[
str
]):
if
os
.
path
.
isdir
(
model_name_or_path
):
return
model_name_or_path
else
:
allow_patterns
=
[
"*.safetensors"
]
return
download_weights_from_hf
(
model_name_or_path
,
self
.
load_config
.
download_dir
,
allow_patterns
,
revision
)
def
load_model
(
self
,
*
,
model_config
:
ModelConfig
,
device_config
:
DeviceConfig
,
lora_config
:
Optional
[
LoRAConfig
],
...
...
@@ -433,6 +443,10 @@ class ShardedStateLoader(BaseModelLoader):
from
safetensors.torch
import
safe_open
from
vllm.distributed
import
get_tensor_model_parallel_rank
local_model_path
=
self
.
_prepare_weights
(
model_config
.
model
,
model_config
.
revision
)
with
set_default_torch_dtype
(
model_config
.
dtype
):
with
torch
.
device
(
device_config
.
device
):
model
=
_initialize_model
(
model_config
,
self
.
load_config
,
...
...
@@ -440,7 +454,7 @@ class ShardedStateLoader(BaseModelLoader):
cache_config
)
rank
=
get_tensor_model_parallel_rank
()
pattern
=
os
.
path
.
join
(
model_config
.
model
,
local_model_path
,
self
.
pattern
.
format
(
rank
=
rank
,
part
=
"*"
),
)
filepaths
=
glob
.
glob
(
pattern
)
...
...
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