-
Notifications
You must be signed in to change notification settings - Fork 247
[Feat] allow service discovery by service names #586
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
[Feat] allow service discovery by service names #586
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 @learner0810, 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 Kubernetes service discovery capabilities within the vllm_router
. It introduces a new mechanism to identify and connect to backend engines using their stable Kubernetes service names, offering an alternative to the existing pod IP-based discovery. This change improves the robustness and flexibility of how the router interacts with services deployed in a Kubernetes environment.
Highlights
- Enhanced Kubernetes Service Discovery: A new mode for Kubernetes service discovery has been implemented, allowing the
vllm_router
to discover backend engines by their Kubernetes service names rather than individual pod IPs. This provides a more stable and abstract way to manage backend connections. - New Configuration Option: A new command-line argument,
--k8s-service-discovery-type
, has been added. This argument allows users to explicitly choose betweenpod-ip
(the existing default behavior) andservice-name
for Kubernetes service discovery. - Dedicated Service Discovery Class: A new class,
K8sServiceNameServiceDiscovery
, has been introduced. This class encapsulates the specific logic required for discovering and managing backend engines based on Kubernetes service names, including methods for checking service readiness and fetching model information. - Dependency Update: The
psutil
library has been added as a new dependency, likely to support system-level information retrieval within the new service discovery logic.
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. ↩
3fa3eee
to
7596830
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.
Code Review
This pull request introduces a new service discovery mechanism for Kubernetes based on service names, in addition to the existing pod IP-based discovery. This enhances flexibility in environments where direct pod IP access is not ideal. The changes include a new command-line argument to select the discovery type, a new K8sServiceNameServiceDiscovery
class implementing the logic, and updates to integrate everything.
I've identified a critical bug due to a typo that would cause a runtime error, a potential design issue with how prefill/decode clients are handled, and a few smaller issues related to code clarity and dependency management. Addressing these points will improve the code's reliability and maintainability.
if ( | ||
self.prefill_model_labels is not None | ||
and self.decode_model_labels is not None | ||
): | ||
if model_label in self.prefill_model_labels: | ||
self.app.state.prefill_client = httpx.AsyncClient( | ||
base_url=f"http://{engine_name}:{self.port}", | ||
timeout=None, | ||
) | ||
elif model_label in self.decode_model_labels: | ||
self.app.state.decode_client = httpx.AsyncClient( | ||
base_url=f"http://{engine_name}:{self.port}", | ||
timeout=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.
The logic for setting prefill_client
and decode_client
on app.state
will overwrite the client every time a new matching engine is discovered. If you expect to have multiple prefill or decode engines running concurrently, this will result in only the last discovered engine being used by the router.
If the design is to only have one prefill and one decode engine, consider adding a check to prevent overwriting, or logging a warning if a second one is discovered.
if model_label in self.prefill_model_labels:
if hasattr(self.app.state, 'prefill_client'):
logger.warning("Prefill client is already set. Overwriting with new engine: %s", engine_name)
self.app.state.prefill_client = httpx.AsyncClient(
base_url=f"http://{engine_name}:{self.port}",
timeout=None,
)
elif model_label in self.decode_model_labels:
if hasattr(self.app.state, 'decode_client'):
logger.warning("Decode client is already set. Overwriting with new engine: %s", engine_name)
self.app.state.decode_client = httpx.AsyncClient(
base_url=f"http://{engine_name}:{self.port}",
timeout=None,
)
aa6d725
to
f4d8f58
Compare
cc @zerofishnoodles PTAL |
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 looks like a super good start! But I am wondering the compatibility with the routing logic and metrics part.
For the routing logic, it seems to me it can't perform the kvaware or pd routing, but rather k8s native pod load-balancing strategy like round-robin or session based.
Also for the metrics, rn the metric service will scrape the vllm metrics from the associated pod, when it is performed in the service level, it might not get the same pod metrics as the actual one that run the inference when there are multiple replicas.
So for now, I think the scenario for this is just one pod for one service if we want to have full functionality of the production stack? Correct me if I misunderstood it.
f4d8f58
to
fb04b77
Compare
Yes, you're absolutely right. |
fb04b77
to
29f66b1
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.
LGTM
efa96dc
to
54421f9
Compare
Hi Could you explicitly state this in the code so that others can know about this? |
f6b558a
to
3e0fdb3
Compare
Signed-off-by: learner0810 <[email protected]>
3e0fdb3
to
9c31fb7
Compare
Already added, please have a look |
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.
LGTM
@learner0810 thanks for the PR! I'm merging it now, can you also write a tutorial of how to use this feature? Also make it explicit in the tutorial that this assumes one pod for one service. |
Okay, I'll write it later. |
allow service discovery by service names
FIX ##471
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
-s
when doinggit commit
[Bugfix]
,[Feat]
, and[CI]
.Detailed Checklist (Click to Expand)
Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Feat]
for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).[Router]
for changes to thevllm_router
(e.g., routing algorithm, router observability, etc.).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
Feat
The PR need to meet the following code quality standards:
pre-commit
to format your code. SeeREADME.md
for installation.DCO and Signed-off-by
When contributing changes to this project, you must agree to the DCO. Commits must include a
Signed-off-by:
header which certifies agreement with the terms of the DCO.Using
-s
withgit commit
will automatically add this header.What to Expect for the Reviews
We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.