From a5cd7c903905cd0b553dcfb1b4bc828e336d42f8 Mon Sep 17 00:00:00 2001 From: LiqinruiG <37392159+LiqinruiG@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:43:42 +0800 Subject: [PATCH] [BugFix] rollback max_tokens and min_tokens when continue to infer (#5082) * [BugFix] rollback max_tokens and min_tokens when continue to infer * [BugFix] rollback max_tokens and min_tokens when continue to infer * [fix] add more logger info: max_tokens --------- Co-authored-by: liqinrui --- fastdeploy/entrypoints/engine_client.py | 9 +++++++-- .../input/ernie4_5_vl_processor/ernie4_5_vl_processor.py | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fastdeploy/entrypoints/engine_client.py b/fastdeploy/entrypoints/engine_client.py index 8e9434501..07291c818 100644 --- a/fastdeploy/entrypoints/engine_client.py +++ b/fastdeploy/entrypoints/engine_client.py @@ -298,7 +298,12 @@ class EngineClient: if data.get("max_tokens") is not None: if data["max_tokens"] < 1 or data["max_tokens"] >= self.max_model_len: - raise ParameterError("max_tokens", f"max_tokens can be defined [1, {self.max_model_len}).") + api_server_logger.error( + f"req_id:{data['request_id']}, max_tokens must be defined [1, {self.max_model_len}), but now it's {data['max_tokens']}." + ) + raise ValueError( + f"max_tokens can be defined [1, {self.max_model_len}), but now it's {data['max_tokens']}." + ) if data.get("reasoning_max_tokens") is not None: if data["reasoning_max_tokens"] < 1: @@ -306,7 +311,7 @@ class EngineClient: if data["reasoning_max_tokens"] > data["max_tokens"]: data["reasoning_max_tokens"] = data["max_tokens"] api_server_logger.warning( - f"req_id: {data['request_id']}, reasoning_max_tokens exceeds max_tokens, the value of reasoning_max_tokens will be adjusted to match that of max_tokens" + f"req_id: {data['request_id']}, reasoning_max_tokens exceeds max_tokens, the value of reasoning_max_tokens will be adjusted to {data['max_tokens']}" ) if data.get("temperature") is not None and abs(data["temperature"]) < 1e-6: data["temperature"] = 1e-6 diff --git a/fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py b/fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py index 77c62125c..0fe724af5 100644 --- a/fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py +++ b/fastdeploy/input/ernie4_5_vl_processor/ernie4_5_vl_processor.py @@ -264,14 +264,12 @@ class Ernie4_5_VLProcessor(Ernie4_5Processor): if max_model_len is not None and len(request["prompt_token_ids"]) > max_model_len: request["prompt_token_ids"] = request["prompt_token_ids"][: max_model_len - 1] - tmp_max_tokens = 0 if request.get("max_tokens") is None: request["max_tokens"] = max(1, max_model_len - len(request["prompt_token_ids"])) - tmp_max_tokens = request["max_tokens"] else: request["max_tokens"] = min(max_model_len - len(request["prompt_token_ids"]), request["max_tokens"]) if request.get("reasoning_max_tokens") is None: - request["reasoning_max_tokens"] = max(int(tmp_max_tokens * 0.8), 1) + request["reasoning_max_tokens"] = max(int(request["max_tokens"] * 0.8), 1) data_processor_logger.info(f"Processed request {request}") if request.get("top_p") is not None and request.get("top_p") < _SAMPLING_EPS: