fix(ascend): skip unhealthy devices in Fit() - #2241
Conversation
|
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 skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesAscend device health filtering
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/device/ascend/device_test.go (1)
2032-2057: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd a mixed-health allocation case.
This case verifies rejection when every device is unhealthy. It does not verify that
Fitskips an unhealthy device and continues scanning. Add a case with an unhealthy device followed by a healthy device, and assert that the healthy device is allocated.🤖 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/ascend/device_test.go` around lines 2032 - 2057, Add a mixed-health test case alongside the existing CardNotHealth scenario, with an unhealthy device followed by a healthy device that satisfies the request. Assert Fit succeeds, allocates exactly one device, selects the healthy device ID, and reports the corresponding successful reason while preserving the existing all-unhealthy rejection case.
🤖 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/device/nvidia/calculate_score.go`:
- Around line 218-219: Update pkg/device/nvidia/calculate_score.go lines 218-219
in the P2P link validation to compare normalized P2PLink.Type values or
multiplicity counts, log a mismatch, and return zero when asymmetric link types
are detected. Update pkg/device/nvidia/calculate_score_test.go line 128 to make
the reverse direction contain one TwoNVLINKLinks entry while preserving the
existing zero-score assertions.
---
Nitpick comments:
In `@pkg/device/ascend/device_test.go`:
- Around line 2032-2057: Add a mixed-health test case alongside the existing
CardNotHealth scenario, with an unhealthy device followed by a healthy device
that satisfies the request. Assert Fit succeeds, allocates exactly one device,
selects the healthy device ID, and reports the corresponding successful reason
while preserving the existing all-unhealthy rejection case.
🪄 Autofix (Beta)
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: 57acf54b-8a5f-4183-ad86-73d4bc80961c
📒 Files selected for processing (4)
pkg/device/ascend/device.gopkg/device/ascend/device_test.gopkg/device/nvidia/calculate_score.gopkg/device/nvidia/calculate_score_test.go
The Ascend device plugin writes Health: false into node annotations when GetDeviceHealth() reports an unhealthy NPU. The scheduler decodes this and buildNodeUsage() copies it to DeviceUsage.Health. However, ascend.Fit() never checked dev.Health, allowing unhealthy NPUs to remain eligible for allocation. Add a dev.Health check at the top of the device loop, mirroring the existing nvidia.Fit() pattern. Unhealthy devices are skipped with reason CardNotHealth. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com>
f0a3fc3 to
14e4e98
Compare
|
/lgtm |
The nvidia backend already checks dev.Health before allocating a device. The same guard was missing from all other backends: amd, awsneuron, biren, cambricon, enflame (device.go + gcu.go), hygon, iluvatar, kunlun (device.go + vdevice.go), metax, mthreads, and vastai. For loop-based backends, add the dev.Health check at the top of the device loop before any other checks, mirroring the nvidia pattern. For graph-select backends (kunlun), add the check inside the fitness functions (FitXPU, FitVXPU) so unhealthy devices are excluded from graph selection. For awsneuron, add the check in both the single-device loop path and inside continuousDeviceAvailable() for multi-device topology-aware selection. Add a CardNotHealth test case for each touched backend that already has a Fit test table (amd, awsneuron, biren, cambricon, enflame/gcu, hygon, iluvatar, kunlun/vdevice, metax, mthreads, vastai). Ascend is handled separately in Project-HAMi#2241. Follows up on Project-HAMi#2241 which fixed the same gap for ascend. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com>
pkg/device/ascend/device.go and device_test.go changes duplicate PR Project-HAMi#2241 which already has LGTM. Reverting to master to avoid conflict. Signed-off-by: Eshiv-Pandey <eshivpandey@gmail.com>
pkg/device/ascend/device.go and device_test.go changes duplicate PR Project-HAMi#2241 which already has LGTM. Reverting to master to avoid conflict. Signed-off-by: Eshiv-Pandey <eshivpandey@gmail.com> Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com>
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 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
|
please resolve these conflicts |
The nvidia backend already checks dev.Health before allocating a device. The same guard was missing from all other backends: amd, awsneuron, biren, cambricon, enflame (device.go + gcu.go), hygon, iluvatar, kunlun (device.go + vdevice.go), metax, mthreads, and vastai. For loop-based backends, add the dev.Health check at the top of the device loop before any other checks, mirroring the nvidia pattern. For graph-select backends (kunlun), add the check inside the fitness functions (FitXPU, FitVXPU) so unhealthy devices are excluded from graph selection. For awsneuron, add the check in both the single-device loop path and inside continuousDeviceAvailable() for multi-device topology-aware selection. Add a CardNotHealth test case for each touched backend that already has a Fit test table (amd, awsneuron, biren, cambricon, enflame/gcu, hygon, iluvatar, kunlun/vdevice, metax, mthreads, vastai). Ascend is handled separately in Project-HAMi#2241. Follows up on Project-HAMi#2241 which fixed the same gap for ascend. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com>
The nvidia backend already checks dev.Health before allocating a device. The same guard was missing from all other backends: amd, awsneuron, biren, cambricon, enflame (device.go + gcu.go), hygon, iluvatar, kunlun (device.go + vdevice.go), metax, mthreads, and vastai. For loop-based backends, add the dev.Health check at the top of the device loop before any other checks, mirroring the nvidia pattern. For graph-select backends (kunlun), add the check inside the fitness functions (FitXPU, FitVXPU) so unhealthy devices are excluded from graph selection. For awsneuron, add the check in both the single-device loop path and inside continuousDeviceAvailable() for multi-device topology-aware selection. Add a CardNotHealth test case for each touched backend that already has a Fit test table (amd, awsneuron, biren, cambricon, enflame/gcu, hygon, iluvatar, kunlun/vdevice, metax, mthreads, vastai). Ascend is handled separately in Project-HAMi#2241. Follows up on Project-HAMi#2241 which fixed the same gap for ascend. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com>
Resolve merge conflict in pkg/device/ascend/device_test.go by keeping both test cases: - 'fit fail: CardNotHealth' (from PR branch) - tests skipping unhealthy devices in Fit() - 'fit fail: partial allocation AllocatedCardsInsufficientRequest for multiple cards' (from master) - tests partial allocation Both test cases pass successfully.
c8cb33a to
88c09ce
Compare
|
for future: please refrain from force pushing once you have started getting reviews, it makes it much harder to tell what has changed from review to review |
|
/lgtm |
|
Would keep in mind. Thanks! |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: archlitchi, Eshiv-Pandey 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 |
* fix: skip unhealthy devices in Fit() for all non-nvidia backends The nvidia backend already checks dev.Health before allocating a device. The same guard was missing from all other backends: amd, awsneuron, biren, cambricon, enflame (device.go + gcu.go), hygon, iluvatar, kunlun (device.go + vdevice.go), metax, mthreads, and vastai. For loop-based backends, add the dev.Health check at the top of the device loop before any other checks, mirroring the nvidia pattern. For graph-select backends (kunlun), add the check inside the fitness functions (FitXPU, FitVXPU) so unhealthy devices are excluded from graph selection. For awsneuron, add the check in both the single-device loop path and inside continuousDeviceAvailable() for multi-device topology-aware selection. Add a CardNotHealth test case for each touched backend that already has a Fit test table (amd, awsneuron, biren, cambricon, enflame/gcu, hygon, iluvatar, kunlun/vdevice, metax, mthreads, vastai). Ascend is handled separately in #2241. Follows up on #2241 which fixed the same gap for ascend. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> * fix: address CodeRabbit suggestions and CI lint failures - Fix duplicate Health field in awsneuron DeviceInfo struct literal - Remove invalid Health field from ContainerDevice/ContainerDeviceRequest literals (not valid fields on those types) - Fix undefined 'reason' var in iluvatar TestPatchAnnotations - Add wantReason assertion to iluvatar Test_Fit loop - Add Health: true to kunlun positive FitVXPU fixtures (Go zero-inits omitted bool to false, causing health check to reject valid fixtures) - Add CardNotHealth test cases for amd, biren, cambricon, enflame, hygon, iluvatar, kunlun, metax, mthreads, vastai, awsneuron backends Signed-off-by: Eshiv-Pandey <eshivpandey@gmail.com> Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> * test: fix broken tests after health check added to Fit() After adding the !dev.Health early-exit to Fit() across all non-nvidia backends, two test files had devices without Health: true set: - enflame/device_test.go: TestFit_SelectProfileByRequest, TestFit_SelectProfileByMemoryCoreRequest, and TestFit_MutexRejectsUsedDevice used DeviceUsage structs with Health defaulting to false, causing the health gate to fire before the logic under test. Set Health: true on those devices. - iluvatar/device_test.go: Test_Fit existing failure-path cases had no wantReason set (empty string), but the test loop now checks reason unconditionally. Added the correct expected reason strings: CardInsufficientMemory, CardTypeMismatch, ExclusiveDeviceAllocateConflict. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> * test: add Health: true to graphSelect test fixtures after health check added to Fit() The !dev.Health early-exit added to Fit() and continuousDeviceAvailable() caused graphSelect test fixtures to fail because DeviceUsage.Health defaults to false in Go, making every device appear unhealthy. Add Health: true to all DeviceUsage fixtures in: - awsneuron/device_test.go: Test_graphSelect - kunlun/device_test.go: Test_graphSelect, Test_graphSelectVXPU, TestKunlunVDevices_Fit_Mutex Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> * test: add CardNotHealth coverage for enflame and restore health check lost in rebase The rebase onto latest master dropped two changes from the original PR: 1. The !dev.Health check in enflame/device.go Fit() was lost 2. Health: true on test fixtures in enflame/device_test.go was lost This commit restores both and adds a TestFit_UnhealthyDeviceRejected test to bring enflame/device.go patch coverage to 100%. Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> * refactor(awsneuron): use helper functions for test device construction Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> * fix(awsneuron): resolve golangci-lint gofmt and modernize issues - Run gofmt -w to fix formatting - Replace for i := 0; i < total; i++ with for i := range 16 to satisfy the modernize linter (range over int, Go 1.22+) Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> --------- Signed-off-by: Eshiv Pandey <eshivpandey18@gmail.com> Signed-off-by: Eshiv-Pandey <eshivpandey@gmail.com>
What type of PR is this?
/kind bug
What this PR does / why we need it:
The Ascend device plugin writes
Health: falseinto node annotations whenGetDeviceHealth()reports an unhealthy NPU. The scheduler decodes this viaUnMarshalNodeDevices()anduildNodeUsage()copies it toDeviceUsage.Health.However,Ascend.Fit()never checks dev.Health, so unhealthy NPUs remain eligible for allocation.NVIDIA's
Fit()already skips unhealthy devices withcommon.CardNotHealth. This PR adds the same check to the Ascend backend, placed at the top of the device loop beforecheckType()matching the NVIDIA pattern exactly, in short adding consistency here :)Which issue(s) this PR fixes:
None filed.
Special notes for your reviewer:
Healthfor every device (manager.go: Health: health == 0), so this check is safe.Does this PR introduce a user-facing change?
No. Unhealthy Ascend NPUs are now skipped during scheduling instead of being allocated.
AI assistance disclosure:
I used an AI tool for codebase navigation and review support.
Summary by CodeRabbit
Bug Fixes