fix(server): keep serving when one chip refuses device-share #137
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 460 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.367
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #137"
general
weight: 0.35
DSFans2014
What type of PR is this?
/kind bug
What this PR does / why we need it:
On a
hami-vnpu-corenode the plugin enablesdevice-shareon every chip duringStart().npu-smi set -t device-share ... -d 1refuses to switch a chip that still runs a workload,applyDeviceSharestops at the first failure, andStart()aborts — so kubelet crash-loops the DaemonSet and the node stops advertising everyhuawei.com/Ascend*resource. One busy chip, whose block clears on its own once its workload finishes, takes the whole node offline (#131).enableNodeDeviceSharenow drives the chips one at a time, asking the driver whether a workload is running on each through a newManager.IsDeviceInUse(logicID)backed bydevmanager.GetDevProcessInfo, rather than interpretingnpu-smi's exit code. A chip in use is logged once and queued inpendingDeviceShare; the rest are switched and stay available, including when every chip is busy. Because a workload can start between the check and the set, a refused set is followed by a second look at the process list; if the list itself cannot be read, the set is attempted and its own result decides.watchAndRegistercallsretryPendingDeviceShareon every tick, so a chip is switched as soon as its workload finishes, and still-busy chips log atV(3)to avoid a warning per chip every 30 s.As requested in review, a queued chip is not registered while it waits: it is still laid out as a whole chip, so advertising it would let the scheduler place sliced workloads on a chip that cannot slice. It is withheld from the kubelet
ListAndWatchresponse and from the HAMi node annotation, and appears in the next tick once the switch succeeds.Indexin the annotation stays continuous over the devices actually reported whileNetworkIDkeeps following the chip's physical position, so a withheld chip in the middle of the list does not shift the network ID of the ones after it.Any other
npu-smifailure still aborts startup exactly as before. Becausenpu-smiis now invoked from the periodic loop too,runNpuSmiruns it under a timeout so a hung binary cannot stallwatchAndRegisterand with it the kubelet updates and the HAMi registration.Which issue(s) this PR fixes:
Fixes #131
Special notes for your reviewer:
This follows the behaviour suggested in the issue discussion: skip the busy chip, keep the rest available, retry later. The busy check uses the driver's process list as requested in review rather than
npu-smi's exit code; the set's own refusal is still handled for the window between the check and the set.Unit tests in
internal/server/device_share_test.gouse the existing fakerunNpuSmihook and a fakeIsDeviceInUse, so no hardware is involved: a busy chip is skipped and queued, an all-busy node queues everything and still starts, a chip taken between check and set is queued, an idle chip failing for another reason still fails fast, an unreadable process list falls back to the set, the retry loop drops a chip once switched, and a hungnpu-smitimes out. Three more cover the non-registration: the withheld chip is absent fromapiDevices, absent from the HAMi annotation withIndexcontinuous andNetworkIDintact, and the device fingerprint moves when a chip is withheld or restored.I have not run this on Ascend hardware.
Yes, AI-assisted; reviewed by me.
Does this PR introduce a user-facing change?:
``
release-notenpu-smiThe Ascend device plugin no longer exits when
refuses to enable device-share on a chip that is in use; the chip is withheld from registration and retried periodically while the remaining chips stay available.
``