Skip to content

feat: support comma-separated gpu-scheduler-policy combinations - #2621

Merged
hami-robot[bot] merged 1 commit into
masterfrom
feat/gpu-scheduler-policy-combination
Aug 13, 2026
Merged

feat: support comma-separated gpu-scheduler-policy combinations#2621
hami-robot[bot] merged 1 commit into
masterfrom
feat/gpu-scheduler-policy-combination

Conversation

@mesutoezdil

@mesutoezdil mesutoezdil commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Lets gpu-scheduler-policy take an ordered comma-separated list.
binpack/spread/numa chain as sort keys in the order written, mutex/topology-aware stay filters in Fit().
Single values keep working as before.
Adds PolicyContains to replace the raw == checks that a comma would've silently broken.
I have tested all in my H100

Summary by CodeRabbit

  • New Features

    • Added support for combining GPU scheduling policies, including binpacking, spreading, NUMA awareness, mutex scheduling, and topology-aware placement.
    • Scheduling policies now accept comma-separated values and extra whitespace.
    • Added NUMA-aware GPU scheduling support.
  • Bug Fixes

    • Improved exclusive and topology-aware allocation when multiple policies are configured.
    • Added deterministic device selection when candidates have equal priority.
    • Improved fallback behavior for policy combinations containing filtering-only options.

@hami-robot
hami-robot Bot requested review from DSFans2014 and archlitchi August 12, 2026 10:32
@github-actions github-actions Bot added the kind/feature new function label Aug 12, 2026
@hami-robot hami-robot Bot added the size/L label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e1bd75a-81ce-451a-9e1e-82af713d875e

📥 Commits

Reviewing files that changed from the base of the PR and between 4763bae and b469f4b.

📒 Files selected for processing (2)
  • pkg/scheduler/policy/gpu_policy.go
  • pkg/scheduler/policy/gpu_policy_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/scheduler/policy/gpu_policy_test.go
  • pkg/scheduler/policy/gpu_policy.go

📝 Walkthrough

Walkthrough

GPU scheduler policies now support comma-separated combinations. Shared membership checks update allocation behavior across GPU backends. Device sorting now applies ordered binpack, spread, and NUMA keys with deterministic tie-breaking.

Changes

GPU policy composition

