-
Notifications
You must be signed in to change notification settings - Fork 265
feat: make no-hit-lru P/D-aware #522
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,12 @@ const ( | |
|
|
||
| // defaultLRUSize is the maximum number of pods we'll consider in the cache | ||
| defaultLRUSize = 1024 | ||
|
|
||
| // defaultPrefillProfile is the name of the prefill profile | ||
| // | ||
| // This is currently hardcoded until we have a defined proper config interface. | ||
| // (See also https://github.com/kubernetes-sigs/gateway-api-inference-extension/pull/2104/ ) | ||
| defaultPrefillProfile = "prefill" | ||
| ) | ||
|
|
||
| // compile-time type assertions | ||
|
|
@@ -286,19 +292,24 @@ func (s *NoHitLRU) PreRequest(ctx context.Context, request *types.LLMRequest, sc | |
| return | ||
| } | ||
|
|
||
| // Get the primary profile's target pod | ||
| primaryProfile := schedulingResult.ProfileResults[schedulingResult.PrimaryProfileName] | ||
| if primaryProfile == nil || len(primaryProfile.TargetPods) == 0 { | ||
| logger.Info("No target pod in primary profile") | ||
| s.moveTargetPodToFront(ctx, request, schedulingResult.ProfileResults[schedulingResult.PrimaryProfileName], schedulingResult.PrimaryProfileName) | ||
| s.moveTargetPodToFront(ctx, request, schedulingResult.ProfileResults[defaultPrefillProfile], defaultPrefillProfile) | ||
| } | ||
|
|
||
| func (s *NoHitLRU) moveTargetPodToFront(ctx context.Context, request *types.LLMRequest, targetProfile *types.ProfileRunResult, profileName string) { | ||
| logger := log.FromContext(ctx).V(logutil.DEBUG) | ||
|
|
||
| // Get the target profile's target pod | ||
| if targetProfile == nil || len(targetProfile.TargetPods) == 0 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to the other comment: doing the defensive check here is great, I think it may be more readable to bubble it up.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok I think it should be better now! |
||
| return | ||
| } | ||
|
|
||
| targetPod := primaryProfile.TargetPods[0] | ||
| targetPod := targetProfile.TargetPods[0] | ||
| podName := targetPod.GetPod().NamespacedName.String() | ||
|
|
||
| // Move the pod to the front of the LRU. | ||
| var present struct{} // dummy value | ||
| s.lruCache.Add(podName, present) | ||
|
|
||
| logger.Info("Updated LRU cache for cold request", "pod", podName, "requestId", request.RequestId) | ||
| logger.Info("Updated LRU cache for cold request", "profile", profileName, "pod", podName, "requestId", request.RequestId) | ||
| } | ||
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 think we should check if the
defaultPrefillProfilekey exists