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
3dde8619
Unverified
Commit
3dde8619
authored
Aug 01, 2025
by
pansicheng
Committed by
GitHub
Jul 31, 2025
Browse files
Conditionally import HiCacheHF3FS (#8598)
Co-authored-by:
Zhiqiang Xie
<
xiezhq@stanford.edu
>
parent
b7170cc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
python/sglang/srt/managers/cache_controller.py
python/sglang/srt/managers/cache_controller.py
+19
-16
No files found.
python/sglang/srt/managers/cache_controller.py
View file @
3dde8619
...
...
@@ -25,12 +25,6 @@ if TYPE_CHECKING:
from
sglang.srt.mem_cache.allocator
import
BaseTokenToKVPoolAllocator
from
sglang.srt.mem_cache.memory_pool_host
import
HostKVCache
from
sglang.srt.mem_cache.hicache_storage
import
HiCacheFile
,
get_hash_str
from
sglang.srt.mem_cache.mooncake_store.mooncake_store
import
(
MooncakeStore
,
get_hash_str_mooncake
,
)
from
sglang.srt.mem_cache.storage.hf3fs.storage_hf3fs
import
HiCacheHF3FS
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -251,16 +245,7 @@ class HiCacheController:
self
.
enable_storage
=
False
# todo: move backend initialization to storage backend module
if
storage_backend
is
not
None
:
# create a new communication group for synchronizing storage operations across TP workers
self
.
tp_world_size
=
torch
.
distributed
.
get_world_size
(
group
=
tp_group
)
if
self
.
tp_world_size
>
1
:
group_ranks
=
torch
.
distributed
.
get_process_group_ranks
(
tp_group
)
self
.
prefetch_tp_group
=
torch
.
distributed
.
new_group
(
group_ranks
,
backend
=
"gloo"
)
self
.
backup_tp_group
=
torch
.
distributed
.
new_group
(
group_ranks
,
backend
=
"gloo"
)
from
sglang.srt.mem_cache.hicache_storage
import
HiCacheFile
,
get_hash_str
if
storage_backend
==
"file"
:
self
.
storage_backend
=
HiCacheFile
()
...
...
@@ -271,11 +256,19 @@ class HiCacheController:
self
.
storage_backend
=
HiCacheNixl
()
self
.
get_hash_str
=
get_hash_str
elif
storage_backend
==
"mooncake"
:
from
sglang.srt.mem_cache.mooncake_store.mooncake_store
import
(
MooncakeStore
,
get_hash_str_mooncake
,
)
self
.
storage_backend
=
MooncakeStore
()
self
.
get_hash_str
=
get_hash_str_mooncake
self
.
storage_backend
.
register_buffer
(
self
.
mem_pool_host
.
kv_buffer
)
elif
storage_backend
==
"hf3fs"
:
from
sglang.srt.distributed
import
get_tensor_model_parallel_rank
from
sglang.srt.mem_cache.storage.hf3fs.storage_hf3fs
import
(
HiCacheHF3FS
,
)
rank
=
get_tensor_model_parallel_rank
()
bytes_per_page
=
(
...
...
@@ -293,6 +286,16 @@ class HiCacheController:
self
.
enable_storage
=
True
# todo: threshold policy for prefetching
self
.
prefetch_threshold
=
max
(
prefetch_threshold
,
self
.
page_size
)
# create a new communication group for synchronizing storage operations across TP workers
self
.
tp_world_size
=
torch
.
distributed
.
get_world_size
(
group
=
tp_group
)
if
self
.
tp_world_size
>
1
:
group_ranks
=
torch
.
distributed
.
get_process_group_ranks
(
tp_group
)
self
.
prefetch_tp_group
=
torch
.
distributed
.
new_group
(
group_ranks
,
backend
=
"gloo"
)
self
.
backup_tp_group
=
torch
.
distributed
.
new_group
(
group_ranks
,
backend
=
"gloo"
)
self
.
load_cache_event
=
load_cache_event
self
.
layer_done_counter
=
LayerDoneCounter
(
self
.
mem_pool_device
.
layer_num
)
...
...
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