From d1a731176cd8ba9cc140e094a84ae4c0515bb202 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 05:12:17 +0000 Subject: [PATCH] fix: guard empty free_token_index in InferBatch._filter For linear-attention mixed models (e.g. Qwen3.5), a request aborted before any kv is generated (cur_kv_len == 0) makes _linear_att_free_req return without appending anything. custom_cat then crashes with 'IndexError: list index out of range' on the empty list, killing the infer_loop thread. Skip custom_cat when the list is empty, matching the existing guard in pause_reqs. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_018e7Le4MGpdfA1LdPRShk3f --- lightllm/server/router/model_infer/infer_batch.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lightllm/server/router/model_infer/infer_batch.py b/lightllm/server/router/model_infer/infer_batch.py index c12acf8b4..0d8b4d3c2 100644 --- a/lightllm/server/router/model_infer/infer_batch.py +++ b/lightllm/server/router/model_infer/infer_batch.py @@ -281,7 +281,12 @@ def _filter(self, finished_request_ids: List[int]): req.shm_req.shm_infer_released = True self.shm_req_manager.put_back_req_obj(req.shm_req) - free_token_index = custom_cat(free_token_index) + # 线性注意力混合模型下,请求可能在未产生任何 kv (cur_kv_len == 0) 时被 abort, + # 此时 free_token_index 为空列表,custom_cat 无法处理空输入。 + if len(free_token_index) != 0: + free_token_index = custom_cat(free_token_index) + else: + free_token_index = [] self.req_manager.free(free_req_index, free_token_index) finished_req_ids_set = set(finished_request_ids)