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

chore: default priority earlier to ensure constraints are satisfied [CM-553] #10043

Merged
merged 3 commits into from
Oct 14, 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
8 changes: 8 additions & 0 deletions master/internal/api_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/determined-ai/determined/master/internal/api/apiutils"
"github.com/determined-ai/determined/master/internal/authz"
"github.com/determined-ai/determined/master/internal/command"
masterConfig "github.com/determined-ai/determined/master/internal/config"
"github.com/determined-ai/determined/master/internal/configpolicy"
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/grpcutil"
Expand Down Expand Up @@ -144,6 +145,13 @@ func (a *apiServer) getCommandLaunchParams(ctx context.Context, req *protoComman
config.Resources.ResourcePool = poolName.String()
config.Resources.Slots = resources.Slots

// Apply the scheduler's default priority.
if config.Resources.Priority == nil {
prio := masterConfig.DefaultPriorityForPool(poolName.String())
config.Resources.Priority = &prio
}
stoksc marked this conversation as resolved.
Show resolved Hide resolved
// TODO (CM-493) NTSC invariant config overrides

var contextDirectory []byte
config.WorkDir, contextDirectory, err = fillContextDir(config.WorkDir, workDirInDefaults, req.Files)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions master/internal/api_generic_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/authz"
"github.com/determined-ai/determined/master/internal/command"
masterConfig "github.com/determined-ai/determined/master/internal/config"
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/grpcutil"
"github.com/determined-ai/determined/master/internal/job/jobservice"
Expand Down Expand Up @@ -131,6 +132,12 @@ func (a *apiServer) getGenericTaskLaunchParameters(
taskConfig.Resources.RawResourcePool = &rawResourcePool
taskConfig.Resources.RawSlots = &resources.Slots

// Apply the scheduler's default priority.
if taskConfig.Resources.Priority() == nil {
prio := masterConfig.DefaultPriorityForPool(poolName.String())
taskConfig.Resources.RawPriority = &prio
}

var contextDirectoryBytes []byte
taskConfig.WorkDir, contextDirectoryBytes, err = fillContextDir(
taskConfig.WorkDir,
Expand Down
1 change: 1 addition & 0 deletions master/internal/api_user_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func MockRM() *mocks.ResourceManager {
}, nil)

mockRM.On("SmallerValueIsHigherPriority").Return(true, nil)
mockRM.On("SetGroupPriority", mock.Anything).Return(nil)

return &mockRM
}
Expand Down
15 changes: 8 additions & 7 deletions master/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ func readRMPreemptionStatus(config *ResourceManagerWithPoolsConfig, rpName strin

// ReadPriority resolves the priority value for a job.
func ReadPriority(rpName string, jobConf interface{}) int {
config := GetMasterConfig()
var prio *int
// look at the individual job config
switch conf := jobConf.(type) {
Expand All @@ -628,13 +627,18 @@ func ReadPriority(rpName string, jobConf interface{}) int {
if prio != nil {
return *prio
}

// if not found, fall back to the resource pools config
return DefaultPriorityForPool(rpName)
}

// DefaultPriorityForPool returns the default priority for any jobs (user-defined if provided, otherwise our default).
func DefaultPriorityForPool(rpName string) int {
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this helper!

config := GetMasterConfig()
for _, rm := range config.ResourceManagers() {
for _, rpConfig := range rm.ResourcePools {
if rpConfig.PoolName == rpName {
schedulerConf := rpConfig.Scheduler
prio = readPriorityFromScheduler(schedulerConf)
prio := readPriorityFromScheduler(schedulerConf)
if prio != nil {
return *prio
}
Expand All @@ -647,16 +651,13 @@ func ReadPriority(rpName string, jobConf interface{}) int {
return *prio
}
}

if rm.ResourceManager.KubernetesRM != nil {
return KubernetesDefaultPriority
}

break
return DefaultSchedulingPriority
}
}
}

return DefaultSchedulingPriority
}

Expand Down
7 changes: 7 additions & 0 deletions master/internal/core_experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/authz"
"github.com/determined-ai/determined/master/internal/checkpoints"
masterConfig "github.com/determined-ai/determined/master/internal/config"
"github.com/determined-ai/determined/master/internal/configpolicy"
detContext "github.com/determined-ai/determined/master/internal/context"
"github.com/determined-ai/determined/master/internal/db"
Expand Down Expand Up @@ -348,6 +349,12 @@ func (m *Master) parseCreateExperiment(ctx context.Context, req *apiv1.CreateExp
config.RawCheckpointStorage, &m.config.CheckpointStorage,
)

// Apply the scheduler's default priority.
if config.Resources().Priority() == nil {
prio := masterConfig.DefaultPriorityForPool(poolName.String())
config.RawResources.RawPriority = &prio
}

// Lastly, apply any json-schema-defined defaults.
config = schemas.WithDefaults(config)

Expand Down
Loading