-
Notifications
You must be signed in to change notification settings - Fork 312
Add max_model_len field support to router #638
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
base: main
Are you sure you want to change the base?
Conversation
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 @llm-net, 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!
I've implemented support for the max_model_len field within the router's /v1/models endpoint. Previously, while the vLLM backend provided this crucial context window size information, the router was not forwarding it, making it impossible for clients to determine a model's context capabilities via the router's API. My changes ensure that this max_model_len value is now properly propagated and exposed, making the router fully compatible with vLLM's extended OpenAI API format and providing complete model information to consumers.
Highlights
- ModelInfo Update: I've added the
max_model_lenfield to theModelInfodataclass, which is used internally for service discovery. - ModelCard Enhancement: I've included the
max_model_lenfield in theModelCarddataclass, which defines the structure for model information exposed via the API. - Router Logic Adjustment: I've updated the main router logic to ensure that the
max_model_lenvalue, retrieved from the backend, is correctly passed through and included when constructing theModelCardfor the/v1/modelsendpoint.
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 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 or fill out our survey 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
This pull request correctly adds support for the max_model_len field, propagating it from the service discovery layer to the /v1/models API endpoint. The changes are well-implemented. My feedback includes suggestions to add a unit test to cover this new functionality and to extend support for this field to the StaticServiceDiscovery for feature consistency.
| created=model_info.created, | ||
| owned_by=model_info.owned_by, | ||
| parent=model_info.parent, | ||
| max_model_len=model_info.max_model_len, |
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.
This change correctly passes the max_model_len to the ModelCard. To ensure this functionality is robust and to prevent future regressions, it would be beneficial to add a unit test for the /v1/models endpoint. The test should verify that when a model's ModelInfo includes a max_model_len, this value is correctly included in the API response.
| root: Optional[str] = None | ||
| parent: Optional[str] = None | ||
| is_adapter: bool = False | ||
| max_model_len: Optional[int] = None |
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.
While max_model_len is correctly added to ModelInfo and populated for Kubernetes-based service discovery, StaticServiceDiscovery currently has no mechanism to configure this value; it will always default to None. To ensure feature parity across discovery methods, consider enhancing StaticServiceDiscovery to allow static configuration of max_model_len for each model. This could be done by adding a max_model_lens list to its constructor, similar to how urls and models are handled.
…lity - Added max_model_len field to ModelInfo dataclass in service_discovery.py - Added max_model_len field to ModelCard in protocols.py - Updated main_router.py to pass max_model_len when creating ModelCard - This allows the router to properly forward the max_model_len field from vLLM endpoints This fixes the issue where /v1/models endpoint was not showing the context window size for models. Signed-off-by: llm-net <[email protected]>
00ead58 to
2f2be41
Compare
Signed-off-by: llm-net <[email protected]>
2f2be41 to
0a7e331
Compare
Description
This PR adds support for the
max_model_lenfield in the router's /v1/models endpoint.Problem
The vLLM backend returns
max_model_len(context window size) in its /v1/models response, but the router was not forwarding this field. This made it impossible to know the context window size of models through the router API.Solution
max_model_lenfield toModelInfodataclass inservice_discovery.pymax_model_lenfield toModelCardinprotocols.pymain_router.pyto passmax_model_lenwhen creating ModelCardTesting
Tested with a deployment running Qwen3-235B model which has a context window of 131072 tokens.
Before this change:
{ "id": "Qwen/Qwen3-235B-A22B-Thinking-2507-FP8", "object": "model", "created": 1754905632, "owned_by": "vllm", "root": null, "parent": null }After this change (expected):
{ "id": "Qwen/Qwen3-235B-A22B-Thinking-2507-FP8", "object": "model", "created": 1754905632, "owned_by": "vllm", "root": null, "parent": null, "max_model_len": 131072 }This makes the router fully compatible with vLLM's extended OpenAI API format.