Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
5cc0d25a
"vscode:/vscode.git/clone" did not exist on "12ced4f39ee4eec4c13fdfdf2915acc3192fef0b"
Unverified
Commit
5cc0d25a
authored
Oct 31, 2025
by
Liangsheng Yin
Committed by
GitHub
Oct 31, 2025
Browse files
Add trait for `BasePrefixCache` (#12436)
parent
a076ec1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
python/sglang/srt/mem_cache/base_prefix_cache.py
python/sglang/srt/mem_cache/base_prefix_cache.py
+23
-4
No files found.
python/sglang/srt/mem_cache/base_prefix_cache.py
View file @
5cc0d25a
from
__future__
import
annotations
from
abc
import
ABC
,
abstractmethod
from
typing
import
TYPE_CHECKING
,
Any
,
NamedTuple
,
Optional
,
Tuple
from
typing
import
(
TYPE_CHECKING
,
Any
,
NamedTuple
,
Optional
,
Protocol
,
Tuple
,
runtime_checkable
,
)
import
torch
from
sglang.srt.mem_cache.allocator
import
BaseTokenToKVPoolAllocator
from
sglang.srt.mem_cache.memory_pool
import
ReqToTokenPool
if
TYPE_CHECKING
:
from
sglang.srt.managers.schedule_batch
import
Req
else
:
Req
=
Any
# Placeholder for Req type when not type checking
@
runtime_checkable
class
PrefixCacheTrait
(
Protocol
):
req_to_token_pool
:
ReqToTokenPool
token_to_kv_pool_allocator
:
BaseTokenToKVPoolAllocator
page_size
:
int
disable
:
bool
class
MatchResult
(
NamedTuple
):
...
...
@@ -28,7 +47,7 @@ class MatchResult(NamedTuple):
host_hit_length
:
int
=
0
class
BasePrefixCache
(
ABC
):
class
BasePrefixCache
(
ABC
,
PrefixCacheTrait
):
"""Cache can be indexed by either rid or key."""
@
abstractmethod
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment