Fix/hisparse host backed max request length (#28753)

Co-authored-by: huangtingwei <141888744+huangtingwei9988@users.noreply.github.com>
Co-authored-by: Zhangheng <hzh0425@apache.org>
This commit is contained in:
ybyang
2026-08-10 16:58:13 +08:00
committed by GitHub
co-authored by huangtingwei Zhangheng
parent b51bf9ec9e
commit a76a167812
3 changed files with 212 additions and 4 deletions
+7 -2
View File
@@ -656,9 +656,14 @@ class DecodePreallocQueue(DecodeHiCachePreallocMixin):
return len(req.origin_input_ids) + max(len(req.output_ids) - 1, 0)
def _check_if_req_exceed_kv_capacity(self, req: Req) -> bool:
# HiSparse admits up to the host-backed logical capacity.
if self.scheduler.enable_hisparse:
capacity = self.scheduler.tp_worker.model_runner.max_token_pool_size
else:
capacity = self.max_total_num_tokens
input_len = self._rebootstrap_prefill_len(req)
if input_len > self.max_total_num_tokens:
message = f"Request {req.rid} exceeds the maximum number of tokens: {input_len} > {self.max_total_num_tokens}"
if input_len > capacity:
message = f"Request {req.rid} exceeds the maximum number of tokens: {input_len} > {capacity}"
logger.error(message)
prepare_abort(req, message, status_code=HTTPStatus.BAD_REQUEST)
self.scheduler.output_streamer.stream_output([req], req.return_logprob)
@@ -997,7 +997,7 @@ class ModelRunner:
RoutedExpertsCapturer.create(
model=self.model,
model_config=self.model_config,
num_tokens=self.max_total_num_tokens + self.page_size,
num_tokens=self.max_token_pool_size + self.page_size,
max_running_requests=self.max_running_requests,
device=self.device,
)
@@ -1007,7 +1007,7 @@ class ModelRunner:
set_global_indexer_capturer(
create_indexer_capturer(
model_config=self.model_config,
num_tokens=self.max_total_num_tokens + self.page_size,
num_tokens=self.max_token_pool_size + self.page_size,
max_running_requests=self.max_running_requests,
device=self.device,
)
@@ -1244,6 +1244,16 @@ class ModelRunner:
else:
return self.max_total_num_tokens
@property
def max_token_pool_size(self):
"""Return the max token pool size considering hybrid swa and hisparse settings."""
if self.enable_hisparse:
# HiSparse uses the host-backed full pool capacity.
size_full = getattr(self.token_to_kv_pool_allocator, "size_full", None)
if size_full is not None:
return size_full
return self.effective_max_total_num_tokens
def _load_format_scope(self, load_format: Optional[str]):
"""Make this runner's load format the published one while it loads.