fix(disagg): correct DSA/SWA state-page transfer mismatch in PD disaggregation (#27004)

This commit is contained in:
Kevin Flansburg
2026-06-03 14:33:41 +08:00
committed by GitHub
parent dae86f51f5
commit 52f2fe456a
3 changed files with 63 additions and 2 deletions
@@ -3,6 +3,7 @@ import unittest
import numpy as np
from sglang.srt.disaggregation.common.utils import (
group_concurrent_contiguous,
pack_int_lists,
pack_list_of_buffers,
unpack_int_lists,
@@ -45,5 +46,49 @@ class TestDisaggregationWire(unittest.TestCase):
self.assertEqual(unpack_list_of_buffers(pack_list_of_buffers(bufs)), bufs)
class TestGroupConcurrentContiguous(unittest.TestCase):
@staticmethod
def _arr(values):
return np.array(values, dtype=np.int32)
def test_single_contiguous_group(self):
src = self._arr([10, 11, 12])
dst = self._arr([5, 6, 7])
self.assertEqual(
group_concurrent_contiguous(src, dst),
([[10, 11, 12]], [[5, 6, 7]]),
)
def test_splits_on_discontiguous_indices(self):
src = self._arr([10, 11, 20])
dst = self._arr([5, 6, 7])
self.assertEqual(
group_concurrent_contiguous(src, dst),
([[10, 11], [20]], [[5, 6], [7]]),
)
def test_both_empty(self):
self.assertEqual(
group_concurrent_contiguous(self._arr([]), self._arr([])), ([], [])
)
def test_empty_src_nonempty_dst(self):
self.assertEqual(
group_concurrent_contiguous(self._arr([]), self._arr([1, 2])), ([], [])
)
def test_nonempty_src_empty_dst(self):
# Regression: a non-empty source paired with an empty destination must not
# raise a NumPy broadcast error (observed transferring DSA sparse-attention
# state on a disaggregated GLM deployment when decode registered zero dst indices).
self.assertEqual(
group_concurrent_contiguous(self._arr([1, 2]), self._arr([])), ([], [])
)
def test_mismatched_nonempty_lengths_raise(self):
with self.assertRaises(ValueError):
group_concurrent_contiguous(self._arr([1, 2, 3]), self._arr([1, 2]))
if __name__ == "__main__":
unittest.main()