Repository navigation
[GPU Reset 1/3] Refactor health checker to go-nvml with Stop/Start lifecycle - #642
Open
ankitjoju-google wants to merge 3 commits into
Open
ankitjoju-google wants to merge 3 commits into
ankitjoju-google wants to merge 3 commits into
Conversation
Replaced the deprecated gpu-monitoring-tools library with the official go-nvml library. Updated method signatures to use raw types for easier testability and mocking, avoiding issues with non-mockable nvml.Device struct. Updated test cases to match new signatures and smaller mock instance IDs.
- Make Stop() idempotent, synchronize Start()/Stop() with a mutex, and wait for background goroutines (listenToEvents, setXIDheartbeat, resetXIDConditionWithBackoff) via sync.WaitGroup before freeing the NVML event set. - Keep a single long-lived EventBroadcaster across Stop()/Start() cycles instead of attempting an invalid interface assertion in Stop() or leaking broadcasters on restart. - Spawn background goroutines only after NVML device registration succeeds, and clean up the allocated eventSet on early Start() failure. - Restore upstream/master MIG behavior: treat nvml.ERROR_NOT_SUPPORTED from GetMigMode() as MIG disabled, verify currentMode == pendingMode, and resolve MIG parent UUID and GI/CI IDs via go-nvml handles for modern R470+ MIG-<uuid> format with fallback to legacy regex parsing. - Add unit tests covering idempotent Stop(), Stop()/Start() restart without broadcaster leaks, Start() error cleanup, and modern/legacy MIG UUID handling.
…el and optimize MIG - Select on hc.stop when sending to hc.health in catchError so Stop() cannot deadlock if the health channel is full or unconsumed during teardown. - Deduplicate physDevice.RegisterEvents calls per physical GPU UUID when multiple MIG instances share a parent GPU. - Skip MIG NVML handle lookups in resolveMigDeviceInfo and GPUDevice.parseMigDeviceUUID when the device UUID does not start with "MIG-". - Add TestStopUnderHealthChannelBackpressure and verify single RegisterEvents per physical GPU in TestMIGSupportModernAndLegacyUUIDs.
This was referenced Nov 5, 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.
GPU Reset, PR 1/3. Part of in-process GPU reset for the NVIDIA device plugin (PR 2/3 and 3/3 build on this).
Why
Resetting a GPU requires every process, including the device plugin itself, to release its NVML handles first. The health checker holds NVML event sets for its whole lifetime and can't be stopped and restarted, and it still uses the deprecated
gpu-monitoring-toolsbindings while the rest of the plugin usesgo-nvml.What
pkg/gpu/nvidia/health_checktogithub.com/NVIDIA/go-nvml, behind small internal interfaces so it can be unit tested without hardware.Stop()/ restartableStart(): goroutines are joined before the event set is freed, one long-lived event broadcaster is kept, andStop()can't deadlock on a full health channel.Testing
go vet ./...,go test -race ./pkg/gpu/nvidia/... ./cmd/... ./partition_gpu/...