Skip to content

Commit 1146c8f

Browse files
author
none
committed
fix
1 parent 36d69d1 commit 1146c8f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

lightllm/server/core/objs/req.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,8 @@ class Req(ctypes.Structure):
7777
("prompt_cache_len", ctypes.c_int), # 用于记录prompt cache 的命中长度,用于统计
7878
("is_paused", ctypes.c_bool), # 标记一个Req因为显存资源管理的原因被临时暂停了。
7979
("finish_status", FinishStatus),
80+
# 这个标记变量是http_server 写入,其他进程读取,用于标记该请求是否因为断网被aborted。
8081
("is_aborted", ctypes.c_bool),
81-
# 这个标记变量是router进程读取到is_aborted信息后,router 进程标记该请求已经被abort处理
82-
# 等待推理进程处理,防止router进程反复给推理进程发送abort指令。
83-
("router_aborted", ctypes.c_bool),
8482
# 当FinishStatus 是正常结束状态时,finish_token_index 用于标识结束的
8583
# token 的index位置
8684
("finish_token_index", ctypes.c_int),
@@ -100,7 +98,8 @@ class Req(ctypes.Structure):
10098
("mtp_accepted_token_num", ctypes.c_int),
10199
# mtp_step 保存一个mtp使用的常量参数,用于快速访问,不会被外部输入初始化
102100
("_mtp_step", ctypes.c_int),
103-
# stop_str_matched用于判断停止字符串是否匹配成功
101+
# stop_str_matched 用于判断停止字符串是否匹配成功, detokenization 进程写入,router 进程读取
102+
# 然后router发停止命令给推理进程,推理进程停止输出
104103
("stop_str_matched", ctypes.c_bool),
105104
]
106105

@@ -129,7 +128,6 @@ def init(
129128
self.is_paused = False
130129
self.finish_status = FinishStatus()
131130
self.is_aborted = False
132-
self.router_aborted = False
133131
self.shm_infer_released = False
134132
self.shm_cur_kv_len = 0
135133
self.shm_cur_output_len = 0

lightllm/server/router/manager.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ def _get_aborted_reqs_from_running_batch(self) -> List[Req]:
332332
if self.running_batch is None:
333333
return ans
334334
for req in self.running_batch.reqs:
335-
if req.is_aborted and req.router_aborted is False:
336-
req.router_aborted = True
335+
if req.is_aborted and req._router_aborted is False:
336+
req._router_aborted = True
337337
ans.append(req)
338338
return ans
339339

@@ -342,7 +342,8 @@ def _get_stop_str_reqs_from_running_batch(self) -> List[Req]:
342342
if self.running_batch is None:
343343
return ans
344344
for req in self.running_batch.reqs:
345-
if req.stop_str_matched:
345+
if req.stop_str_matched and req._router_stop_str_matched is False:
346+
req._router_stop_str_matched = True
346347
ans.append(req)
347348
return ans
348349

@@ -382,6 +383,11 @@ def _add_req(self, group_req_indexes: GroupReqIndexes):
382383
req = self.shm_req_manager.get_req_obj_by_index(req_index)
383384
req.multimodal_params = group_req_indexes.multimodal_params
384385
req.start_time = group_req_indexes.time_mark
386+
# 附加一个私有标记变量,标记请求是否已经被router发送过abort命令给推理进程,
387+
# 防止反复发送abort命令给推理进程
388+
req._router_aborted = False
389+
# 作用同 _router_aborted 类似
390+
req._router_stop_str_matched = False
385391
req_group.append(req)
386392

387393
logger.info(f"router recive req id {req.request_id} cost time {time.time() - req.start_time} s")

lightllm/server/router/model_infer/infer_batch.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ def update_finish_status(self, eos_ids, output_len: int):
392392
self.finish_status.set_status(FinishStatus.FINISHED_LENGTH)
393393
return
394394

395-
def is_finished_or_aborted(self):
396-
return self.finish_status.is_finished() or self.shm_req.router_aborted
397-
398395
def _stop_sequences_matched(self, output_len: int):
399396
for stop_token_ids in self.stop_sequences:
400397
stop_len = len(stop_token_ids)

0 commit comments

Comments
 (0)