Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tqdm when loading checkpoint shards #6569

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vllm/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ def enable_trace_function_call(log_file_path: str,
if root_dir is None:
# by default, this is the vllm root directory
root_dir = os.path.dirname(os.path.dirname(__file__))
sys.settrace(partial(_trace_calls, log_file_path, root_dir))
sys.settrace(partial(_trace_calls, log_file_path, root_dir))
3 changes: 3 additions & 0 deletions vllm/model_executor/model_loader/weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def np_cache_weights_iterator(
with get_lock(model_name_or_path, cache_dir):
if not os.path.exists(weight_names_file):
weight_names: List[str] = []
hf_weights_files = tqdm(hf_weights_files,desc="Loading np_cache checkpoint shards")
for bin_file in hf_weights_files:
state = torch.load(bin_file, map_location="cpu")
for name, param in state.items():
Expand All @@ -355,6 +356,7 @@ def safetensors_weights_iterator(
hf_weights_files: List[str]
) -> Generator[Tuple[str, torch.Tensor], None, None]:
"""Iterate over the weights in the model safetensor files."""
hf_weights_files = tqdm(hf_weights_files,desc="Loading safetensors checkpoint shards")
for st_file in hf_weights_files:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the common practice would be:

for st_file in tqdm(hf_weights_files, desc="Loading safetensors checkpoint shards"):

with safe_open(st_file, framework="pt") as f:
for name in f.keys(): # noqa: SIM118
Expand All @@ -366,6 +368,7 @@ def pt_weights_iterator(
hf_weights_files: List[str]
) -> Generator[Tuple[str, torch.Tensor], None, None]:
"""Iterate over the weights in the model bin/pt files."""
hf_weights_files = tqdm(hf_weights_files,desc="Loading pt checkpoint shards")
for bin_file in hf_weights_files:
state = torch.load(bin_file, map_location="cpu")
for name, param in state.items():
Expand Down
Loading