Skip to content

Conversation

@andyxning
Copy link
Contributor

@andyxning andyxning commented Jul 29, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

currently, weights_patterns is ["*.safetensors"] and if file is model.safetensors, then ext is *.safetensors and file.endswith(ext) will be false. As *.safetensors is a pattern, then we should use fnmatch to check whether a file matches the pattern like how ignore_patterns is implemented in huggingface_cli.

Test Plan

NA

Test Result

NA

(Optional) Documentation Update

NA

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a bug where filename patterns were being checked with endswith instead of fnmatch. The change also correctly handles subdirectories by copying them. However, the new logic doesn't apply the filter patterns to directories, which could lead to incorrect behavior. I've provided a suggestion to apply patterns to both files and directories to make the implementation more robust and consistent with the behavior of similar utilities in huggingface_hub.

Comment on lines 67 to 71
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current logic correctly uses fnmatch for files, but it unconditionally copies all directories without checking them against weights_patterns. This could lead to incorrect behavior if a weight pattern is intended to match a directory, which deviates from the behavior of ignore_patterns in huggingface_hub that was referenced in the pull request description.

For example, if weights_patterns contained a pattern like "checkpoints", a directory with that name would be copied instead of being ignored.

To make the logic more robust and align with the intended behavior, I suggest checking items against weights_patterns first, regardless of whether they are files or directories. This ensures that directories matching a weight pattern are correctly skipped.

Suggested change
if os.path.isdir(os.path.join(input_dir, file)):
continue
if not any(file.endswith(ext) for ext in weights_patterns):
shutil.copy(f"{input_dir}/{file}", output_dir)
shutil.copytree(
os.path.join(input_dir, file), os.path.join(output_dir, file)
)
elif not any(fnmatch.fnmatch(file, ext) for ext in weights_patterns):
shutil.copy(os.path.join(input_dir, file), output_dir)
if any(fnmatch.fnmatch(file, ext) for ext in weights_patterns):
continue
src_path = os.path.join(input_dir, file)
if os.path.isdir(src_path):
shutil.copytree(src_path, os.path.join(output_dir, file))
else:
shutil.copy(src_path, output_dir)

@andyxning andyxning force-pushed the fix_metadata_file_copy_in_test_sharded_state_loader branch 2 times, most recently from f938118 to 8f9c472 Compare July 29, 2025 13:10
Signed-off-by: Andy Xie <andy.xning@gmail.com>
@andyxning andyxning force-pushed the fix_metadata_file_copy_in_test_sharded_state_loader branch from 8f9c472 to 51bf142 Compare July 29, 2025 13:26
continue
if not any(file.endswith(ext) for ext in weights_patterns):
shutil.copy(f"{input_dir}/{file}", output_dir)
shutil.copytree(os.path.join(input_dir, file),
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to copy directories now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be consistent with

# Copy metadata files to output directory
for file in os.listdir(model_path):
if os.path.splitext(file)[1] not in (".bin", ".pt", ".safetensors"):
if os.path.isdir(os.path.join(model_path, file)):
shutil.copytree(
os.path.join(model_path, file), os.path.join(args.output, file)
)
else:
shutil.copy(os.path.join(model_path, file), args.output)

Copy link
Collaborator

@sarckk sarckk left a comment

Choose a reason for hiding this comment

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

looks good, thanks for fixing this. cc: @DarkLight1337 @WoosukKwon

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) July 31, 2025 03:36
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 31, 2025
@DarkLight1337 DarkLight1337 merged commit 3e36fcb into vllm-project:main Jul 31, 2025
53 checks passed
liuyumoye pushed a commit to liuyumoye/vllm that referenced this pull request Jul 31, 2025
@andyxning andyxning deleted the fix_metadata_file_copy_in_test_sharded_state_loader branch July 31, 2025 08:43
vadiklyutiy pushed a commit to CentML/vllm that referenced this pull request Aug 5, 2025
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
…roject#21830)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
Signed-off-by: x22x22 <wadeking@qq.com>
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
…roject#21830)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
noamgat pushed a commit to noamgat/vllm that referenced this pull request Aug 9, 2025
…roject#21830)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
Signed-off-by: Noam Gat <noamgat@gmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
…roject#21830)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
Signed-off-by: Paul Pak <paulpak58@gmail.com>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
…roject#21830)

Signed-off-by: Andy Xie <andy.xning@gmail.com>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants