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
3029d301
Unverified
Commit
3029d301
authored
Oct 27, 2025
by
cctry
Committed by
GitHub
Oct 27, 2025
Browse files
Fix crash after flush cache (#12107)
Co-authored-by:
fzyzcjy
<
5236035+fzyzcjy@users.noreply.github.com
>
parent
f389f017
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
python/sglang/srt/managers/scheduler.py
python/sglang/srt/managers/scheduler.py
+21
-4
python/sglang/srt/mem_cache/radix_cache.py
python/sglang/srt/mem_cache/radix_cache.py
+4
-0
No files found.
python/sglang/srt/managers/scheduler.py
View file @
3029d301
...
@@ -2305,13 +2305,30 @@ class Scheduler(
...
@@ -2305,13 +2305,30 @@ class Scheduler(
if_success
=
False
if_success
=
False
return
ClearHiCacheReqOutput
(
success
=
if_success
)
return
ClearHiCacheReqOutput
(
success
=
if_success
)
def
flush_cache
(
self
):
def
_is_no_request
(
self
):
"""Flush the memory pool and cache."""
no_request
=
(
if
(
len
(
self
.
waiting_queue
)
==
0
len
(
self
.
waiting_queue
)
==
0
and
self
.
running_batch
.
is_empty
()
and
self
.
running_batch
.
is_empty
()
and
(
self
.
last_batch
is
None
or
self
.
last_batch
.
is_empty
())
and
(
self
.
cur_batch
is
None
or
self
.
cur_batch
.
is_empty
())
and
(
not
self
.
enable_overlap
or
len
(
self
.
result_queue
)
==
0
)
and
(
self
.
pp_size
==
1
or
all
(
x
.
is_empty
()
for
x
in
self
.
running_mbs
))
and
(
self
.
pp_size
==
1
or
all
(
x
.
is_empty
()
for
x
in
self
.
running_mbs
))
):
)
if
self
.
disaggregation_mode
==
DisaggregationMode
.
PREFILL
:
no_request
&=
(
len
(
self
.
disagg_prefill_bootstrap_queue
.
queue
)
==
0
and
len
(
self
.
disagg_prefill_inflight_queue
)
==
0
)
if
self
.
disaggregation_mode
==
DisaggregationMode
.
DECODE
:
no_request
&=
(
len
(
self
.
disagg_decode_prealloc_queue
.
queue
)
==
0
and
len
(
self
.
disagg_decode_transfer_queue
.
queue
)
==
0
)
return
no_request
def
flush_cache
(
self
):
"""Flush the memory pool and cache."""
if
self
.
_is_no_request
():
self
.
cur_batch
=
None
self
.
cur_batch
=
None
self
.
last_batch
=
None
self
.
last_batch
=
None
self
.
tree_cache
.
reset
()
self
.
tree_cache
.
reset
()
...
...
python/sglang/srt/mem_cache/radix_cache.py
View file @
3029d301
...
@@ -533,6 +533,10 @@ class RadixCache(BasePrefixCache):
...
@@ -533,6 +533,10 @@ class RadixCache(BasePrefixCache):
self
.
protected_size_
-=
len
(
node
.
key
)
self
.
protected_size_
-=
len
(
node
.
key
)
delta
+=
len
(
node
.
key
)
delta
+=
len
(
node
.
key
)
node
.
lock_ref
-=
1
node
.
lock_ref
-=
1
if
node
.
parent
is
None
:
assert
(
node
is
self
.
root_node
),
f
"This request holds the node from another tree"
node
=
node
.
parent
node
=
node
.
parent
return
delta
return
delta
...
...
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