-
Notifications
You must be signed in to change notification settings - Fork 180
profile handler ProcessResult returns additional return value #1013
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 all 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 |
---|---|---|
|
@@ -19,6 +19,8 @@ package profile | |
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
|
||
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins" | ||
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework" | ||
|
@@ -58,15 +60,28 @@ func (h *SingleProfileHandler) Pick(_ context.Context, request *types.LLMRequest | |
return profiles | ||
} | ||
|
||
func (h *SingleProfileHandler) ProcessResults(_ context.Context, _ *types.LLMRequest, profileResults map[string]*types.ProfileRunResult) *types.SchedulingResult { | ||
var firstKey string | ||
for key := range profileResults { | ||
firstKey = key | ||
// ProcessResults handles the outcome of the profile runs after all profiles ran. | ||
// It may aggregate results, log test profile outputs, or apply custom logic. It specifies in the SchedulingResult the | ||
// key of the primary profile that should be used to get the request selected destination. | ||
// When a profile run fails, its result in the profileResults map is nil. | ||
func (h *SingleProfileHandler) ProcessResults(_ context.Context, _ *types.LLMRequest, | ||
profileResults map[string]*types.ProfileRunResult) (*types.SchedulingResult, error) { | ||
if len(profileResults) != 1 { | ||
return nil, errors.New("single profile handler is intended to be used with a single profile, failed to process multiple profiles") | ||
} | ||
|
||
var singleProfileName string | ||
for profileName := range profileResults { | ||
singleProfileName = profileName | ||
break | ||
} | ||
|
||
if profileResults[singleProfileName] == nil { // there was an error while running the profile | ||
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. IIUC, it seems that you are special casing the first profile, even when there are multiple. 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. this profile handler is intended to be used for a single profile, as the name suggests |
||
return nil, fmt.Errorf("failed to run scheduler profile '%s'", singleProfileName) | ||
} | ||
|
||
return &types.SchedulingResult{ | ||
ProfileResults: profileResults, | ||
PrimaryProfileName: firstKey, | ||
} | ||
PrimaryProfileName: singleProfileName, | ||
}, nil | ||
} |
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.
confirming: it will be an empty entry (key + nil), not no entry (no key at all)?
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.
right. if prefill for example fail we will have an entry in the map "prefill" -> nil
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.
Do we want SchedulingResult to carry an error so that erroring out is explicit?
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.
that depends on the plugin implementation. whoever implements ProfileHandler can decide to filter out from the SchedulingResult the profiles that failed, or alternatively leave them with nil for being explicit. both are possible.
In GIE there is a single profile. having a failure means we cannot schedule the request. in different scenarios like llm-d PD it’s not always the case (see description in the PR intro)
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.
Sorry, I meant changing ProfileRunResult to include the error parameter instead of assuming that there is an error when it is nil.
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.
as part of the scheduling new design, one of the first changes that were made was to remove the error return value from all extensions of a profile. that is - filter, scorer and picker - none of them returns an error.
the only case where an error is returned from a Profile run is when no pods left available after the filter phase.
see here:
gateway-api-inference-extension/pkg/epp/scheduling/framework/scheduler_profile.go
Lines 109 to 122 in e29fa4b
additionally, we can notice that when that happens, the returned ProfileRunResult is nil.
in the scheduler itself, the code in this PR is implemented to include the nil result when error happens.
see here:
gateway-api-inference-extension/pkg/epp/scheduling/scheduler.go
Lines 122 to 130 in e29fa4b
I feel comfortable with leaving it as is, but if you have a strong opinion about adding explicit error field to ProfileRunResult we can do that. just don't think it's necessary, not atm at least.
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.
Sounds good