fix(ascend): stop whole-card/memory-less hami-core requests from bypassing the node mode gate - #2029
Conversation
…ssing the node mode gate The node soft/hard exclusivity added in Project-HAMi#1812 rejects a mismatched pod with ModeNotFit, but the check is nested inside `request.Memreq > 0 && request.Memreq < totalMemPerCard && request.Nums > 0`. A whole-card memory request (Memreq == card capacity) or a memory-less request (Memreq == 0) never enters that block, so a hami-core (soft-split) pod can be scheduled onto a hard-split node, bypassing the exclusivity. Lift the soft-pod arm out of the memory-range condition: a pod that declares hami-core mode must land on a hami-core node regardless of how much memory it requests. The reverse arm (a legacy pod on a hami-core reserved node) stays inside the memory-range condition on purpose, so plain whole-card jobs are not rejected when a node -- or the global hamiVnpuCore default -- marks the node as hami-core. Verified on real hardware (8x Ascend 910B4): a hami-core pod requesting the whole card (32768 MiB) or no memory field is now held Pending with ModeNotFit on a hard node, matching the sub-capacity behaviour, while matching-mode and whole-card legacy requests keep scheduling. Signed-off-by: wangmin <wangmin@riseunion.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThe Ascend Fit logic now rejects hami-core pods on nodes without hami-core support before the memory-based gate, and the test table adds whole-card and memory-less cases to cover the updated mode checks. ChangesAscend hami-core mode gate fix
Estimated code review effort: 2 (Simple) | ~15 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request ensures that hami-core pods are correctly restricted to hami-core nodes regardless of their memory requests (including whole-card and memory-less requests) by moving the node compatibility check outside of the memory-range condition. Corresponding unit tests were added to verify these scenarios. Feedback was provided regarding a potential nil pointer dereference when logging nodeInfo.Node.Name and pod.Name in the legacy vNPU filtering block, which could lead to runtime panics.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Use klog.KObj(pod) instead of dereferencing nodeInfo.Node.Name and pod.Name directly, matching the hami-core arm above and avoiding a potential nil dereference (both are guarded as possibly nil earlier in Fit). Signed-off-by: wangmin <wangmin@riseunion.io>
ouyangluwei163
left a comment
There was a problem hiding this comment.
Please remove the AI-generated code comments and follow the new specification #1998
Signed-off-by: wangmin <wangmin@riseunion.io>
6c508a8 to
cdbaaae
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi, ouyangluwei163, Wangmin362 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does
Fixes #2028.
The node soft/hard-split exclusivity added in #1812 rejects a mismatched pod with
ModeNotFit, but the check sits insiderequest.Memreq > 0 && request.Memreq < totalMemPerCard && request.Nums > 0. A whole-card memory request (Memreq == card capacity) or a memory-less request (Memreq == 0) skips the block, so a hami-core (soft-split) pod can be scheduled onto a hard-split node.This PR lifts the soft-pod arm out of the memory-range condition: a pod that declares
vnpu-mode: hami-coremust land on a hami-core node regardless of how much memory it requests.Why only the soft-pod arm (not a symmetric change)
The reverse arm (a legacy/whole-card pod on a hami-core node) is deliberately left inside the memory-range condition. Making it symmetric would newly reject plain whole-card jobs on any hami-core node, and because
nodeSupportHamiCoredefaults to the globalhamiVnpuCorevalue, a cluster withhamiVnpuCore: truewould then reject every whole-card legacy request. A hami-core pod on a hard node is a correctness problem (no soft-split limiter to enforce its limits); a legacy whole-card pod on a hami-core node is not — so only the soft-pod direction is unconditional.Testing
Unit tests
pkg/device/ascendTestDevices_Fit: 115/115 pass,go build/vet/gofmtclean. Added 4 cases:Memreq == capacity) hami-core on hard node →ModeNotFitMemreq == 0) hami-core on hard node →ModeNotFitReal hardware (8× Ascend 910B4, hard node) — before/after A/B
Same scheduler build, toggling only this change (
v2.9.0andmasterhave this gate byte-identical):vnpu-mode: hami-core)ModeNotFitModeNotFitModeNotFitModeNotFitModeNotFitModeNotFitBefore:
FilteringSucceed: 1 nodes fit(node-001)+BindingSucceedfor the whole-card hami-core pod.After:
NodeUnfitPod ... reason="1/8 ModeNotFit"for the same pod; the legacy whole-card pod still schedules.Scope note
The bypass is confirmed on real hardware. Demonstrating the runtime failure of a whole-card soft pod on a hard-only node needs a second node without soft-split assets, which I can't construct on a single node (the device-plugin always ships soft-split assets). See the linked issue.
This PR was written with AI assistance (Claude Code): the analysis is from my own testing on real Ascend 910B4 hardware, and the code and tests were drafted with AI and reviewed/validated by me.
Summary by CodeRabbit