Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions integration/hicache/dfkv_hicache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 10 additions & 0 deletions integration/hicache/tests/test_sg_width_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading