[BugFix] Fix incorrect GPU device mapping in multi-replica stages (#4132)

Signed-off-by: ZhengWG <zwg0606@gmail.com>
This commit is contained in:
Zheng Wengang authored and GitHub committed 2026-06-04 15:32:58 +00:00
1 parent 469c1dc87e
commit fccd95b12b
2 files changed
+12 -34

No files matched your search

-18
View File
@@ -95,24 +95,6 @@ def _map_device_list(stage_id: int, device_list: list[str], visible_device_list:
if not all(device.isdigit() for device in device_list):
raise ValueError("Logical devices must be non-negative integers")
# Idempotency: if every requested id already names an entry in the visible
# pool (by value, not by index), treat the YAML field as physical and skip
# the remap. This avoids a double-mapping crash when a parent harness has
# already narrowed CUDA_VISIBLE_DEVICES to specific physical ids before
# spawning the subprocess (the test runtime's OmniServerStageCli does this
# — it sets each stage subprocess's env via ``_set_stage_device_env``).
# Without this guard, a YAML ``devices: "1"`` against a narrowed visible
# list ``["1"]`` would try ``visible[1]`` (out of range) and raise.
visible_set = set(visible_device_list)
if all(device in visible_set for device in device_list):
logger.info(
"Stage %s requested devices %s are already in the visible set %s; using as-is (no remap).",
stage_id,
device_list,
visible_device_list,
)
return list(device_list)
logical_ids = [int(device) for device in device_list]
# If ALL logical device IDs are >= num_visible, none can be 0-based indices