-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[Model][1/N] Automatic conversion of CrossEncoding model #20012
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
Conversation
Signed-off-by: wang.yuqi <noooop@126.com>
There was a problem hiding this 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 @noooop, 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 introduces a robust mechanism to handle model-specific configuration adjustments within vLLM's multiprocessing architecture. Previously, certain configuration values, like num_labels
for specific models, were not correctly propagated from the model's initialization to the main process's VllmConfig
. This change centralizes and standardizes how these adjustments are applied, ensuring that the VllmConfig
is accurately updated early in its lifecycle, thereby preventing inconsistencies and incorrect behavior.
Highlights
- Centralized Configuration Updates: A new
try_verify_and_update_config
method has been added toVllmConfig
, which is called during its__post_init__
. This method dynamically loads and applies model-specific configuration adjustments based on the detected model architecture, ensuring consistency across processes. - Dedicated Model Configuration Module: A new module,
vllm/model_executor/models/config.py
, has been introduced. This module now houses static methods for verifying and updatingVllmConfig
properties for specific model architectures (e.g.,Qwen3ForSequenceClassification
), cleanly separating this logic from the model's main implementation. - Qwen3-Reranker
num_labels
Fix: The specific issue where thenum_labels
for Qwen3-Reranker models was incorrectly set to 2 (instead of 1) is now resolved. This adjustment is handled by the new centralized configuration mechanism, ensuring correct model behavior. - Refactored Model Weight Loading: Redundant configuration logic and assertions related to
num_labels
have been removed from theqwen3.py
model implementation, as these concerns are now managed by the new dedicated configuration module.
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
-
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. ↩
There was a problem hiding this comment.
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 introduces a mechanism to verify and update model configurations, particularly for CrossEncoding models, by separating configuration and model logic. This involves adding a try_verify_and_update_config
method to VllmConfig
and creating a new VerifyAndUpdateConfig
class in vllm/model_executor/models/config.py
. The changes also include modifications to the Qwen3 model to accommodate the new configuration verification process. The code maintains testing and aims for simplification, but there are opportunities to improve readability and documentation.
👋 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 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 🚀 |
Does this work for you? |
cc @maxdebayser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this because while implementing support for encoder models I've encountered several situations where I had to disable/enable feature is config.py because of model specifics.
Signed-off-by: wang.yuqi <noooop@126.com>
9b0b84c
to
954412f
Compare
34764ec
to
d7fc461
Compare
d2e666f
to
49779ea
Compare
ready to final review I have locally tested and fixed as many tests as possible. |
5a70d6f
to
fb7c8e0
Compare
Could you plz look at this thread, thanks |
Signed-off-by: wang.yuqi <noooop@126.com>
73e3079
to
fbd9dfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM! Thanks for this enhancement!
e3ae464
to
94dbbe8
Compare
a2a8596
to
abe9209
Compare
Is the failure of buildkite/ci/pr/basic-models-test related to this pr? I can't reproduce this error locally . |
Seems just a network issue on CI runner, retrying. |
Thanks for reviewing |
find an earlier failure |
verify_and_update_config
Sometimes when implementing a model, we need to modify some default values in the config, or change variables to names commonly used by vllm.
how did the problem occur
But now vllm uses a multiprocessing architecture, so changing VllmConfig in model init will not affect the main process.
It seems that this is not much of an issue for loading the model.
But if get values from vllm_config in the main processing or server api processing, it may get incorrect data.
Solution 1
Change verify_and_update_config into a class method and call it after initializing model_config.
vllm/vllm/model_executor/models/registry.py
Lines 330 to 341 in 9a3b883
It seems that everyone intends to avoid directly importing the model in the main process.
Solution 2
Using a similar method like _run_in_subprocess, but I'm not sure if vllm_config is picklable. e.g., referencing some lambda functions
Solution 3
Modify somewhere in vllm.config, that's why vllm.config has over 4000+ lines.
Solution 4 <- this pr
separate config and model impl.
I am sure this is not the best solution.
This pr intends to start further discussion on this issue. 抛砖引玉
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
this pr is to address some complex issues found when dealing with #19675
Simplification of the 4000+ lines of vllm.config by moving code specific to certain models out.
Test Plan
pytest tests/models/language/pooling/test_qwen3_reranker.py
Test Result
Manage to keep all testing happy.
(Optional) Documentation Update