feat: allow per-node memoryFactor override in device-plugin - #2295
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: alehhu The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @alehhu! It looks like this is your first PR to Project-HAMi/HAMi 🎉 |
📝 WalkthroughWalkthroughThe change adds optional per-node NVIDIA ChangesPer-node NVIDIA memory factor
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/device-plugin/nvidiadevice/nvinternal/plugin/server.go (1)
140-142: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for
MemoryFactorpropagation.The nil check and assignment are correct. The supplied
Test_configOverrideinpkg/device-plugin/nvidiadevice/nvinternal/plugin/server_test.godoes not set or assertMemoryFactor. Add one node with an override and one node without the field. Verify both override propagation and fallback to the global value.🤖 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/device-plugin/nvidiadevice/nvinternal/plugin/server.go` around lines 140 - 142, Add regression coverage in Test_configOverride for MemoryFactor propagation: configure one node with a MemoryFactor override and another without the field, then assert the first uses its node-specific value while the second falls back to the global value. Keep the existing nil-check and assignment in the server configuration flow unchanged.
🤖 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.
Nitpick comments:
In `@pkg/device-plugin/nvidiadevice/nvinternal/plugin/server.go`:
- Around line 140-142: Add regression coverage in Test_configOverride for
MemoryFactor propagation: configure one node with a MemoryFactor override and
another without the field, then assert the first uses its node-specific value
while the second falls back to the global value. Keep the existing nil-check and
assignment in the server configuration flow unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e7726a9a-3e9b-4ae6-9061-30b048582191
📒 Files selected for processing (3)
charts/hami/values.yamlpkg/device-plugin/nvidiadevice/nvinternal/plugin/server.gopkg/device/nvidia/device.go
Signed-off-by: alehhu <159355663+alehhu@users.noreply.github.com>
|
scheduler still uses the global nvidia.MemoryFactor for FitQuota and the webhook quota check. only device plugin config is per node here. scheduler and device plugin can end up using different factors for the same node. pls cover the scheduler side too or note this as a known limit |
|
pls dont force push, add new commits instead. also re-check the contribution gates in CONTRIBUTING.md before pushing again |
|
Hi @mesutoezdil , sorry for the force push! It was an automatic reflex while I was fixing the tests locally. I'm a student and this is one of my first open source contributions (small fixes so far), so I'm still learning the right workflow. I will use normal commits next time. About the scheduler issue: you're totally right. The webhook runs before the node is assigned, so it can't know the node-specific memory factor. I just updated the PR description to note this as a known limit for HAMi scheduler users. For Volcano users though, this should already solve their issue completely. |
|
good that you added the known limit note. one question: does volcano vgpu skip the hami mutatingwebhook completely, or does the webhook still run and just get ignored by volcano scheduling. if it still runs, fitResourceQuota still uses the global factor, so quota checks could be wrong for volcano users too, not just chunking. |
|
Volcano vGPU completely skips the HAMi mutatingwebhook logic, so the global memoryFactor issue in fitResourceQuota does not affect Volcano users. reasons: When a user submits a pod using Volcano, the pod.Spec.SchedulerName is explicitly set to volcano (or their custom volcano scheduler name). This means that:
Since all these conditions evaluate to true, the webhook logs the event and performs an early return with admission.Allowed(...). Because the execution stops there, the fitResourceQuota(pod) function (which is located further down on line 100) is never reached or executed for Volcano pods. Therefore, the global memoryFactor value is never applied to their quota checks. |
|
i don't think a good idea to make this a 'per-node' configuration, because that will make 1 unit of 'device-memory' represent different amounts between nodes, and that makes user unable to predict how much device-memory they can actually get. |
|
@archlitchi Hi, I think it’s not really worth giving up flexibility just to make memory units semantically consistent. Right now, the dp plugin doesn’t explicitly show the semantics of the units—it’s still up to the user (or higher-level software) to read them from config files or node annotations, so reading it once or multiple times doesn’t really matter. Plus, for people, it’s easier to handle actual physical memory identified by card type, like A800-80GB. Conversion and rounding of memory units should be done by higher-level software, and then just give people a heads-up. |
Fixes #2287
What this PR does / why we need it:
Currently,
memoryFactoris a global setting inNvidiaConfig. When using Volcano vGPU DP (or in general heterogeneous clusters), different nodes might need different chunk granularities to avoid gRPC size limits on nodes with large GPUs, without forcing small GPUs to use large chunk sizes.This PR allows configuring
memoryfactoron a per-node basis via thenodeconfigconfigmap array, parsing it securely and falling back to the global default if omitted.Implementation details:
Added
MemoryFactoras an optional pointer (*int32withomitempty) insideNodeDefaultConfigto preserve backwards compatibility. Inserver.go, the specificmemoryfactorcleanly overrides the globalsConfig.MemoryFactorduring node config initialization.AI Assistance Notice:
Testing:
make verifyandgo test ./...passed locally.Release note:
Known Limits:
Scheduler vs Device Plugin Consistency: When using the default HAMi scheduler, the MutatingAdmissionWebhook operates at the cluster level before a node is assigned, so it will continue to use the global
memoryFactor. The per-nodememoryFactoris only applied locally by the DP. Users relying on the HAMi scheduler must ensure their globalmemoryFactoraligns with their workloads, while Volcano users (who bypass the HAMi webhook entirely) can fully benefit from this per-node chunking.Summary by CodeRabbit