[Fix] Remove min_tokens from prefill request to avoid max_tokens conflict in PD disaggregation mode - #1295
Open
NinSang wants to merge 1 commit into
Open
Conversation
在 proxy 给 prefiller 设置 max_tokens=1 的同时删除 min_tokens, 避免 min_tokens > max_tokens 导致 vLLM 后端报错。 Co-Authored-By: Kscc <noreply@owtffssent.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using the PD disaggregation mode, the proxy server modifies the prefill request by setting max_tokens=1 (since the prefill stage only
needs to compute KV cache, not generate full output). However, if the original request contains a min_tokens parameter, it is passed through
unchanged. This causes a conflict where min_tokens > max_tokens (e.g., min_tokens=100, max_tokens=1), resulting in an Internal Server Error
(HTTP 500) from the vLLM backend.
Reproduction:
curl -s -X POST http://:/v1/chat/completions
-H 'Content-Type: application/json'
-d '{"model":"qwen3.6","messages":[{"role":"user","content":"你好"}],"stream":true,"max_tokens":500,"min_tokens":100}'
The same request without min_tokens works correctly.
Fix
Remove min_tokens from the prefill request data in both places where max_tokens is overridden to 1:
The min_tokens constraint is still respected in the decode stage, since the original request (with min_tokens intact) is forwarded to the
decoder for full output generation.
Diff
diff --git a/ucm/pd/toy_proxy_server.py b/ucm/pd/toy_proxy_server.py
index f338bf5..efa7593 100644
--- a/ucm/pd/toy_proxy_server.py
+++ b/ucm/pd/toy_proxy_server.py
@@ -200,6 +200,8 @@ async def send_request_to_service(
req_data["max_tokens"] = 1
if "stream_options" in req_data:
del req_data["stream_options"]
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
"X-Request-Id": request_id,
@@ -252,6 +254,8 @@ async def _handle_completions(api: str, request: Request):
prefill_req_data["max_tokens"] = 1
if "stream_options" in prefill_req_data:
del prefill_req_data["stream_options"]
Files Changed