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
a169b9f8
Unverified
Commit
a169b9f8
authored
Mar 30, 2025
by
Zhiqiang Xie
Committed by
GitHub
Mar 30, 2025
Browse files
Fix oom error for large page size (#4913)
Co-authored-by:
Lianmin Zheng
<
lianminzheng@gmail.com
>
parent
4a63bc32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
python/sglang/srt/managers/schedule_batch.py
python/sglang/srt/managers/schedule_batch.py
+20
-12
test/srt/test_eagle_infer.py
test/srt/test_eagle_infer.py
+1
-1
No files found.
python/sglang/srt/managers/schedule_batch.py
View file @
a169b9f8
...
@@ -814,11 +814,11 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
...
@@ -814,11 +814,11 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
last_loc
:
torch
.
Tensor
,
last_loc
:
torch
.
Tensor
,
backup_state
:
bool
=
False
,
backup_state
:
bool
=
False
,
):
):
if
self
.
tree_cache
is
not
None
:
if
(
if
(
self
.
token_to_kv_pool_allocator
.
available_size
()
self
.
token_to_kv_pool_allocator
.
available_size
()
<
len
(
seq_lens
)
*
self
.
token_to_kv_pool_allocator
.
page_size
<
len
(
seq_lens
)
*
self
.
token_to_kv_pool_allocator
.
page_size
):
):
if
self
.
tree_cache
is
not
None
:
self
.
tree_cache
.
evict
(
self
.
tree_cache
.
evict
(
len
(
seq_lens
)
*
self
.
token_to_kv_pool_allocator
.
page_size
,
len
(
seq_lens
)
*
self
.
token_to_kv_pool_allocator
.
page_size
,
)
)
...
@@ -1116,17 +1116,25 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
...
@@ -1116,17 +1116,25 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
# TODO (lianmin): Revisit this. It should be seq_len - 1
# TODO (lianmin): Revisit this. It should be seq_len - 1
self
.
extend_logprob_start_lens
.
extend
([
0
]
*
running_bs
)
self
.
extend_logprob_start_lens
.
extend
([
0
]
*
running_bs
)
def
check_decode_mem
(
self
,
buf_multiplier
=
1
):
def
new_page_count_next_decode
(
self
):
bs
=
len
(
self
.
reqs
)
*
buf_multiplier
page_size
=
self
.
token_to_kv_pool_allocator
.
page_size
if
self
.
token_to_kv_pool_allocator
.
available_size
()
>=
bs
:
if
page_size
==
1
:
return
True
return
len
(
self
.
reqs
)
return
sum
(
1
for
req
in
self
.
reqs
if
req
.
seqlen
%
page_size
==
0
)
self
.
tree_cache
.
evict
(
bs
)
def
check_decode_mem
(
self
,
buf_multiplier
=
1
):
tokens_required
=
(
self
.
new_page_count_next_decode
()
*
buf_multiplier
*
self
.
token_to_kv_pool_allocator
.
page_size
)
if
self
.
token_to_kv_pool_allocator
.
available_size
()
>=
bs
:
if
self
.
token_to_kv_pool_allocator
.
available_size
()
>=
tokens_required
:
return
True
return
True
return
False
self
.
tree_cache
.
evict
(
tokens_required
)
return
self
.
token_to_kv_pool_allocator
.
available_size
()
>=
tokens_required
def
retract_decode
(
self
,
server_args
:
ServerArgs
):
def
retract_decode
(
self
,
server_args
:
ServerArgs
):
"""Retract the decoding requests when there is not enough memory."""
"""Retract the decoding requests when there is not enough memory."""
...
...
test/srt/test_eagle_infer.py
View file @
a169b9f8
...
@@ -144,7 +144,7 @@ class TestEAGLEEngine(CustomTestCase):
...
@@ -144,7 +144,7 @@ class TestEAGLEEngine(CustomTestCase):
if
engine
.
server_args
.
model_path
==
DEFAULT_EAGLE_TARGET_MODEL_FOR_TEST
:
if
engine
.
server_args
.
model_path
==
DEFAULT_EAGLE_TARGET_MODEL_FOR_TEST
:
self
.
assertGreater
(
acc_length
,
3.6
)
self
.
assertGreater
(
acc_length
,
3.6
)
else
:
else
:
self
.
assertGreater
(
acc_length
,
2.
6
)
self
.
assertGreater
(
acc_length
,
2.
5
)
class
TestEAGLEEngineTokenMap
(
TestEAGLEEngine
):
class
TestEAGLEEngineTokenMap
(
TestEAGLEEngine
):
...
...
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