[NUMA+Ray] Fix NUMA NVML handle resolution under shuffled CUDA_VISIBLE_DEVICES - #24766
Merged
Merged
Conversation
`nvmlDeviceGetHandleByIndex` enumerates GPUs in PCI bus order and ignores `CUDA_VISIBLE_DEVICES`, so passing a CUDA logical index returned the wrong physical GPU under shuffled CVD (e.g. Ray's GPU allocator producing `3,6,5,4,0,7,1,2`), binding scheduler subprocesses to the wrong NUMA node. Resolve CUDA logical GPU ids through PyTorch's NVML index helper (`torch.cuda._get_nvml_device_index`) so NUMA binding follows reordered `CUDA_VISIBLE_DEVICES` while keeping a fallback for older torch builds. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Collaborator
Author
|
/tag-and-run-ci |
Collaborator
Author
|
/tag-and-rerun-ci |
ispobock
approved these changes
May 10, 2026
ByronHsu
added a commit
that referenced
this pull request
May 10, 2026
…der shuffled CUDA_VISIBLE_DEVICES (#24901) Co-authored-by: Byron Hsu <byron@periodiclabs.ai> Co-authored-by: Cursor <cursoragent@cursor.com>
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
…E_DEVICES (sgl-project#24766) Co-authored-by: Byron Hsu <byron@periodiclabs.ai> Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Motivation
pynvml.nvmlDeviceGetHandleByIndexenumerates GPUs in PCI bus order and ignoresCUDA_VISIBLE_DEVICES. Under a reordered CVD (e.g. Ray's GPU allocator producing3,6,5,4,0,7,1,2),numa_utils._query_numa_node_for_gpupasses a CUDA logical index and gets back the wrong physical GPU's NUMA affinity, so scheduler subprocesses get bound to the wrong NUMA node.Modifications
Resolve the CUDA logical id via
torch.cuda._get_nvml_device_index(which honorsCUDA_VISIBLE_DEVICES) before callingnvmlDeviceGetHandleByIndex. Falls back to the original index (with a warning) on torch builds that don't expose the helper.Also enriches the numactl
debug_strwith logical/physical GPU ids andCUDA_VISIBLE_DEVICES.Checklist
Co-authored-by: bingyuhsu <byronhsu1230@gmail.com>in the commit message after the PR is merged.