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
20 changes: 10 additions & 10 deletions cmd/epp/runner/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import (

// RegisterAllPlugins registers the factory functions of all known plugins
func RegisterAllPlugins() {
plugins.Register(filter.LeastKVCacheFilterName, filter.LeastKVCacheFilterFactory)
plugins.Register(filter.LeastQueueFilterName, filter.LeastQueueFilterFactory)
plugins.Register(filter.LoraAffinityFilterName, filter.LoraAffinityFilterFactory)
plugins.Register(filter.LowQueueFilterName, filter.LowQueueFilterFactory)
plugins.Register(prefix.PrefixCachePluginName, prefix.PrefixCachePluginFactory)
plugins.Register(picker.MaxScorePickerName, picker.MaxScorePickerFactory)
plugins.Register(picker.RandomPickerName, picker.RandomPickerFactory)
plugins.Register(profile.SingleProfileHandlerName, profile.SingleProfileHandlerFactory)
plugins.Register(scorer.KvCacheScorerName, scorer.KvCacheScorerFactory)
plugins.Register(scorer.QueueScorerName, scorer.QueueScorerFactory)
plugins.Register(filter.LeastKVCacheFilterType, filter.LeastKVCacheFilterFactory)
plugins.Register(filter.LeastQueueFilterType, filter.LeastQueueFilterFactory)
plugins.Register(filter.LoraAffinityFilterType, filter.LoraAffinityFilterFactory)
plugins.Register(filter.LowQueueFilterType, filter.LowQueueFilterFactory)
plugins.Register(prefix.PrefixCachePluginType, prefix.PrefixCachePluginFactory)
plugins.Register(picker.MaxScorePickerType, picker.MaxScorePickerFactory)
plugins.Register(picker.RandomPickerType, picker.RandomPickerFactory)
plugins.Register(profile.SingleProfileHandlerType, profile.SingleProfileHandlerFactory)
plugins.Register(scorer.KvCacheScorerType, scorer.KvCacheScorerFactory)
plugins.Register(scorer.QueueScorerType, scorer.QueueScorerFactory)
}

// eppHandle is a temporary implementation of the interface plugins.Handle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func NewHeaderBasedTestingFilter() *HeaderBasedTestingFilter {
// HeaderBasedTestingFilter filters Pods based on an address specified in the "test-epp-endpoint-selection" request header.
type HeaderBasedTestingFilter struct{}

// Name returns the name of the filter.
func (f *HeaderBasedTestingFilter) Name() string {
// Type returns the type of the filter.
func (f *HeaderBasedTestingFilter) Type() string {
return "header-based-testing"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type SchedulingResult struct {

// Plugin is the parent type for all the scheduling framework plugins.
type Plugin interface {
Name() string
Type() string
}

// ProfileHandler defines the interface for handling multi SchedulerProfile instances.
Expand Down
40 changes: 20 additions & 20 deletions pkg/epp/common/config/configloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import (
)

const (
testProfileHandlerName = "test-profile-handler"
test1Name = "test-one"
test2Name = "test-two"
testPickerName = "test-picker"
testProfileHandlerType = "test-profile-handler"
test1Type = "test-one"
test2Type = "test-two"
testPickerType = "test-picker"
)

func TestLoadConfiguration(t *testing.T) {
Expand All @@ -50,21 +50,21 @@ func TestLoadConfiguration(t *testing.T) {
Plugins: []configapi.PluginSpec{
{
Name: "test1",
PluginName: test1Name,
PluginName: test1Type,
Parameters: json.RawMessage("{\"threshold\":10}"),
},
{
Name: "profileHandler",
PluginName: "test-profile-handler",
},
{
Name: test2Name,
PluginName: test2Name,
Name: test2Type,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about changing PluginName > Type in the configuration file and the loader?
follow up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow up.
Noted in PR description

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw this, we can do it in a follow up

PluginName: test2Type,
Parameters: json.RawMessage("{\"hashBlockSize\":32}"),
},
{
Name: "testPicker",
PluginName: testPickerName,
PluginName: testPickerType,
},
},
SchedulingProfiles: []configapi.SchedulingProfile{
Expand Down Expand Up @@ -463,8 +463,8 @@ type test1 struct {
Threshold int `json:"threshold"`
}

func (f *test1) Name() string {
return test1Name
func (f *test1) Type() string {
return test1Type
}

// Filter filters out pods that doesn't meet the filter criteria.
Expand All @@ -478,8 +478,8 @@ var _ framework.PostCycle = &test2{}

type test2 struct{}

func (f *test2) Name() string {
return test2Name
func (f *test2) Type() string {
return test2Type
}

func (m *test2) Score(ctx context.Context, request *types.LLMRequest, cycleState *types.CycleState, pods []types.Pod) map[types.Pod]float64 {
Expand All @@ -494,8 +494,8 @@ var _ framework.Picker = &testPicker{}

type testPicker struct{}

func (p *testPicker) Name() string {
return testPickerName
func (p *testPicker) Type() string {
return testPickerType
}

func (p *testPicker) Pick(ctx context.Context, cycleState *types.CycleState, scoredPods []*types.ScoredPod) *types.ProfileRunResult {
Expand All @@ -507,8 +507,8 @@ var _ framework.ProfileHandler = &testProfileHandler{}

type testProfileHandler struct{}

func (p *testProfileHandler) Name() string {
return testProfileHandlerName
func (p *testProfileHandler) Type() string {
return testProfileHandlerType
}

func (p *testProfileHandler) Pick(ctx context.Context, request *types.LLMRequest, profiles map[string]*framework.SchedulerProfile, executionResults map[string]*types.ProfileRunResult) map[string]*framework.SchedulerProfile {
Expand All @@ -520,27 +520,27 @@ func (p *testProfileHandler) ProcessResults(ctx context.Context, request *types.
}

func registerTestPlugins() {
plugins.Register(test1Name,
plugins.Register(test1Type,
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
result := test1{}
err := json.Unmarshal(parameters, &result)
return &result, err
},
)

plugins.Register(test2Name,
plugins.Register(test2Type,
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
return &test2{}, nil
},
)

plugins.Register(testPickerName,
plugins.Register(testPickerType,
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
return &testPicker{}, nil
},
)

plugins.Register(testProfileHandlerName,
plugins.Register(testProfileHandlerType,
func(name string, parameters json.RawMessage, handle plugins.Handle) (plugins.Plugin, error) {
return &testProfileHandler{}, nil
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package plugins
// Plugin defines the interface for a plugin.
// This interface should be embedded in all plugins across the code.
type Plugin interface {
// Name returns the name of the plugin.
Name() string
// Type returns the type of the plugin.
Type() string
}

// Handle provides plugins set of standard data and tools to work with
Expand Down
8 changes: 4 additions & 4 deletions pkg/epp/requestcontrol/director.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,18 @@ func RandomWeightedDraw(logger logr.Logger, model *v1alpha2.InferenceModel, seed
func (d *Director) runPreRequestPlugins(ctx context.Context, request *schedulingtypes.LLMRequest, schedulingResult *schedulingtypes.SchedulingResult,
targetPort int) {
for _, plugin := range d.preRequestPlugins {
log.FromContext(ctx).V(logutil.DEBUG).Info("Running pre-request plugin", "plugin", plugin.Name())
log.FromContext(ctx).V(logutil.DEBUG).Info("Running pre-request plugin", "plugin", plugin.Type())
before := time.Now()
plugin.PreRequest(ctx, request, schedulingResult, targetPort)
metrics.RecordRequestControlPluginProcessingLatency(PreRequestPluginType, plugin.Name(), time.Since(before))
metrics.RecordRequestControlPluginProcessingLatency(PreRequestPluginType, plugin.Type(), time.Since(before))
}
}

func (d *Director) runPostResponsePlugins(ctx context.Context, request *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {
for _, plugin := range d.postResponsePlugins {
log.FromContext(ctx).V(logutil.DEBUG).Info("Running post-response plugin", "plugin", plugin.Name())
log.FromContext(ctx).V(logutil.DEBUG).Info("Running post-response plugin", "plugin", plugin.Type())
before := time.Now()
plugin.PostResponse(ctx, request, response, targetPod)
metrics.RecordRequestControlPluginProcessingLatency(PostResponsePluginType, plugin.Name(), time.Since(before))
metrics.RecordRequestControlPluginProcessingLatency(PostResponsePluginType, plugin.Type(), time.Since(before))
}
}
6 changes: 3 additions & 3 deletions pkg/epp/requestcontrol/director_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func pointer(v int32) *int32 {

func TestDirector_HandleResponse(t *testing.T) {
pr1 := &testPostResponse{
NameRes: "pr1",
TypeRes: "pr1",
}

ctx := logutil.NewTestLoggerIntoContext(context.Background())
Expand Down Expand Up @@ -559,12 +559,12 @@ func TestDirector_HandleResponse(t *testing.T) {
}

type testPostResponse struct {
NameRes string
TypeRes string
lastRespOnResponse *Response
lastTargetPodOnResponse string
}

func (p *testPostResponse) Name() string { return p.NameRes }
func (p *testPostResponse) Type() string { return p.TypeRes }

func (p *testPostResponse) PostResponse(_ context.Context, _ *schedulingtypes.LLMRequest, response *Response, targetPod *backend.Pod) {
p.lastRespOnResponse = response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ type DecisionTreeFilter struct {
NextOnSuccessOrFailure framework.Filter
}

// Name returns the name of the filter.
func (f *DecisionTreeFilter) Name() string {
// Type returns the type of the filter.
func (f *DecisionTreeFilter) Type() string {
if f == nil {
return "nil"
}
return f.Current.Name()
return f.Current.Type()
}

// Filter filters out pods that doesn't meet the filter criteria.
Expand All @@ -69,7 +69,7 @@ func (f *DecisionTreeFilter) Filter(ctx context.Context, request *types.LLMReque
if f.NextOnSuccess != nil {
next = f.NextOnSuccess
}
loggerTrace.Info("Filter succeeded", "filter", f.Name(), "next", next.Name(), "filteredPodCount", len(filteredPod))
loggerTrace.Info("Filter succeeded", "filter", f.Type(), "next", next.Type(), "filteredPodCount", len(filteredPod))
// On success, pass the filtered result to the next filter.
return next.Filter(ctx, request, cycleState, filteredPod)
} else {
Expand All @@ -80,7 +80,7 @@ func (f *DecisionTreeFilter) Filter(ctx context.Context, request *types.LLMReque
if f.NextOnFailure != nil {
next = f.NextOnFailure
}
loggerTrace.Info("Filter failed", "filter", f.Name(), "next", next.Name())
loggerTrace.Info("Filter failed", "filter", f.Type(), "next", next.Type())
// On failure, pass the initial set of pods to the next filter.
return next.Filter(ctx, request, cycleState, pods)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/scheduling/framework/plugins/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var _ framework.Filter = &filterAll{}

type filterAll struct{}

func (f *filterAll) Name() string {
return "filter all"
func (f *filterAll) Type() string {
return "filter-all"
}

func (f *filterAll) Filter(_ context.Context, _ *types.LLMRequest, _ *types.CycleState, pods []types.Pod) []types.Pod {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
LeastKVCacheFilterName = "least-KV-cache"
LeastKVCacheFilterType = "least-KV-cache"
)

// compile-time type validation
Expand All @@ -50,9 +50,9 @@ func NewLeastKVCacheFilter() *LeastKVCacheFilter {
// least one as it gives more choices for the next filter, which on aggregate gave better results.
type LeastKVCacheFilter struct{}

// Name returns the name of the filter.
func (f *LeastKVCacheFilter) Name() string {
return LeastKVCacheFilterName
// Type returns the type of the filter.
func (f *LeastKVCacheFilter) Type() string {
return LeastKVCacheFilterType
}

// Filter filters out pods that doesn't meet the filter criteria.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
LeastQueueFilterName = "least-queue"
LeastQueueFilterType = "least-queue"
)

// compile-time type validation
Expand All @@ -50,9 +50,9 @@ func NewLeastQueueFilter() *LeastQueueFilter {
// the least one as it gives more choices for the next filter, which on aggregate gave better results.
type LeastQueueFilter struct{}

// Name returns the name of the filter.
func (f *LeastQueueFilter) Name() string {
return LeastQueueFilterName
// Type returns the type of the filter.
func (f *LeastQueueFilter) Type() string {
return LeastQueueFilterType
}

// Filter filters out pods that doesn't meet the filter criteria.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

const (
LoraAffinityFilterName = "lora-affinity"
LoraAffinityFilterType = "lora-affinity"
)

type loraAffinityFilterParameters struct {
Expand All @@ -44,7 +44,7 @@ var _ framework.Filter = &LoraAffinityFilter{}
func LoraAffinityFilterFactory(name string, rawParameters json.RawMessage, _ plugins.Handle) (plugins.Plugin, error) {
parameters := loraAffinityFilterParameters{Threshold: config.DefaultLoraAffinityThreshold}
if err := json.Unmarshal(rawParameters, &parameters); err != nil {
return nil, fmt.Errorf("failed to parse the parameters of the '%s' filter - %w", LoraAffinityFilterName, err)
return nil, fmt.Errorf("failed to parse the parameters of the '%s' filter - %w", LoraAffinityFilterType, err)
}
return NewLoraAffinityFilter(parameters.Threshold), nil
}
Expand All @@ -67,9 +67,9 @@ type LoraAffinityFilter struct {
loraAffinityThreshold float64
}

// Name returns the name of the filter.
func (f *LoraAffinityFilter) Name() string {
return LoraAffinityFilterName
// Type returns the type of the filter.
func (f *LoraAffinityFilter) Type() string {
return LoraAffinityFilterType
}

// Filter filters out pods that doesn't meet the filter criteria.
Expand Down
10 changes: 5 additions & 5 deletions pkg/epp/scheduling/framework/plugins/filter/low_queue_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

const (
LowQueueFilterName = "low-queue"
LowQueueFilterType = "low-queue"
)

type lowQueueFilterParameters struct {
Expand All @@ -43,7 +43,7 @@ var _ framework.Filter = &LowQueueFilter{}
func LowQueueFilterFactory(name string, rawParameters json.RawMessage, _ plugins.Handle) (plugins.Plugin, error) {
parameters := lowQueueFilterParameters{Threshold: config.DefaultQueueingThresholdLoRA}
if err := json.Unmarshal(rawParameters, &parameters); err != nil {
return nil, fmt.Errorf("failed to parse the parameters of the '%s' filter - %w", LowQueueFilterName, err)
return nil, fmt.Errorf("failed to parse the parameters of the '%s' filter - %w", LowQueueFilterType, err)
}

return NewLowQueueFilter(parameters.Threshold), nil
Expand All @@ -61,9 +61,9 @@ type LowQueueFilter struct {
queueingThresholdLoRA int
}

// Name returns the name of the filter.
func (f *LowQueueFilter) Name() string {
return LowQueueFilterName
// Type returns the type of the filter.
func (f *LowQueueFilter) Type() string {
return LowQueueFilterType
}

// Filter filters out pods that doesn't meet the filter criteria.
Expand Down
Loading