Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/epp/scheduling/framework/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Filter interface {

// Scorer defines the interface for scoring a list of pods based on context.
// Scorers must score pods with a value within the range of [0,1] where 1 is the highest score.
// If a scorer returns value greater than 1, it will be treated as score 1.
// If a scorer returns value lower than 0, it will be treated as score 0.
type Scorer interface {
plugins.Plugin
Score(ctx context.Context, cycleState *types.CycleState, request *types.LLMRequest, pods []types.Pod) map[types.Pod]float64
Expand Down
12 changes: 11 additions & 1 deletion pkg/epp/scheduling/framework/scheduler_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (p *SchedulerProfile) runScorerPlugins(ctx context.Context, request *types.
scores := scorer.Score(ctx, cycleState, request, pods)
metrics.RecordSchedulerPluginProcessingLatency(ScorerPluginType, scorer.TypedName().Type, time.Since(before))
for pod, score := range scores { // weight is relative to the sum of weights
weightedScorePerPod[pod] += score * float64(scorer.Weight())
weightedScorePerPod[pod] += enforceScoreRange(score) * float64(scorer.Weight())
}
loggerDebug.Info("After running scorer", "scorer", scorer.TypedName().Type)
}
Expand Down Expand Up @@ -192,3 +192,13 @@ func (p *SchedulerProfile) runPostCyclePlugins(ctx context.Context, cycleState *
metrics.RecordSchedulerPluginProcessingLatency(PostCyclePluginType, plugin.TypedName().Type, time.Since(before))
}
}

func enforceScoreRange(score float64) float64 {
if score < 0 {
return 0
}
if score > 1 {
return 1
}
return score
}