Fix decode OOM caused by retraction (#14939)
This commit is contained in:
@@ -1609,6 +1609,7 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
|
|||||||
def retract_decode(
|
def retract_decode(
|
||||||
self,
|
self,
|
||||||
server_args: ServerArgs,
|
server_args: ServerArgs,
|
||||||
|
buf_multiplier: int = 1,
|
||||||
) -> Tuple[List[Req], float, List[Req]]:
|
) -> Tuple[List[Req], float, List[Req]]:
|
||||||
"""Retract the decoding requests when there is not enough memory."""
|
"""Retract the decoding requests when there is not enough memory."""
|
||||||
sorted_indices = list(range(len(self.reqs)))
|
sorted_indices = list(range(len(self.reqs)))
|
||||||
@@ -1630,7 +1631,9 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
|
|||||||
retracted_reqs = []
|
retracted_reqs = []
|
||||||
first_iter = True
|
first_iter = True
|
||||||
while first_iter or (
|
while first_iter or (
|
||||||
not self.check_decode_mem(selected_indices=sorted_indices)
|
not self.check_decode_mem(
|
||||||
|
selected_indices=sorted_indices, buf_multiplier=buf_multiplier
|
||||||
|
)
|
||||||
):
|
):
|
||||||
if len(sorted_indices) == 1:
|
if len(sorted_indices) == 1:
|
||||||
# Corner case: only one request left
|
# Corner case: only one request left
|
||||||
|
|||||||
@@ -1965,7 +1965,7 @@ class Scheduler(
|
|||||||
):
|
):
|
||||||
old_ratio = self.new_token_ratio
|
old_ratio = self.new_token_ratio
|
||||||
retracted_reqs, new_token_ratio, reqs_to_abort = batch.retract_decode(
|
retracted_reqs, new_token_ratio, reqs_to_abort = batch.retract_decode(
|
||||||
self.server_args
|
self.server_args, self.decode_mem_cache_buf_multiplier
|
||||||
)
|
)
|
||||||
self.num_retracted_reqs = len(retracted_reqs)
|
self.num_retracted_reqs = len(retracted_reqs)
|
||||||
self.new_token_ratio = new_token_ratio
|
self.new_token_ratio = new_token_ratio
|
||||||
|
|||||||
@@ -1666,7 +1666,9 @@ class ModelRunner:
|
|||||||
self.max_total_num_tokens = self.profile_max_num_token(total_gpu_memory)
|
self.max_total_num_tokens = self.profile_max_num_token(total_gpu_memory)
|
||||||
|
|
||||||
if (small_kv_size := envs.SGLANG_CI_SMALL_KV_SIZE.get()) > 0:
|
if (small_kv_size := envs.SGLANG_CI_SMALL_KV_SIZE.get()) > 0:
|
||||||
# Use a small KV cache pool size for local tests
|
logger.info(
|
||||||
|
f"Use a small KV cache pool size ({small_kv_size}) for local tests"
|
||||||
|
)
|
||||||
self.max_total_num_tokens = small_kv_size
|
self.max_total_num_tokens = small_kv_size
|
||||||
|
|
||||||
if max_num_reqs is None:
|
if max_num_reqs is None:
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ class TestEAGLERetract(TestEAGLEServerBasic):
|
|||||||
# These config helps find a leak.
|
# These config helps find a leak.
|
||||||
# FIXME(lsyin): use override context manager
|
# FIXME(lsyin): use override context manager
|
||||||
envs.SGLANG_CI_SMALL_KV_SIZE.set(4500)
|
envs.SGLANG_CI_SMALL_KV_SIZE.set(4500)
|
||||||
|
with envs.SGLANG_TEST_RETRACT.override(True):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user