Skip to content
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

Fix: Make distributed error aggregation opt-in #6103

Merged
merged 1 commit into from
Dec 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ type K8sPluginConfig struct {

// Extended resources that should be added to the tolerations automatically.
AddTolerationsForExtendedResources []string `json:"add-tolerations-for-extended-resources" pflag:",Name of the extended resources for which tolerations should be added."`

EnableDistributedErrorAggregation bool `json:"enable-distributed-error-aggregation" pflag:",If true, will aggregate errors of different worker pods for distributed tasks."`
}

// FlyteCoPilotConfig specifies configuration for the Flyte CoPilot system. FlyteCoPilot, allows running flytekit-less containers
Expand Down
24 changes: 17 additions & 7 deletions flyteplugins/go/tasks/plugins/k8s/kfoperators/pytorch/pytorch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery"
pluginsCore "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
pluginsK8s "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s"
k8sConfig "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s/config"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/k8s"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/utils"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/plugins/k8s/kfoperators/common"
Expand All @@ -30,8 +31,14 @@ type pytorchOperatorResourceHandler struct {
var _ k8s.Plugin = pytorchOperatorResourceHandler{}

func (pytorchOperatorResourceHandler) GetProperties() k8s.PluginProperties {
return k8s.PluginProperties{
ErrorAggregationStrategy: k8s.EarliestErrorAggregationStrategy,
config := k8sConfig.GetK8sPluginConfig()

if config.EnableDistributedErrorAggregation {
return k8s.PluginProperties{
ErrorAggregationStrategy: k8s.EarliestErrorAggregationStrategy,
}
} else {
return k8s.PluginProperties{}
}
}

Expand All @@ -47,7 +54,7 @@ func (pytorchOperatorResourceHandler) BuildIdentityResource(ctx context.Context,
}

// Defines a func to create the full resource object that will be posted to k8s.
func (pytorchOperatorResourceHandler) BuildResource(ctx context.Context, taskCtx pluginsCore.TaskExecutionContext) (client.Object, error) {
func (p pytorchOperatorResourceHandler) BuildResource(ctx context.Context, taskCtx pluginsCore.TaskExecutionContext) (client.Object, error) {
taskTemplate, err := taskCtx.TaskReader().Read(ctx)

if err != nil {
Expand Down Expand Up @@ -115,10 +122,13 @@ func (pytorchOperatorResourceHandler) BuildResource(ctx context.Context, taskCtx
},
},
})
container.Env = append(container.Env, apiv1.EnvVar{
Name: pluginsK8s.FlyteInternalDistErrorStrategyEnvVarKey,
Value: k8s.EarliestErrorAggregationStrategy.String(),
})

if p.GetProperties().ErrorAggregationStrategy == k8s.EarliestErrorAggregationStrategy {
container.Env = append(container.Env, apiv1.EnvVar{
Name: pluginsK8s.FlyteInternalDistErrorStrategyEnvVarKey,
Value: k8s.EarliestErrorAggregationStrategy.String(),
})
}
}
updateEnvVars(&workerReplicaSpec.Template.Spec.Containers[0])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s"
pluginsK8s "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s"
flytek8sConfig "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s/config"
k8sConfig "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/flytek8s/config"
pluginIOMocks "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io/mocks"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/k8s"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/utils"
Expand Down Expand Up @@ -724,8 +725,14 @@ func TestGetLogsElastic(t *testing.T) {
}

func TestGetProperties(t *testing.T) {
config := k8sConfig.GetK8sPluginConfig()
pytorchResourceHandler := pytorchOperatorResourceHandler{}
expected := k8s.PluginProperties{

expected := k8s.PluginProperties{}
assert.Equal(t, expected, pytorchResourceHandler.GetProperties())

config.EnableDistributedErrorAggregation = true
expected = k8s.PluginProperties{
ErrorAggregationStrategy: k8s.EarliestErrorAggregationStrategy,
}
assert.Equal(t, expected, pytorchResourceHandler.GetProperties())
Expand Down Expand Up @@ -861,6 +868,8 @@ func TestBuildResourcePytorchV1(t *testing.T) {
},
}

config := k8sConfig.GetK8sPluginConfig()
config.EnableDistributedErrorAggregation = true
pytorchResourceHandler := pytorchOperatorResourceHandler{}

taskTemplate := dummyPytorchTaskTemplate("job4", taskConfig)
Expand Down
Loading