[Bugfix] Fix negative max_tokens when input prompt is too long (#36789)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
This commit is contained in:
Isotr0py
2026-03-11 16:30:51 +00:00
committed by GitHub
parent 741ecf0630
commit c84b519cf3
2 changed files with 19 additions and 0 deletions
+5
View File
@@ -178,6 +178,11 @@ def get_max_tokens(
default_sampling_params: dict,
override_max_tokens: int | None = None,
) -> int:
if max_model_len < input_length:
raise ValueError(
f"Input length ({input_length}) exceeds model's maximum "
f"context length ({max_model_len})."
)
model_max_tokens = max_model_len - input_length
platform_max_tokens = current_platform.get_max_output_tokens(input_length)
fallback_max_tokens = (