diff --git a/python/sglang/srt/model_executor/pool_configurator.py b/python/sglang/srt/model_executor/pool_configurator.py index fdf01e606b..a379e913ed 100644 --- a/python/sglang/srt/model_executor/pool_configurator.py +++ b/python/sglang/srt/model_executor/pool_configurator.py @@ -1045,7 +1045,8 @@ class DSV4PoolConfigurator(MemoryPoolConfigurator): f"layers=[{kvc.layer_info.start_layer},{kvc.layer_info.end_layer}) " f"local={len(self.compression_ratios)}/{len(cfg.compress_ratios)}" ) - self.swa_page_size = cfg.window_size + self.swa_window_size = cfg.window_size + self.swa_page_size = get_schedule().page_size self.operator_swa_ratio = _operator_swa_full_tokens_ratio() self.swa_ratio = ( self.operator_swa_ratio @@ -1097,8 +1098,10 @@ class DSV4PoolConfigurator(MemoryPoolConfigurator): dsv4_unified_row_bytes, ) - # swa_page_size is the model's sliding window (cfg.window_size). - self._swa_ring_size = get_swa_ring_size(self.swa_page_size, self.is_speculative) + # swa_window_size is the model's sliding window (cfg.window_size). + self._swa_ring_size = get_swa_ring_size( + self.swa_window_size, self.is_speculative + ) self._spec_infl = 1.0 # The unified pool takes no dtype, so --kv-cache-dtype never reaches it. diff --git a/test/registered/unit/model_executor/test_pool_configurator.py b/test/registered/unit/model_executor/test_pool_configurator.py index 91f0192a3d..7d525e408c 100644 --- a/test/registered/unit/model_executor/test_pool_configurator.py +++ b/test/registered/unit/model_executor/test_pool_configurator.py @@ -1163,7 +1163,7 @@ class TestSWAPoolFloor(CustomTestCase): cfg = object.__new__(DSV4PoolConfigurator) cfg.swa_ratio = 0.1 cfg.sliding_window_size = 128 - cfg.swa_page_size = 128 + cfg.swa_page_size = page_size cfg.c4_ring_size = 8 cfg.c4_shrink_factor = 1 cfg._unified = unified @@ -1183,8 +1183,9 @@ class TestSWAPoolFloor(CustomTestCase): sizes = self._dsv4_sizes(max_tokens=32768, page_size=256) self.assertEqual(sizes.full_max_total_num_tokens, 32768) self.assertEqual(sizes.swa_max_total_num_tokens, 3072) - # Non-unified: the c4 state pool scales with the paged SWA pool. - self.assertEqual(sizes.c4_state_pool_size, 3072 // 128 * 8) + # Non-unified: the c4 state pool scales with the paged SWA pool, and + # is sized by the page the ring is addressed by (not the window). + self.assertEqual(sizes.c4_state_pool_size, 3072 // 256 * 8) def test_dsv4_token_cap_never_grows_total_footprint(self): """Regression: the token-cap path subtracts no fixed-pool bias, so