Skip to content

[Bugfix] Fix modelscope token passed in - #19389

Merged
jeejeelee merged 3 commits into
vllm-project:mainfrom
Potabk:ms
Jun 10, 2025
Merged

jeejeelee merged 3 commits into
vllm-project:mainfrom
Potabk:ms

Conversation

@Potabk

@Potabk Potabk commented Jun 10, 2025

Copy link
Copy Markdown
Contributor

When we set env VLLM_USE_MODELSCOPE, the token is delivered as HF_TOKEN by mistake, so when should pass the real token or None

Signed-off-by: wangli <wangli858794774@gmail.com>
@github-actions

Copy link
Copy Markdown

👋 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.

🚀

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @Potabk, 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!

Summary of Changes

Hello team, Gemini or gemini-code-assist here to provide a summary of this pull request by @Potabk.

This PR addresses a bug where, when the VLLM_USE_MODELSCOPE environment variable is set, the system was incorrectly passing a potentially wrong token (likely intended for Hugging Face) to the modelscope_list_repo_files function. The fix ensures that the correct environment variable, MODELSCOPE_API_TOKEN, is explicitly read and passed as the token for ModelScope operations, or None if the variable is not set.

Highlights

  • Bugfix: ModelScope Token Handling: Corrects the logic for passing the API token when interacting with ModelScope repositories under the VLLM_USE_MODELSCOPE flag.
  • Environment Variable Usage: Ensures that the MODELSCOPE_API_TOKEN environment variable is the source for the token used with ModelScope functions, preventing the use of an incorrect or unintended token.

Changelog

  • vllm/transformers_utils/config.py
    • Modified the lookup_files function to explicitly use os.getenv("MODELSCOPE_API_TOKEN") as the token when calling modelscope_list_repo_files if envs.VLLM_USE_MODELSCOPE is true (lines 144-147).
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 configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request addresses a bug where an incorrect token (HF_TOKEN) was being passed when VLLM_USE_MODELSCOPE was enabled. The fix correctly retrieves the MODELSCOPE_API_TOKEN directly from the environment variables. This is a clear and effective solution to the described problem.

Summary of Findings

  • Maintainability: Environment Variable Name as String Literal: The environment variable name "MODELSCOPE_API_TOKEN" is used directly as a string literal. For better maintainability and to avoid potential typos or inconsistencies if this key is used elsewhere, consider defining it as a constant. This could be a local constant in the file or, for broader consistency within the project, defined in vllm.envs.py.

Merge Readiness

The bugfix provided in this pull request is correct and effectively addresses the issue of passing the wrong token for ModelScope. The code is clear and the change is well-targeted.

I've included one medium-severity suggestion regarding the use of a string literal for the environment variable name, proposing the use of a constant for enhanced maintainability. This is a suggestion for improvement and does not affect the correctness of the current fix.

Overall, the PR is in good shape. As an AI reviewer, I am not authorized to approve pull requests. Please ensure this change is reviewed and approved by human maintainers before merging.

Comment thread vllm/transformers_utils/config.py Outdated
return modelscope_list_repo_files(
repo_id,
revision=revision,
token=os.getenv("MODELSCOPE_API_TOKEN"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly sources the ModelScope API token, resolving the issue of the wrong token being used. Well done!

For improved maintainability, have you considered defining the environment variable name "MODELSCOPE_API_TOKEN" as a constant? This approach can make it easier to manage and update environment variable keys across the codebase.

Possible ways to implement this:

  1. Define a module-level constant within this file (e.g., _MODELSCOPE_API_TOKEN_KEY = "MODELSCOPE_API_TOKEN" at the top of config.py) and use os.getenv(_MODELSCOPE_API_TOKEN_KEY).
  2. For greater consistency with how other environment variables like envs.VLLM_USE_MODELSCOPE are handled in this project, you could consider adding MODELSCOPE_API_TOKEN to vllm.envs.py. This would involve defining it in the TYPE_CHECKING block and adding a loader to the environment_variables dictionary in vllm.envs.py. Then, it could be accessed here as envs.MODELSCOPE_API_TOKEN.

While the current implementation is correct, centralizing environment variable names can be beneficial in the long run. What are your thoughts on this?

Comment thread vllm/transformers_utils/config.py Resolved
Signed-off-by: wangli <wangli858794774@gmail.com>

@jeejeelee jeejeelee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, LGTM

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jeejeelee jeejeelee added ready ONLY add when PR is ready to merge/full CI is needed and removed ready ONLY add when PR is ready to merge/full CI is needed labels Jun 10, 2025
@jeejeelee

jeejeelee commented Jun 10, 2025 •

Copy link
Copy Markdown
Member

@Potabk Could you plz address the CI failure?

Done

Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
@jeejeelee jeejeelee added the ready ONLY add when PR is ready to merge/full CI is needed label Jun 10, 2025
@Potabk

Potabk commented Jun 10, 2025

Copy link
Copy Markdown
Contributor Author

@jeejeelee thx for fix it!

@jeejeelee
jeejeelee merged commit 1efef71 into vllm-project:main Jun 10, 2025
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Potabk
Potabk deleted the ms branch June 10, 2025 06:10
0826joyce pushed a commit to 0826joyce/vllm-serving-optimization that referenced this pull request May 19, 2026
Signed-off-by: wangli <wangli858794774@gmail.com>
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
philippesic pushed a commit to philippesic/vllm-semantic-cache that referenced this pull request Jul 19, 2026
Signed-off-by: wangli <wangli858794774@gmail.com>
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
plasticchris pushed a commit to plasticchris/vllm that referenced this pull request Jul 20, 2026
Signed-off-by: wangli <wangli858794774@gmail.com>
Signed-off-by: Jee Jee Li <pandaleefree@gmail.com>
Co-authored-by: Jee Jee Li <pandaleefree@gmail.com>
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.

2 participants