Repository navigation
fix(nvidia): keep MIG indexes stable when a card is skipped - #53
Conversation
…pped MIG devices are numbered in blocks above the largest card index the detected cards report. A skipped card no longer reports one, so a MIG device on another card must keep the index it has when every card answers. Signed-off-by: Skand Tandon <21158496+skandtandon@users.noreply.github.com>
index_mig_devices starts the MIG blocks above the largest index the detected cards report. When the skipped card was the one with the largest index, every other card's MIG devices moved down by one, so an index handed out before now names a different MIG device. Add a reserved count to index_mig_devices and pass the NVML device count when a card was skipped. With every card detected nothing changes. Signed-off-by: Skand Tandon <21158496+skandtandon@users.noreply.github.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). Reviewed |
There was a problem hiding this comment.
🟡 Changes recommended
The reservation logic can renumber existing MIG instances in physical-index-priority mode when another GPU becomes unqueryable, breaking index stability.
1 open issue
What changed in this PR
This follow-up to #51 stabilizes NVIDIA MIG indexes when the highest-index card cannot be queried, preserving assignments for healthy cards.
Changes:
- Adds an optional reserved card-index count to the shared MIG indexing helper.
- Passes the NVML device count when NVIDIA detection skips an unqueryable card.
- Adds a regression test comparing MIG indexes before and after the last card becomes unavailable.
| File | Description |
|---|---|
tests/gpustack_runtime/detector/test_nvidia.py |
Tests index stability when the last card is lost. |
gpustack_runtime/detector/nvidia.py |
Reserves card indexes after a query failure. |
gpustack_runtime/detector/__types__.py |
Adds and documents the reservation parameter. |
Review effort: Balanced
| ret, | ||
| devs_mig_devices, | ||
| devs_mig_slots, | ||
| reserved=dev_count if unqueryable_error else 0, |
There was a problem hiding this comment.
Right, reproduced: with physical index priority, minors 0 and 1 and a third card without a readable minor, losing card 0 moved card 1's MIG indexes from [9, 10] to [10, 11]. The device count only matches the index namespace for enumeration indexes, so the reservation now applies only there (d6d1813), with your case as a test (4090823). In physical-index mode a skipped card with the largest minor can still shift the blocks, as on main.
There was a problem hiding this comment.
Code Review
This pull request introduces a 'reserved' parameter to the index_mig_devices function to ensure that MIG device indexes remain stable even when some cards cannot be queried or are skipped. This prevents renumbering of MIG devices when the last card in a sequence fails. I have no feedback to provide as there were no review comments for this pull request.
With GPUSTACK_RUNTIME_DETECT_PHYSICAL_INDEX_PRIORITY the card indexes are minor numbers and a card without a readable one is already left out, so the NVML device count is not the index namespace. A card that cannot be queried must not move another card's MIG indexes. Signed-off-by: Skand Tandon <21158496+skandtandon@users.noreply.github.com>
Reported in review: with physical index priority, minors 0 and 1 and a third card without a readable minor, losing card 0 made reserved=3 and moved card 1's MIG indexes from [9, 10] to [10, 11]. Reserve the NVML device count only when cards are indexed by enumeration. Signed-off-by: Skand Tandon <21158496+skandtandon@users.noreply.github.com>

Summary
Follow-up to #51.
index_mig_devicesstarts the MIG blocks above the largest index the detected cards report. Since #51 a card that cannot be queried is skipped, and when that card is the one with the largest index, every other card's MIG devices move down by one. An A100 with two instances on card 0 of three cards reports MIG indexes[3, 4]; with card 2 lost it reports[2, 3], so an index handed out earlier now names a different MIG device.index_mig_devicesgets an optionalreservedcount: card indexes that stay taken even if no detected card reports them. The NVIDIA detector passes the NVML device count when it skipped a card, and 0 otherwise, so nothing changes when every card answers.Limit: the block size is still the largest slot count among the detected cards, so on a node mixing MIG-capable models where the skipped card hosts the most slots, the blocks can still shift.
Tests
test_detect_info_keeps_mig_indexes_when_the_last_card_cannot_be_queried(first commit): the same three cards detected with and without the last card lost must give card 0's MIG devices[3, 4]. Without the fix it fails with[2, 3] == [3, 4]; reverting either half of the fix (thereservedterm in the base, or the detector passing it) fails it the same way.pytest tests/gpustack_runtime/detector: 517 passed, 20 skipped. pre-commit (ruff, codespell, commitizen) passes.