diff --git a/integration/hicache/dfkv_hicache.py b/integration/hicache/dfkv_hicache.py index 0beec0c..662772c 100644 --- a/integration/hicache/dfkv_hicache.py +++ b/integration/hicache/dfkv_hicache.py @@ -127,13 +127,22 @@ def _resolve_parallel_coordinates( if f"{name}_size" in cfg or f"{name}_rank" in cfg: resolved[name] = _physical_axis(cfg, name) elif parallel is not None: - resolved[name] = _physical_axis( - { - f"{name}_size": getattr(parallel, size_attr), - f"{name}_rank": getattr(parallel, rank_attr), - }, - name, - ) + size_value = getattr(parallel, size_attr, None) + rank_value = getattr(parallel, rank_attr, None) + if name == "dcp" and size_value is None and rank_value is None: + # Legacy SGLang exposes only attn_cp_*: that single axis is + # already represented by PCP above. It has no independent DCP + # shard, so duplicating attn_cp_* here would corrupt keys and + # replica-writer election. + resolved[name] = (1, 0) + else: + resolved[name] = _physical_axis( + { + f"{name}_size": size_value, + f"{name}_rank": rank_value, + }, + name, + ) else: resolved[name] = (1, 0) diff --git a/integration/hicache/tests/test_sg_width_namespace.py b/integration/hicache/tests/test_sg_width_namespace.py index 495e1ad..4c72b5a 100644 --- a/integration/hicache/tests/test_sg_width_namespace.py +++ b/integration/hicache/tests/test_sg_width_namespace.py @@ -174,6 +174,16 @@ def test_discovers_sglang_pcp_dcp_coordinates(self): self.assertEqual(dcp, (2, 1)) self.assertEqual(attn_tp_rank, 0) + def test_legacy_sglang_without_dcp_coordinates(self): + with _parallel_runtime( + attn_cp_size=8, + attn_cp_rank=3, + ): + pcp, dcp, attn_tp_rank = H._resolve_parallel_coordinates({}) + self.assertEqual(pcp, (8, 3)) + self.assertEqual(dcp, (1, 0)) + self.assertIsNone(attn_tp_rank) + def test_explicit_coordinates_override_runtime_axes(self): with _parallel_runtime( attn_cp_size=8,