From 17e41cfb21541c92966e5acd17dd611887087f93 Mon Sep 17 00:00:00 2001 From: Alison Shao <54658187+alisonshao@users.noreply.github.com> Date: Tue, 24 Mar 2026 22:56:57 -0700 Subject: [PATCH] Fix RDMA device mapping for non-zero GPU indices in disaggregation tests (#21303) Co-authored-by: Alison Shao Co-authored-by: hnyls2002 --- python/sglang/srt/server_args.py | 12 +++++++++--- .../test/server_fixtures/disaggregation_fixture.py | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/python/sglang/srt/server_args.py b/python/sglang/srt/server_args.py index 7b855bffe..ac7847366 100644 --- a/python/sglang/srt/server_args.py +++ b/python/sglang/srt/server_args.py @@ -3234,9 +3234,15 @@ class ServerArgs: if len(devices) == 0: raise ValueError("No valid IB devices specified") - # Check for duplicates - if len(devices) != len(set(devices)): - raise ValueError(f"Duplicate IB devices specified: {device_str}") + # Deduplicate while preserving order + unique_devices = list(dict.fromkeys(devices)) + if len(unique_devices) != len(devices): + logger.warning( + "Duplicate IB devices specified: %s. Deduplicating to: %s", + device_str, + ",".join(unique_devices), + ) + devices = unique_devices # Get available IB devices from sysfs ib_sysfs_path = "/sys/class/infiniband" diff --git a/python/sglang/test/server_fixtures/disaggregation_fixture.py b/python/sglang/test/server_fixtures/disaggregation_fixture.py index a66ecc213..53baed4d5 100644 --- a/python/sglang/test/server_fixtures/disaggregation_fixture.py +++ b/python/sglang/test/server_fixtures/disaggregation_fixture.py @@ -249,11 +249,13 @@ def get_rdma_devices_args(): ) rdma_devices = [] + base_gpu = min(gpu_indices) for gpu_idx in gpu_indices: - nic_index = min(gpu_idx // gpus_per_rdma, n_rdma - 1) + nic_index = min((gpu_idx - base_gpu) // gpus_per_rdma, n_rdma - 1) rdma_devices.append(rdma_all_devices[nic_index]) if not rdma_devices: return ",".join(_pick_default_pair(rdma_all_devices)) - return ",".join(rdma_devices) + # Deduplicate while preserving order + return ",".join(dict.fromkeys(rdma_devices))