-
Notifications
You must be signed in to change notification settings - Fork 251
feat(scheduler): add gpujoborder plugin for configurable JobOrderFn tiebreak #1995
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
Merged
davidLif
merged 14 commits into
kai-scheduler:main
from
CoolingCube:resourceaware-tiebreak
Aug 23, 2026
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e3144dd
Add resourceaware plugin: configurable resource-based JobOrderFn tieb…
CoolingCube 60f765c
Register resourceaware plugin in factory.go; restore priority guard c…
CoolingCube c5ff98c
chore: add changelog fragment for resourceaware plugin
CoolingCube 279043f
refactor(scheduler): rename resourceaware plugin to gpujoborder for c…
CoolingCube d366fa3
docs: update changelog fragment to reference gpujoborder
CoolingCube ff245ea
perf(scheduler): cache GetAliveTasksRequestedGPUs to fix reclaim benc…
CoolingCube 8a53739
chore: add license headers and fix formatting to pass make validate
CoolingCube c7b3e9e
fix(scheduler): scope gpujoborder to victim selection only via new Vi…
CoolingCube 5991c05
fix(scheduler): VictimOrderFn correctly composes with existing JobOrd…
CoolingCube 04467da
test(scheduler): fix duplicate task UIDs in elastic-composition test …
CoolingCube 2b6eade
style(scheduler): remove comments per @gshaibi's review preference
CoolingCube 24d2587
style(scheduler): remove comment from new test, matching bare-minimum…
CoolingCube 99cd1c2
docs(scheduler): add doc comments for the VictimOrderFn extension point
CoolingCube 587dab3
Merge branch 'main' into resourceaware-tiebreak
CoolingCube File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| kind: Added | ||
| body: |- | ||
| Add gpujoborder plugin for configurable GPU-based JobOrderFn tiebreak on priority ties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Copyright 2026 NVIDIA CORPORATION | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| // Package gpujoborder implements a GPU-count-based victim-selection | ||
| // tiebreak, used only when two jobs of equal priority are otherwise tied | ||
| // (including by any other registered JobOrderFn, such as elastic's | ||
| // at-min/above-min protection) and the scheduler must choose which one | ||
| // to evict. It has no effect on pending-job allocation ordering, and no | ||
| // effect whenever an existing JobOrderFn-registered plugin already has an | ||
| // opinion on the comparison. | ||
| package gpujoborder | ||
|
|
||
| import ( | ||
| "github.com/kai-scheduler/KAI-scheduler/pkg/scheduler/api/podgroup_info" | ||
| "github.com/kai-scheduler/KAI-scheduler/pkg/scheduler/framework" | ||
| "github.com/kai-scheduler/KAI-scheduler/pkg/scheduler/log" | ||
| ) | ||
|
|
||
| const ( | ||
| // ModeEvictLargerFirst prefers evicting the job requesting MORE GPUs | ||
| // when a tie must be broken. Named for the eviction outcome directly | ||
| // (not "prefer-larger", which reads ambiguously as either "prefer to | ||
| // evict the larger job" or "prefer to keep/favor the larger job") -- | ||
| // per review discussion, this is deliberately unambiguous since the | ||
| // config string is hard to rename once real users depend on it. | ||
| ModeEvictLargerFirst = "evict-larger-first" | ||
| // ModeEvictSmallerFirst prefers evicting the job requesting FEWER | ||
| // GPUs when a tie must be broken. | ||
| ModeEvictSmallerFirst = "evict-smaller-first" | ||
| ) | ||
|
|
||
| type gpuJobOrderPlugin struct { | ||
| mode string | ||
| } | ||
|
|
||
| func New(arguments framework.PluginArguments) framework.Plugin { | ||
| mode := arguments.GetString("mode", ModeEvictLargerFirst) | ||
| if mode != ModeEvictLargerFirst && mode != ModeEvictSmallerFirst { | ||
| log.InfraLogger.Warningf("gpujoborder: unrecognized mode %q, defaulting to %s", mode, ModeEvictLargerFirst) | ||
| mode = ModeEvictLargerFirst | ||
| } | ||
| return &gpuJobOrderPlugin{mode: mode} | ||
| } | ||
|
|
||
| func (rp *gpuJobOrderPlugin) Name() string { | ||
| return "gpujoborder" | ||
| } | ||
|
|
||
| // OnSessionOpen registers this plugin's comparator via AddVictimOrderFn, | ||
| // NOT AddJobOrderFn. This plugin is scoped to victim/eviction selection | ||
| // only, and only applies as a tiebreak after every registered JobOrderFn | ||
| // (priority.go, elastic.go, etc.) has already had a chance to decide -- | ||
| // see Session.VictimOrderFn for the real composition order. | ||
| func (rp *gpuJobOrderPlugin) OnSessionOpen(ssn *framework.Session) { | ||
| ssn.AddVictimOrderFn(rp.VictimOrderFn) | ||
| } | ||
|
|
||
| // VictimOrderFn returns -1 when l is the BETTER victim (should be evicted | ||
| // first), matching VictimOrderFn's direct (non-inverted) contract -- no | ||
| // external sign flip is applied or needed here. | ||
| func (rp *gpuJobOrderPlugin) VictimOrderFn(l, r interface{}) int { | ||
| lv := l.(*podgroup_info.PodGroupInfo) | ||
| rv := r.(*podgroup_info.PodGroupInfo) | ||
|
|
||
| if lv.Priority != rv.Priority { | ||
| return 0 | ||
| } | ||
|
|
||
| lGPU := lv.GetAliveTasksRequestedGPUs() | ||
| rGPU := rv.GetAliveTasksRequestedGPUs() | ||
|
|
||
| switch rp.mode { | ||
| case ModeEvictSmallerFirst: | ||
| if lGPU < rGPU { | ||
| return -1 | ||
| } | ||
| if lGPU > rGPU { | ||
| return 1 | ||
| } | ||
| default: // ModeEvictLargerFirst | ||
| if lGPU > rGPU { | ||
| return -1 | ||
| } | ||
| if lGPU < rGPU { | ||
| return 1 | ||
| } | ||
| } | ||
| return 0 | ||
| } | ||
|
|
||
| func (rp *gpuJobOrderPlugin) OnSessionClose(_ *framework.Session) {} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.