Repository navigation
[GPU Reset 2/3] Add per-GPU MIG partitioning and device/metrics lifecycle helpers - #643
Open
ankitjoju-google wants to merge 4 commits into
Open
ankitjoju-google wants to merge 4 commits into
ankitjoju-google wants to merge 4 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.
- Extract shared per-GPU MIG partitioning helpers (BuildPartitionStr, IsGPUPartitioned, DestroyPartitions, CreatePartitions, DiscoverGPU, PartitionIDs) into pkg/gpu/nvidia/mig and update partition_gpu. - Add PhysicalGPUIDs, MIGDeviceManager, DeviceHealth, UpdateGPUHealth, and exported IsMPSHealthy helpers on nvidiaGPUManager. - Add RefreshDevices on GPUHealthChecker to re-discover MIG instances across resets. - Add Stop/Start/Registerer lifecycle methods on MetricServer and ListPodGPUDevices for kubelet PodResources attribution. BUG=581484470
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 2/3. Depends on PR 1/3 (#642); only the last commit is new here.
Why
A GPU reset must touch only the target GPUs and then put them back the way they were. Today MIG partitioning works on all GPUs at once, the manager has no way to mark individual GPUs unhealthy and restore them, and the metrics server holds NVML handles with no way to release them.
What
pkg/gpu/nvidia/mig: per-GPU (by PCI bus ID) helpers to check, destroy, and re-create MIG partitions;partition_gpuuses them with no behaviour change.manager.go:PhysicalGPUIDs,DeviceHealth,UpdateGPUHealth(notifiesListAndWatch),MIGDeviceManager, exportedIsMPSHealthy.RefreshDevices()so re-created MIG instances are tracked.Stop()/Start()that release NVML while keeping/metricsup,Registerer(), andListPodGPUDevices(kubelet PodResources tonamespace/pod).No user-visible behaviour change on its own.
Testing
go vet ./...,go test -race ./pkg/gpu/nvidia/... ./cmd/... ./partition_gpu/...1g.23gbrebuild) and A4X Max (GB300).