Layer / File(s) Summary
Policy constants and membership parsing
pkg/util/types.go, pkg/util/util.go, pkg/util/util_test.go
Adds the NUMA policy constant and PolicyContains for trimmed, comma-separated policy values. Tests cover matches, whitespace, empty input, and non-matches.
Combined policy ordering
pkg/scheduler/policy/gpu_policy.go, pkg/scheduler/policy/gpu_policy_test.go
Adds ordered, deduplicated sort-key chains for binpack, spread, and NUMA. Filter-only policies use spread fallback. Equal results use device-index ordering.
Backend policy matching
pkg/device/*/device.go, pkg/device/kunlun/vdevice.go, pkg/device/metax/sdevice.go
Updates backend Fit methods to detect mutex membership in policy lists. NVIDIA also detects topology membership.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Pod
  participant PolicyParser
  participant DeviceUsageList
  participant DeviceBackend
  Pod->>PolicyParser: provide comma-separated scheduler policies
  PolicyParser->>DeviceUsageList: provide ordered sort keys
  DeviceUsageList->>DeviceUsageList: compare binpack, spread, or NUMA keys
  Pod->>DeviceBackend: provide scheduler policies
  DeviceBackend->>PolicyParser: check mutex or topology membership
  PolicyParser-->>DeviceBackend: return policy match
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers: archlitchi, dsfans2014

Poem

I hop through policies, tidy and bright,
Mutex joins NUMA in ordered flight.
Binpack and spread now share the way,
Each GPU finds its proper place to stay.
A rabbit approves with a cheerful leap! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: support for comma-separated GPU scheduler policy combinations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gpu-scheduler-policy-combination

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mesutoezdil
mesutoezdil force-pushed the feat/gpu-scheduler-policy-combination branch from c0a02ae to 0016dde Compare August 12, 2026 10:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/scheduler/policy/gpu_policy.go`:
- Around line 77-83: Update DeviceUsageList.Less to route a single "numa" policy
through lessByChain, while preserving the existing chained behavior for
comma-separated policies and legacy handling for other single policies. Add or
adjust the relevant gpu_policy tests with differing NUMA values and opposing
scores so the test distinguishes NUMA ordering from spread ordering.
- Around line 81-83: Update the combined-policy branch in the policy comparator
to preserve contiguous NUMA groups when NumaBind is enabled, applying NUMA-aware
ordering before chained score keys; retain lessByChain ordering for non-NumaBind
chains. Add coverage for a combined policy with NumaBind: true and ensure the
existing device-aware fit, score, and bind flow remains unchanged.

In `@pkg/util/util.go`:
- Line 292: Replace the strings.Split calls used by both range loops with
strings.SplitSeq, preserving the existing comma delimiter and loop behavior.
Update pkg/util/util.go lines 292-292 and pkg/scheduler/policy/gpu_policy.go
lines 65-65; both sites require the same direct change.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fe9baa1a-4b8c-43a3-a352-4da1f000fb91

📥 Commits

Reviewing files that changed from the base of the PR and between e34913f and c0a02ae.

📒 Files selected for processing (19)
  • pkg/device/amd/device.go
  • pkg/device/ascend/device.go
  • pkg/device/awsneuron/device.go
  • pkg/device/biren/device.go
  • pkg/device/cambricon/device.go
  • pkg/device/enflame/device.go
  • pkg/device/hygon/device.go
  • pkg/device/iluvatar/device.go
  • pkg/device/kunlun/vdevice.go
  • pkg/device/metax/device.go
  • pkg/device/metax/sdevice.go
  • pkg/device/mthreads/device.go
  • pkg/device/nvidia/device.go
  • pkg/device/vastai/device.go
  • pkg/scheduler/policy/gpu_policy.go
  • pkg/scheduler/policy/gpu_policy_test.go
  • pkg/util/types.go
  • pkg/util/util.go
  • pkg/util/util_test.go

Comment thread pkg/scheduler/policy/gpu_policy.go
Comment thread pkg/scheduler/policy/gpu_policy.go Outdated
Comment thread pkg/util/util.go Outdated
@mesutoezdil
mesutoezdil force-pushed the feat/gpu-scheduler-policy-combination branch from 0016dde to ee69b08 Compare August 12, 2026 10:39
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/scheduler/policy/gpu_policy.go 94.28% 1 Missing and 1 partial ⚠️
Flag Coverage Δ
unittests 62.54% <96.42%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/device/amd/device.go 72.01% <100.00%> (ø)
pkg/device/ascend/device.go 84.75% <100.00%> (ø)
pkg/device/awsneuron/device.go 76.38% <100.00%> (ø)
pkg/device/biren/device.go 95.03% <100.00%> (ø)
pkg/device/cambricon/device.go 86.26% <100.00%> (ø)
pkg/device/enflame/device.go 62.05% <100.00%> (ø)
pkg/device/hygon/device.go 92.78% <100.00%> (ø)
pkg/device/iluvatar/device.go 58.48% <100.00%> (ø)
pkg/device/kunlun/vdevice.go 98.78% <100.00%> (ø)
pkg/device/metax/device.go 76.35% <100.00%> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mesutoezdil
mesutoezdil force-pushed the feat/gpu-scheduler-policy-combination branch from ee69b08 to 4763bae Compare August 12, 2026 10:44

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
pkg/scheduler/policy/gpu_policy.go (1)

77-83: 🎯 Functional Correctness | 🟠 Major

Route a single numa policy through lessByChain.

Line 81 only enables chained comparison when the policy contains a comma. Policy: "numa" therefore uses the legacy spread comparator, which prioritizes score instead of NUMA. This violates the specified ordered sort-key behavior for a one-item policy chain.

Add a regression case with opposing score and NUMA values.

Proposed fix
-	if strings.Contains(l.Policy, ",") {
+	if strings.Contains(l.Policy, ",") || l.Policy == util.GPUSchedulerPolicyNuma.String() {
 		return l.lessByChain(i, j)
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/scheduler/policy/gpu_policy.go` around lines 77 - 83, Update
DeviceUsageList.Less to route the single "numa" policy through lessByChain, not
the legacy comparator, while preserving chained-policy behavior. Add a
regression test using opposing score and NUMA values to verify the NUMA ordering
is selected for Policy: "numa".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@pkg/scheduler/policy/gpu_policy.go`:
- Around line 77-83: Update DeviceUsageList.Less to route the single "numa"
policy through lessByChain, not the legacy comparator, while preserving
chained-policy behavior. Add a regression test using opposing score and NUMA
values to verify the NUMA ordering is selected for Policy: "numa".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ca41047-5b16-4f67-b2bf-e73385378a83

📥 Commits

Reviewing files that changed from the base of the PR and between ee69b08 and 4763bae.

📒 Files selected for processing (2)
  • pkg/scheduler/policy/gpu_policy.go
  • pkg/scheduler/policy/gpu_policy_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/scheduler/policy/gpu_policy_test.go

binpack/spread/numa chain as ordered sort keys, mutex/topology-aware
stay Fit() filters. Single-value policies are unchanged. Adds
PolicyContains to replace raw == comparisons across device backends.

Closes #2010

Signed-off-by: mesutoezdil <114185853+mesutoezdil@users.noreply.github.com>
@mesutoezdil
mesutoezdil force-pushed the feat/gpu-scheduler-policy-combination branch from 4763bae to b469f4b Compare August 12, 2026 11:02

@archlitchi archlitchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@hami-robot

hami-robot Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: archlitchi, mesutoezdil

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the approved label Aug 13, 2026
@hami-robot
hami-robot Bot merged commit 1832393 into master Aug 13, 2026
25 checks passed
KunwarSidhu47 pushed a commit to KunwarSidhu47/HAMi that referenced this pull request Aug 13, 2026
…ect-HAMi#2621)

binpack/spread/numa chain as ordered sort keys, mutex/topology-aware
stay Fit() filters. Single-value policies are unchanged. Adds
PolicyContains to replace raw == comparisons across device backends.

Closes Project-HAMi#2010

Signed-off-by: mesutoezdil <114185853+mesutoezdil@users.noreply.github.com>
Signed-off-by: KunwarSidhu47 <kunwarsidhu1947@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants