[UnifiedTree]: move /mem_cache/unifed_cache_component dir to /mem_cache/unified_cache (#32484)

This commit is contained in:
Zhangheng
2026-07-28 16:28:21 +08:00
committed by GitHub
parent fc8b328f5c
commit 60d6914f17
23 changed files with 62 additions and 62 deletions
@@ -17,10 +17,10 @@ import torch
from sglang.srt.mem_cache.base_prefix_cache import EvictParams, InsertResult
from sglang.srt.mem_cache.memory_pool import ReqToTokenPool
from sglang.srt.mem_cache.unified_cache_components.mamba_component import (
from sglang.srt.mem_cache.unified_cache.components.mamba_component import (
MambaComponent,
)
from sglang.srt.mem_cache.unified_cache_components.tree_component import TreeComponent
from sglang.srt.mem_cache.unified_cache.components.tree_component import TreeComponent
_CACHE_ATTRS = ("offset", "lengths", "left_padding")
_MISSING = object()
@@ -31,7 +31,7 @@ if TYPE_CHECKING:
CacheAction,
ComponentAction,
)
from sglang.srt.mem_cache.unified_cache_components.tree_component import (
from sglang.srt.mem_cache.unified_cache.components.tree_component import (
ComponentType,
)
@@ -8,8 +8,8 @@ import torch
if TYPE_CHECKING:
from sglang.srt.mem_cache.allocator import BaseTokenToKVPoolAllocator
from sglang.srt.mem_cache.memory_pool import ReqToTokenPool
from sglang.srt.mem_cache.unified_cache_components import ComponentType
from sglang.srt.mem_cache.unified_cache_components.tree_component import (
from sglang.srt.mem_cache.unified_cache.components import ComponentType
from sglang.srt.mem_cache.unified_cache.components.tree_component import (
TreeComponent,
)
@@ -27,7 +27,7 @@ from sglang.srt.mem_cache.pool_host.mha import (
get_mha_host_pool_cls,
)
from sglang.srt.mem_cache.pool_host.mla import MLATokenToKVPoolHost
from sglang.srt.mem_cache.unified_cache_components import ComponentType
from sglang.srt.mem_cache.unified_cache.components import ComponentType
if TYPE_CHECKING:
import torch
+1 -1
View File
@@ -166,7 +166,7 @@ def _create_unified_radix_cache(
params: CacheInitParams,
) -> BasePrefixCache:
"""Initialize a UnifiedRadixCache with proper components and optional HiCache."""
from sglang.srt.mem_cache.unified_cache_components import ComponentType
from sglang.srt.mem_cache.unified_cache.components import ComponentType
from sglang.srt.mem_cache.unified_radix_cache import UnifiedRadixCache
tree_components = [ComponentType.FULL]
@@ -5,7 +5,7 @@
events -- the only object that touches that state; no scheduling policy or IO,
and never touches the cache. References the cache-owned component drivers to
drive their tree-level hooks.
- **Components** (``unified_cache_components.TreeComponent`` subclasses): the
- **Components** (``unified_cache.components.TreeComponent`` subclasses): the
per-component (FULL/SWA/MAMBA) drivers. Built and owned by the Controller;
hold the cache for cache-level logic and the TreeCore for tree state.
- **Controller** (``unified_radix_cache.UnifiedRadixCache``): the scheduling brain
@@ -1,7 +1,7 @@
from sglang.srt.mem_cache.unified_cache_components.full_component import FullComponent
from sglang.srt.mem_cache.unified_cache_components.mamba_component import MambaComponent
from sglang.srt.mem_cache.unified_cache_components.swa_component import SWAComponent
from sglang.srt.mem_cache.unified_cache_components.tree_component import (
from sglang.srt.mem_cache.unified_cache.components.full_component import FullComponent
from sglang.srt.mem_cache.unified_cache.components.mamba_component import MambaComponent
from sglang.srt.mem_cache.unified_cache.components.swa_component import SWAComponent
from sglang.srt.mem_cache.unified_cache.components.tree_component import (
_NUM_COMPONENT_TYPES,
BASE_COMPONENT_TYPE,
CacheTransferPhase,
@@ -18,7 +18,7 @@ from sglang.srt.mem_cache.hicache_storage import (
PoolTransferResult,
)
from sglang.srt.mem_cache.unified_cache.cache_action import FreeComponentDeviceSlot
from sglang.srt.mem_cache.unified_cache_components.tree_component import (
from sglang.srt.mem_cache.unified_cache.components.tree_component import (
CacheTransferPhase,
ComponentType,
EvictLayer,
@@ -25,7 +25,7 @@ from sglang.srt.mem_cache.unified_cache.cache_action import (
FreeComponentHostSlot,
MambaEvictExcessPathStates,
)
from sglang.srt.mem_cache.unified_cache_components.tree_component import (
from sglang.srt.mem_cache.unified_cache.components.tree_component import (
CacheTransferPhase,
ComponentType,
EvictLayer,
@@ -27,7 +27,7 @@ from sglang.srt.mem_cache.unified_cache.cache_action import (
RecoverSWAWithLockedFull,
SWARebuild,
)
from sglang.srt.mem_cache.unified_cache_components.tree_component import (
from sglang.srt.mem_cache.unified_cache.components.tree_component import (
BASE_COMPONENT_TYPE,
CacheTransferPhase,
ComponentType,
@@ -13,10 +13,10 @@ from typing import TYPE_CHECKING, Callable, Optional
if TYPE_CHECKING:
from sglang.srt.mem_cache.cache_init_params import CacheInitParams
from sglang.srt.mem_cache.unified_cache.component_type import ComponentType
from sglang.srt.mem_cache.unified_cache.components import TreeComponent
from sglang.srt.mem_cache.unified_cache.unified_tree_core_interface import (
UnifiedTreeCoreInterface,
)
from sglang.srt.mem_cache.unified_cache_components import TreeComponent
TreeCoreFactory = Callable[
["CacheInitParams", "dict[ComponentType, TreeComponent]"],
@@ -49,6 +49,17 @@ from sglang.srt.mem_cache.unified_cache.cache_action import (
FreeDeviceKV,
ReplaceWriteThroughOnNodeSplit,
)
from sglang.srt.mem_cache.unified_cache.components import (
_NUM_COMPONENT_TYPES,
BASE_COMPONENT_TYPE,
CacheTransferPhase,
ComponentData,
ComponentType,
EvictLayer,
LRURefreshPhase,
TreeComponent,
get_and_increase_time_counter,
)
from sglang.srt.mem_cache.unified_cache.unified_tree_core_interface import (
DecSwaLockOnlyResult,
DemoteResult,
@@ -61,17 +72,6 @@ from sglang.srt.mem_cache.unified_cache.unified_tree_core_interface import (
RadixCacheWalkResult,
UnifiedTreeCoreInterface,
)
from sglang.srt.mem_cache.unified_cache_components import (
_NUM_COMPONENT_TYPES,
BASE_COMPONENT_TYPE,
CacheTransferPhase,
ComponentData,
ComponentType,
EvictLayer,
LRURefreshPhase,
TreeComponent,
get_and_increase_time_counter,
)
from sglang.srt.mem_cache.utils import (
compute_node_hash_values,
get_eviction_strategy,
@@ -102,14 +102,14 @@ if TYPE_CHECKING:
CacheAction,
ComponentAction,
)
from sglang.srt.mem_cache.unified_cache.components import (
CacheTransferPhase,
ComponentType,
)
from sglang.srt.mem_cache.unified_cache.unified_tree_core import (
StorageBackupSpec,
UnifiedTreeNode,
)
from sglang.srt.mem_cache.unified_cache_components import (
CacheTransferPhase,
ComponentType,
)
class UnifiedTreeCoreInterface(KVCacheEventMixin, ABC):
@@ -41,17 +41,10 @@ from sglang.srt.mem_cache.unified_cache.cache_action import (
FreeDeviceKV,
ReplaceWriteThroughOnNodeSplit,
)
from sglang.srt.mem_cache.unified_cache.tree_core_registry import create_tree_core
from sglang.srt.mem_cache.unified_cache.unified_tree_core import ( # noqa: F401
NodeId,
UnifiedLRUList,
UnifiedTreeCore,
UnifiedTreeNode,
)
# UnifiedTreeNode / UnifiedLRUList live on the tree core; re-exported here
# because other modules and tests import them from this module.
from sglang.srt.mem_cache.unified_cache_components import (
from sglang.srt.mem_cache.unified_cache.components import (
BASE_COMPONENT_TYPE,
CacheTransferPhase,
ComponentType,
@@ -61,6 +54,13 @@ from sglang.srt.mem_cache.unified_cache_components import (
SWAComponent,
TreeComponent,
)
from sglang.srt.mem_cache.unified_cache.tree_core_registry import create_tree_core
from sglang.srt.mem_cache.unified_cache.unified_tree_core import ( # noqa: F401
NodeId,
UnifiedLRUList,
UnifiedTreeCore,
UnifiedTreeNode,
)
from sglang.srt.observability.metrics_collector import (
STAT_LOGGER_ROLE_STORAGE,
StorageMetricsCollector,