[Fix] Use real ReqKvInfo in unit-test req mocks (#37339)

This commit is contained in:
Liangsheng Yin
2026-08-31 20:25:51 -07:00
committed by GitHub
parent 60f881b40c
commit 3b14f37b74
7 changed files with 20 additions and 11 deletions
@@ -11,6 +11,7 @@ from unittest.mock import patch
import torch
from sglang.srt.managers.schedule_batch import ReqKvInfo
from sglang.srt.mem_cache.allocator.base import BaseTokenToKVPoolAllocator
from sglang.srt.mem_cache.allocator.paged import PagedTokenToKVPoolAllocator
from sglang.srt.mem_cache.common import _release_overallocated_kv_indices
@@ -131,7 +132,7 @@ class TestFreeSegment(unittest.TestCase):
token_to_kv_pool_allocator=alloc,
req_to_token_pool=SimpleNamespace(req_to_token=row.unsqueeze(0)),
)
req = SimpleNamespace(kv=SimpleNamespace(req_pool_idx=0))
req = SimpleNamespace(kv=ReqKvInfo(req_pool_idx=0))
before = len(alloc.free_pages)
alloc.free_group_begin()
@@ -27,7 +27,6 @@ import random
import unittest
import unittest.mock
from array import array
from types import SimpleNamespace
import torch
@@ -39,6 +38,7 @@ from sglang.srt.disaggregation.kv_events import (
BlockStoredWithMetadata,
StorageMedium,
)
from sglang.srt.managers.schedule_batch import ReqKvInfo
from sglang.srt.mem_cache.allocator.token import TokenToKVPoolAllocator
from sglang.srt.mem_cache.base_prefix_cache import (
EvictParams,
@@ -518,7 +518,7 @@ class TestRadixCache(unittest.TestCase):
)
cache.req_to_token_pool = ReqToTokenPool(request_indices.clone())
req = unittest.mock.Mock(
kv=SimpleNamespace(req_pool_idx=0, cache_protected_len=0),
kv=ReqKvInfo(req_pool_idx=0, cache_protected_len=0),
extra_key=None,
cache_salt=None,
priority=0,