-
Notifications
You must be signed in to change notification settings - Fork 742
[Cherry-Pick] Fix PD interaction and error response #7539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
juncaipeng
wants to merge
1
commit into
PaddlePaddle:release/2.6
from
juncaipeng:release/2.6-pd-refine
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -614,10 +614,28 @@ async def chat_completion_full_generator( | |
| request=request, | ||
| ) | ||
| async for data in generator: | ||
| if data.get("error_code", 200) != 200: | ||
| raise ValueError("{}".format(data["error_msg"])) | ||
| idx = int(data["request_id"].split("_")[-1]) | ||
| # api_server_logger.debug(f"Client {request_id} received: {data}") | ||
| if data.get("error_code", 200) != 200: | ||
| # Error response - include already-generated tokens in the response | ||
| if completion_token_ids[idx]: | ||
| text = self.engine_client.data_processor.tokenizer.decode( | ||
| completion_token_ids[idx], skip_special_tokens=True | ||
| ) | ||
| else: | ||
| text = "" | ||
| data["outputs"] = { | ||
This comment was marked as outdated.
Sorry, something went wrong. |
||
| "text": text, | ||
| "completion_tokens": text, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug 这会导致下游消费 建议修复: "completion_tokens": len(completion_token_ids[idx]), |
||
| "reasoning_content": "", | ||
| "tool_calls": None, | ||
| "reasoning_token_num": 0, | ||
| "num_image_tokens": 0, | ||
| "token_ids": [], | ||
| "top_logprobs": None, | ||
| "draft_top_logprobs": None, | ||
| } | ||
| data["metrics"] = data.get("metrics") or {} | ||
| data["finished"] = True | ||
| previous_num_tokens[idx] += len(data["outputs"]["token_ids"]) | ||
| completion_token_ids[idx].extend(data["outputs"]["token_ids"]) | ||
| # The logprob for handling the response | ||
|
|
@@ -804,6 +822,9 @@ async def _create_chat_completion_choice( | |
|
|
||
| if data.get("error_msg", None) is not None and "Aborted" in data["error_msg"]: | ||
| finish_reason = "abort" | ||
|
|
||
| if data.get("error_msg", None) is not None and "PD Error" in data["error_msg"]: | ||
| finish_reason = "pd_reschedule" | ||
| return ChatCompletionResponseChoice( | ||
| index=idx, | ||
| message=message, | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preallocate_resource_in_d 中不再写入 self.tasks_list[request.idx],但该请求已分配 GPU blocks 且 stop_flags[idx]=False;后续 update_metrics/_recycle_resources 里按 tasks_list 统计 blocks_used 会漏算这部分,导致 available_gpu_block_num 等指标在“预分配-收到首 token”窗口期被高估。建议指标统计改为基于 cache_manager 的 free/used blocks,或把预分配请求单独纳入统计(同时保持 token_processor 不会误处理)。