Skip to content

[Frontend] [Core] Integrate Tensorizer in to S3 loading machinery, allow passing arbitrary arguments during save/load #19619

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

Merged
merged 23 commits into from
Jul 8, 2025

Conversation

sangstar
Copy link
Collaborator

@sangstar sangstar commented Jun 13, 2025

Tensorizer and S3Model loading integrated, updated tensorizer==2.10.1, support passing all TensorSerializer and TensorDeserializer params

Supersedes the closed #19616 with fixed signed-off commits.

This PR does the following:

  • Integrates Tensorizer loading in to the S3Model machinery. It now seamlessly can be used with it to load all non-tensor model artifacts.
  • Consequently, Tensorizer now, when serializing, will not only serialize model tensors, but all model artifacts needed to run a model on vLLM, relying on huggingface_hub's snapshot_download.
  • This means that when loading with Tensorizer, it is no longer necessary to provide Tensorizer args with --model-loader-extra-config. Providing an S3 directory in the model tag will allow Tensorizer to resolve everything as long as all model artifacts for served_model_name are in the aforementioned directory, and Tensorizer can authenticate to S3 (which is does so with the usual boto3-style AWS environment variables, the s3cmd-style environment variables, an ~/.s3cfg file, or the ~/.aws/ config and credential files on one's home path. For example, after serializing a model with Tensorizer, this now works:
vllm serve s3://my-bucket/vllm/facebook/opt-125m/v1 --load-format=tensorizer
  • Original functionality with specifying --model-loader-extra is still supported, and can accept additional nested serialization_kwargs and deserialization_kwargs JSONs, which allow configuring TensorDeserializer and TensorSerializer with arbitrary parameters (as long as they do not conflict with vLLM)
  • Updated vLLM's tensorizer version to ==2.10.0. This version comes with the boto3-style credential support.
  • Additionally fixes the regex when parsing --model-loader-extra-config to respect newlines.

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.

🚀

@mergify mergify bot added documentation Improvements or additions to documentation ci/build llama Related to Llama models v1 labels Jun 13, 2025
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.

Summary of Changes

Hello @sangstar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the integration of Tensorizer within vLLM, particularly for S3-based workflows. It simplifies the loading process by allowing users to specify an S3 directory directly as the model path, while also making the serialization process more complete by including non-tensor model artifacts. Additionally, it provides greater flexibility by enabling the passing of arbitrary Tensorizer arguments during both serialization and deserialization.

Highlights

  • Seamless S3 Loading: Tensorizer loading is now integrated with the S3Model machinery. Users can simply provide an S3 directory containing the tensorized model and other artifacts (like config, tokenizer files) as the model tag, and vLLM will automatically load it using Tensorizer, without needing the --model-loader-extra-config flag for basic loading.
  • Comprehensive Serialization: When serializing a vLLM model with Tensorizer, the process now automatically includes all necessary model artifacts (config, tokenizer files, etc.) from the original Hugging Face model using huggingface_hub.snapshot_download, in addition to the model tensors. This ensures the serialized output is a complete package ready for deployment.
  • Arbitrary Tensorizer Args: The --model-loader-extra-config flag now supports passing arbitrary keyword arguments to Tensorizer's TensorSerializer and TensorDeserializer via nested serialization_kwargs and deserialization_kwargs JSON objects. This allows fine-grained control over Tensorizer's behavior during save and load.
  • Tensorizer Version Update: The required Tensorizer version has been updated to 2.10.0, which includes improvements like boto3-style credential support.
  • Improved Config Parsing: The regex used to parse the --model-loader-extra-config JSON string has been fixed to correctly handle newlines and leading/trailing whitespace.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 significantly enhances Tensorizer integration within vLLM. Key improvements include:

  • Simplified S3 Loading: Models can now be loaded from S3 by specifying the directory containing all artifacts (including model.tensors, config.json, tokenizer files, etc.). Tensorizer will automatically download necessary non-tensor files using huggingface_hub.snapshot_download during serialization, making the loading process seamless.
  • Arbitrary Argument Passing: Users can now pass arbitrary keyword arguments to TensorSerializer and TensorDeserializer during save and load operations via serialization_kwargs and deserialization_kwargs in TensorizerConfig or through the example script.
  • Tensorizer Version Update: The tensorizer dependency is updated to 2.10.0, which includes boto3-style S3 credential support.
  • Improved CLI Argument Parsing: The regex for parsing JSON in CLI arguments now correctly handles newlines.
  • Refactored Configuration: TensorizerConfig and TensorizerArgs have been refactored for better clarity and flexibility.

The changes are well-tested, including new end-to-end tests for serialization and serving. The example script tensorize_vllm_model.py has been updated to reflect these new capabilities.

One area for minor improvement could be updating the docstring of the example script to more prominently feature the new S3 directory loading mechanism.

@sangstar sangstar changed the title [Frontend] [Core] Integrate Tensorizer in to extant S3 loading machinery, allow passing arbitrary arguments during save/load [Frontend] [Core] Integrate Tensorizer in to S3 loading machinery, allow passing arbitrary arguments during save/load Jun 13, 2025
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

LGTM. Can we deprecate the previous model-load-extra field?

I think we ought to have a model-loader-config fwiw and maybe follow similar spec as speculative-config

cc @hmellor the config change

@sangstar
Copy link
Collaborator Author

sangstar commented Jun 17, 2025

Made some small extra tweaks; fast check tests passing!

@sangstar
Copy link
Collaborator Author

Gentle pokes for visibility! Anything else I can address for y'all? @jeejeelee @aarnphm @ywang96

@sangstar sangstar requested a review from aarnphm July 1, 2025 14:58
@sangstar
Copy link
Collaborator Author

sangstar commented Jul 1, 2025

Gentle prod! Is there anything else I can assist with in getting this merged? @aarnphm @ywang96 @jeejeelee @DarkLight1337

@DarkLight1337 DarkLight1337 requested a review from mgoin July 1, 2025 15:41
Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

Ok, have a stamp from me. Tiny comment.

sangstar added 15 commits July 6, 2025 19:18
Signed-off-by: Sanger Steel <[email protected]>
Signed-off-by: Sanger Steel <[email protected]>
Signed-off-by: Sanger Steel <[email protected]>
Signed-off-by: Sanger Steel <[email protected]>
Signed-off-by: Sanger Steel <[email protected]>
@sangstar sangstar force-pushed the sangstar/tensorizer-args branch from 342d7ae to ab44e9d Compare July 6, 2025 23:19
@mergify mergify bot removed the needs-rebase label Jul 6, 2025
@sangstar
Copy link
Collaborator Author

sangstar commented Jul 7, 2025

Rebased. Looks like there was a few test failures unrelated to my changes. Anything else needs doing or can this be merged? @aarnphm @DarkLight1337 @jeejeelee @simon-mo @ywang96 @mgoin

@simon-mo simon-mo merged commit 72d14d0 into vllm-project:main Jul 8, 2025
97 of 99 checks passed
huydhn pushed a commit to huydhn/vllm that referenced this pull request Jul 8, 2025
…low passing arbitrary arguments during save/load (vllm-project#19619)

Signed-off-by: Sanger Steel <[email protected]>
Co-authored-by: Eta <[email protected]>
Chen-zexi pushed a commit to Chen-zexi/vllm that referenced this pull request Jul 13, 2025
…low passing arbitrary arguments during save/load (vllm-project#19619)

Signed-off-by: Sanger Steel <[email protected]>
Co-authored-by: Eta <[email protected]>
patrickvonplaten pushed a commit to patrickvonplaten/vllm that referenced this pull request Jul 15, 2025
…low passing arbitrary arguments during save/load (vllm-project#19619)

Signed-off-by: Sanger Steel <[email protected]>
Co-authored-by: Eta <[email protected]>
Signed-off-by: Patrick von Platen <[email protected]>
LyrisZhong pushed a commit to LyrisZhong/vllm that referenced this pull request Jul 23, 2025
…low passing arbitrary arguments during save/load (vllm-project#19619)

Signed-off-by: Sanger Steel <[email protected]>
Co-authored-by: Eta <[email protected]>
avigny pushed a commit to avigny/vllm that referenced this pull request Jul 31, 2025
…low passing arbitrary arguments during save/load (vllm-project#19619)

Signed-off-by: Sanger Steel <[email protected]>
Co-authored-by: Eta <[email protected]>
Signed-off-by: avigny <[email protected]>
Pradyun92 pushed a commit to Pradyun92/vllm that referenced this pull request Aug 6, 2025
…low passing arbitrary arguments during save/load (vllm-project#19619)

Signed-off-by: Sanger Steel <[email protected]>
Co-authored-by: Eta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/build dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation llama Related to Llama models ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants