generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 207
doc: add doc for infernecemodelrewrites. #1978
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
Open
zetxqx
wants to merge
1
commit into
kubernetes-sigs:main
Choose a base branch
from
zetxqx:mrug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+472
−34
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Inference Model Rewrite | ||
|
|
||
| ??? example "Alpha since v1.2.1" | ||
|
|
||
| The `InferenceModelRewrite` resource is alpha and may have breaking changes in | ||
| future releases of the API. | ||
|
|
||
| ## Background | ||
|
|
||
| The **InferenceModelRewrite** resource allows platform administrators and model owners to control how inference requests are routed to specific models within an Inference Pool. | ||
| This capability is essential for managing model lifecycles without disrupting client applications. | ||
|
|
||
| ## Usages | ||
|
|
||
| * **Model Aliasing**: Map a model name in the request body (e.g., `food-review`) to a specific version (e.g., `food-review-v1`). | ||
| * **Generic Fallbacks**: Redirect unknown model requests to a default model. | ||
| * **Traffic Splitting**: Gradually roll out new model versions (Canary deployment) by splitting traffic between two models based on percentage weights. | ||
|
|
||
| ## Spec | ||
|
|
||
| The full spec of the InferenceModelRewrite is defined [here](/reference/x-v1a2-spec/#inferencemodelrewrite). | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ### Model Aliasing | ||
|
|
||
| Map a virtual model name (e.g., `food-review`) to a specific backend model version (e.g., `food-review-v1`). | ||
|
|
||
| ```yaml | ||
| apiVersion: inference.networking.x-k8s.io/v1alpha2 | ||
| kind: InferenceModelRewrite | ||
| metadata: | ||
| name: food-review-alias | ||
| spec: | ||
| poolRef: | ||
| group: inference.networking.k8s.io | ||
| name: vllm-llama3-8b-instruct | ||
| rules: | ||
| - matches: | ||
| - model: | ||
| type: Exact | ||
| value: food-review | ||
| targets: | ||
| - modelRewrite: "food-review-v1" | ||
| ``` | ||
|
|
||
| ### Generic (Wildcard) Rewrites | ||
|
|
||
| Redirect any request with an unrecognized or unspecified model name to a default safe model. An empty `matches` list implies that the rule applies to **all** requests not matched by previous rules. | ||
|
|
||
| ```yaml | ||
| apiVersion: inference.networking.k8s.io/v1alpha2 | ||
| kind: InferenceModelRewrite | ||
| metadata: | ||
| name: generic-fallback | ||
| spec: | ||
| poolRef: | ||
| group: inference.networking.k8s.io | ||
| name: vllm-llama3-8b-instruct | ||
| rules: | ||
| - matches: [] # Empty means this rule matches everything | ||
| targets: | ||
| - modelRewrite: "meta-llama/Llama-3.1-8B-Instruct" | ||
| ``` | ||
|
|
||
| ### Traffic Splitting (Canary Rollout) | ||
|
|
||
| Divide incoming traffic for a single model name across multiple backend models. This is useful for A/B testing or gradual rollouts. | ||
|
|
||
| ```yaml | ||
| apiVersion: inference.networking.k8s.io/v1alpha2 | ||
| kind: InferenceModelRewrite | ||
| metadata: | ||
| name: food-review-canary | ||
| spec: | ||
| poolRef: | ||
| group: inference.networking.k8s.io | ||
| name: vllm-llama3-8b-instruct | ||
| rules: | ||
| - matches: | ||
| - model: | ||
| type: Exact | ||
| value: food-review | ||
| targets: | ||
| - modelRewrite: "food-review-v1" | ||
| weight: 90 | ||
| - modelRewrite: "food-review-v2" | ||
| weight: 10 | ||
| ``` | ||
|
|
||
| ## Limitations | ||
|
|
||
| 1. **Status Reporting**: Currently, `InferenceModelRewrite` is simply a config read-only CR. It does not report status conditions (e.g., Valid or Ready) in the CRD status field. | ||
| 2. **Scheduler Assumptions**: Traffic splitting occurs before the scheduling algorithm. The system assumes that all model servers within the referenced `InferencePool` are capable of serving the target models. If a model is missing from a specific server in the pool, requests routed to it may fail. | ||
| 3. **Splitting algorithm**: The current traffic split is weighted-random. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should be clear here that this is scoped to traffic splitting within an inferencePool; it will not split traffic between two different pools, but two adapters served by the same inferencePool.
We need to have an overall guide that covers all traffic splitting use cases to make it clear which cases are covered by which api and by which component