[Performance] Decode Offload improves the long texts performance 100% through dynamic block offload. (#17216)

Co-authored-by: zhangheng <hzh0425@apache.org>
This commit is contained in:
yuyu5333
2026-03-08 17:16:53 +08:00
committed by GitHub
co-authored by zhangheng
parent 97a2a9be0f
commit 230fb55899
8 changed files with 290 additions and 33 deletions
@@ -25,9 +25,11 @@ def _make_mock_req(
kv_committed_len: int,
kv_allocated_len: int,
prefix_indices_len: int = 0,
rid: int = 0,
):
"""Create a mock Req with the KV cache state needed for testing."""
req = MagicMock()
req.rid = rid
req.req_pool_idx = req_pool_idx
req.kv_committed_len = kv_committed_len
req.kv_allocated_len = kv_allocated_len
@@ -74,6 +76,7 @@ def _make_manager(pool_size: int, page_size: int = 1):
manager.token_to_kv_pool_allocator = allocator
manager.page_size = page_size
manager.tree_cache = tree_cache
manager.offloaded_state = {}
return manager, freed_indices
@@ -169,7 +172,7 @@ class TestReleaseFinishedReq(unittest.TestCase):
prefix_indices_len=5,
)
manager._release_finished_req(req, prefill_offloaded_len=0)
manager._release_finished_req(req, start_offset=0)
self.assertEqual(manager.tree_cache.protected_size_, 5)