Repository navigation
fix(nvidia): skip a card that cannot be queried instead of failing detection - #51
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change to preserve healthy NVIDIA GPU data when individual cards cannot be queried.
No open issues 🎉
What changed in this PR
This PR makes NVIDIA detection resilient to individual card failures, allowing healthy GPUs to retain their inventory and usage data when another card cannot be queried.
Changes:
- Skip cards with selected device-specific NVML errors while preserving healthy cards’ enumeration indexes.
- Continue raising unrelated NVML errors and fail inventory detection when no card can be queried.
- Add simulated failure tests covering skipped cards, preserved indexes, error propagation, and partial usage results.
| File | Description |
|---|---|
tests/gpustack_runtime/detector/test_nvidia.py |
Extend the fake NVML binding and test per-card query failures. |
gpustack_runtime/detector/nvidia.py |
Classify device-specific errors and skip affected cards during inventory and usage detection. |
Review effort: Balanced
There was a problem hiding this comment.
Code Review
This pull request improves the robustness of the NVIDIA GPU detector by handling cases where a GPU becomes unqueryable (e.g., falls off the bus) during detection. It introduces a helper function to identify specific NVML errors and updates both detect_info and detect_usage to skip problematic devices instead of failing the entire process. I have kept the review comment regarding the potential for stale metrics in detect_usage, as it highlights a valid issue where skipped devices retain their last known values, and provides a clear, actionable path for resolution.
…tection detect_info and detect_usage walked every card by index, and the handle, compute capability, PCI, name and UUID queries had no per-card handling. One card that NVML cannot query, for example one that has fallen off the bus (NVML_ERROR_GPU_IS_LOST), raised out of the walk, so the detector reported no NVIDIA cards at all and the usage of every card was lost. Skip a card whose query fails with GPU_IS_LOST, UNKNOWN, RESET_REQUIRED, INSUFFICIENT_POWER or IRQ_ISSUE, with a debug warning, as the minor number check already skips a card. Other errors still fail, and so does a host where no card can be queried. Signed-off-by: Skand Tandon <21158496+skandtandon@users.noreply.github.com>
Like detect_info, detect_usage now raises the last error when every card was skipped, so that case behaves as it did before: detect() logs it and reports the information only. Signed-off-by: Skand Tandon <21158496+skandtandon@users.noreply.github.com>
04f7af0 to
4d00fb4
Compare
Summary
NVIDIADetector.detect_infoanddetect_usagewalk every card by index. Most per-card queries already degradeon their own (
contextlib.suppress(pynvml.NVMLError)or a helper that catches), but these don't:detect_info: the handle lookup, compute capability, PCI info, name and UUID;detect_usage: the handle lookup and UUID.So one card that NVML can't query, for example one that has fallen off the bus (
NVML_ERROR_GPU_IS_LOST),raises out of the walk:
detect_info:detect_devices()swallows the exception at debug level and returns no NVIDIA cards, so aGPUStack worker on that node reports zero GPUs. A worker that is already running keeps its cached identity for a
while, but a worker that starts or restarts on a node that already has a lost card reports none of its healthy
cards. With
GPUSTACK_RUNTIME_DETECT=nvidiathe error is re-raised instead.detect_usage:detect()already catches this so that the inventory survives (its comment explains why), butthe usage of every card is still lost on each refresh.
Changes
detect_info: the five queries that don't degrade are read together at the top of each card's loop iteration.A card whose query fails with an error specific to that card (
GPU_IS_LOST,UNKNOWN,RESET_REQUIRED,INSUFFICIENT_POWER,IRQ_ISSUE) is skipped withdebug_log_warning, as the minor-number check already skips acard. The other cards keep their enumeration index.
rather than reporting a host without cards.
detect_usage: the same per-card skip for the handle and UUID reads. The skipped card gets no usage, and theothers keep theirs. If no card can be queried, it raises the last error, as before.
_is_unqueryable_device_errorhelper classifies the error byNVMLError.value.get_topologyis unchanged: it works on the devicesdetect_inforeturned and looks them up by UUID.Tests
In
tests/gpustack_runtime/detector/test_nvidia.py, the fake binding gainsquery_error_codeandquery_error_at, so a card can fail its handle or name query.test_detect_info_skips_a_card_that_cannot_be_queried: each of the five codes at the handle lookup, andGPU_IS_LOSTat the name query. The result is cards 0 and 2, with their own indexes.test_detect_info_fails_on_another_query_error:NO_PERMISSIONstill raises.test_detect_info_fails_when_no_card_can_be_queried: still raises.test_detect_usage_fails_when_no_card_can_be_queried: still raises.test_detect_usage_skips_a_card_that_cannot_be_queried: a card lost between the two queries gets no usage; theothers keep theirs.
Commands run:
uv run pytest tests: 837 passed, 20 skipped.nvidia.pychange reverted, the 7 skip cases fail with the card's NVML error. The three "still fails"tests pass on
maintoo, as intended.pre-commit run --files gpustack_runtime/detector/nvidia.py tests/gpustack_runtime/detector/test_nvidia.py:passes.