fix(gpu): add systemd ordering to prevent MIG device detection race#8247
Open
fix(gpu): add systemd ordering to prevent MIG device detection race#8247
Conversation
- Add `Before=nvidia-device-plugin.service` to ensure `mig-partition` completes before `nvidia-device-plugin` starts on reboot - Set `Type=oneshot` so systemd waits for the partitioning script to finish before considering the service "started" - Add `RemainAfterExit=yes` to keep the service in "active (exited)" state, required for `Before=`/`After=` ordering with oneshot services On MIG-enabled GPU nodes, both services start concurrently on the second boot (required for MIG mode activation). Without ordering, `nvidia-device-plugin` scans for MIG devices before `mig-partition` has finished creating them and enters "No devices found. Waiting indefinitely." Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the mig-partition.service systemd unit to enforce startup ordering so MIG partitioning completes before the NVIDIA device plugin scans for devices on MIG-enabled nodes.
Changes:
- Add systemd ordering (
Before=) to start MIG partitioning ahead ofnvidia-device-plugin.service. - Switch the service to
Type=oneshotso systemd waits for the script to exit before considering the unit started. - Keep the unit active after exit (
RemainAfterExit=yes) to retain “active (exited)” state.
ganeshkumarashok
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Fixes a race condition on MIG-enabled GPU nodes where
nvidia-device-plugin.servicestarts beforemig-partition.servicehas finished creating MIG instances, causing the device plugin to report "No devices found. Waiting indefinitely."On MIG nodes, the A100 GPU requires a VM reboot to activate MIG mode. After the reboot, both
mig-partition.serviceandnvidia-device-plugin.servicestart concurrently via systemd'smulti-user.targetsince there is no ordering dependency between them. Thenvidia-device-pluginscans for MIG devices almost instantly (~2s), butmig-partitionneeds ~3-4s to partition the GPU. By the time partitioning completes, the device plugin has already entered an unrecoverable "waiting indefinitely" state.This PR adds three directives to
mig-partition.service:Before=nvidia-device-plugin.service— tells systemd to completemig-partitionbefore startingnvidia-device-plugin. This is purely an ordering directive; ifnvidia-device-plugin.servicedoesn't exist or isn't being started, it is silently ignored.Type=oneshot— semantically correct for a service that runs a script and exits. Critically, with the previous defaultType=simple, systemd considers the service "started" as soon as the process forks, soBefore=alone wouldn't actually wait for partitioning to complete. WithType=oneshot, systemd waits for the script to exit before marking the service as started.RemainAfterExit=yes— keeps the service in "active (exited)" state after completion, required forBefore=/After=ordering to work correctly with oneshot services.