Skip to content

[XPU] add fetch req log#8070

Open
cmcamdy wants to merge 1 commit into
PaddlePaddle:developfrom
cmcamdy:update_log
Open

[XPU] add fetch req log#8070
cmcamdy wants to merge 1 commit into
PaddlePaddle:developfrom
cmcamdy:update_log

Conversation

@cmcamdy

@cmcamdy cmcamdy commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Motivation

需要在 PD disaggregation 场景下定位 prefill 和 decode 之间的请求传递问题,通过环境变量控制是否输出请求调试日志。

Modifications

  • fastdeploy/envs.py 中新增 FD_PD_LOG_REQUEST 环境变量,默认关闭。
  • fastdeploy/engine/common_engine.py 的 prefill 发送请求和 decode 接收请求路径增加 PD 请求日志。
  • 日志内容需脱敏为请求摘要,避免记录原始 prompt、messages、token ids 或多模态数据。

Usage or Command

设置 FD_PD_LOG_REQUEST=1 可启用 PD 请求日志;默认 0 关闭。

Accuracy Tests

N/A(仅新增日志开关和日志输出,不改变模型计算结果。)

Checklist

  • Add at least a tag in the PR title.
    • Tag list: [[FDConfig],[APIServer],[Engine], [Scheduler], [PD Disaggregation], [Executor], [Graph Optimization], [Speculative Decoding], [RL], [Models], [Quantization], [Loader], [OP], [KVCache], [DataProcessor], [BugFix], [Docs], [CI], [Optimization], [Feature], [Benchmark], [Others], [XPU], [HPU], [GCU], [DCU], [Iluvatar], [Metax]]
    • You can add new tags based on the PR content, but the semantics must be clear.
  • Format your code, run pre-commit before commit.
  • Add unit tests. Please write the reason in this PR if no unit tests.
  • Provide accuracy results.
  • If the current PR is submitting to the release branch, make sure the PR has been submitted to the develop branch, then cherry-pick it to the release branch with the [Cherry-Pick] PR tag.

@codecov-commenter

codecov-commenter commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@4653221). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/engine/common_engine.py 0.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #8070   +/-   ##
==========================================
  Coverage           ?   67.50%           
==========================================
  Files              ?      475           
  Lines              ?    66885           
  Branches           ?    10315           
==========================================
  Hits               ?    45154           
  Misses             ?    18860           
  Partials           ?     2871           
Flag Coverage Δ
GPU 77.53% <0.00%> (?)
XPU 6.95% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PaddlePaddle-bot PaddlePaddle-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Paddle-CI-Agent | pr_review | 2026-06-23 18:56:43

📋 Review 摘要

PR 概述:新增 FD_PD_LOG_REQUEST 开关,在 PD 分离的 prefill 发送和 decode 接收路径打印请求日志。
变更范围fastdeploy/engine/common_engine.pyfastdeploy/envs.py
影响面 Tag[Engine] [PD Disaggregation]

问题

级别 文件 概述
🔴 安全 fastdeploy/engine/common_engine.py:985 prefill 连续资源分支将完整用户请求写入 INFO 日志
🔴 安全 fastdeploy/engine/common_engine.py:1017 prefill 非连续资源分支将完整用户请求写入 INFO 日志
🔴 安全 fastdeploy/engine/common_engine.py:2103 decode 接收分支将完整用户请求写入 INFO 日志

📝 PR 规范检查

标题当前使用 [XPU],但 diff 主要修改 PD 分离/Engine 请求日志;PR 描述仍是模板占位内容,未填写实际 Motivation/Modifications/Usage/Accuracy Tests。

标题建议(可直接复制):

  • [PD Disaggregation] Add gated PD request logging
PR 描述建议(点击展开,可直接复制)
## Motivation
需要在 PD disaggregation 场景下定位 prefill 和 decode 之间的请求传递问题,通过环境变量控制是否输出请求调试日志。

## Modifications
-`fastdeploy/envs.py` 中新增 `FD_PD_LOG_REQUEST` 环境变量,默认关闭。
-`fastdeploy/engine/common_engine.py` 的 prefill 发送请求和 decode 接收请求路径增加 PD 请求日志。
- 日志内容需脱敏为请求摘要,避免记录原始 prompt、messages、token ids 或多模态数据。

## Usage or Command
设置 `FD_PD_LOG_REQUEST=1` 可启用 PD 请求日志;默认 `0` 关闭。

## Accuracy Tests
N/A(仅新增日志开关和日志输出,不改变模型计算结果。)

## Checklist

- [x] Add at least a tag in the PR title.
  - Tag list: [`[FDConfig]`,`[APIServer]`,`[Engine]`, `[Scheduler]`, `[PD Disaggregation]`, `[Executor]`, `[Graph Optimization]`, `[Speculative Decoding]`, `[RL]`, `[Models]`, `[Quantization]`, `[Loader]`, `[OP]`, `[KVCache]`, `[DataProcessor]`, `[BugFix]`, `[Docs]`, `[CI]`, `[Optimization]`, `[Feature]`, `[Benchmark]`, `[Others]`, `[XPU]`, `[HPU]`, `[GCU]`, `[DCU]`, `[Iluvatar]`, `[Metax]`]
  - You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [ ] Add unit tests. Please write the reason in this PR if no unit tests.
- [x] Provide accuracy results.
- [x] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.

总体评价

新增开关默认关闭,但当前实现一旦开启会把完整用户请求内容落到 INFO 日志,存在敏感信息泄漏风险。建议先改为脱敏摘要日志后再合入。

)
task.metrics.ask_decode_resource_start_time = time.time()
if envs.FD_PD_LOG_REQUEST:
self.llm_logger.info(f"[PD_LOG] P sends Request: {task.to_dict()}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 安全 这里会把完整用户请求写入 INFO 日志。

Request.to_dict() 包含 promptprompt_token_idsmessagessystemhistorytoolsmultimodal_data 等用户输入字段;一旦 FD_PD_LOG_REQUEST=1,PD 请求的原始内容会进入持久化日志,命中仓库 checklist 的日志泄漏项。

建议修复方式:
改为专用的脱敏/摘要结构,只输出 request_idprompt_token_ids_lenidxnum_computed_tokens、必要的 block/resource 元数据;不要调用 task.to_dict() 直接落日志。

)
task.metrics.ask_decode_resource_start_time = time.time()
if envs.FD_PD_LOG_REQUEST:
self.llm_logger.info(f"[PD_LOG] P sends Request: {task.to_dict()}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 安全 这里会把完整用户请求写入 INFO 日志。

Request.to_dict() 包含 promptprompt_token_idsmessagessystemhistorytoolsmultimodal_data 等用户输入字段;一旦 FD_PD_LOG_REQUEST=1,PD 请求的原始内容会进入持久化日志,命中仓库 checklist 的日志泄漏项。

建议修复方式:
改为专用的脱敏/摘要结构,只输出 request_idprompt_token_ids_lenidxnum_computed_tokens、必要的 block/resource 元数据;不要调用 task.to_dict() 直接落日志。

)
for task in tasks:
if envs.FD_PD_LOG_REQUEST:
self.llm_logger.info(f"[PD_LOG] D received Request: {task.to_dict()}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 安全 这里会把完整用户请求写入 INFO 日志。

Request.to_dict() 包含 promptprompt_token_idsmessagessystemhistorytoolsmultimodal_data 等用户输入字段;一旦 FD_PD_LOG_REQUEST=1,PD 请求的原始内容会进入持久化日志,命中仓库 checklist 的日志泄漏项。

建议修复方式:
改为专用的脱敏/摘要结构,只输出 request_idprompt_token_ids_lenidxnum_computed_tokens、必要的 block/resource 元数据;不要调用 task.to_dict() 直接落日志。

@PaddlePaddle-bot

PaddlePaddle-bot commented Jun 23, 2026

Copy link
Copy Markdown

🤖 Paddle-CI-Agent | ci_status_monitor | 2026-07-05 02:16:53 UTC+08:00

CI报告基于以下代码生成(30分钟更新一次):
PR commit: 0c8e80d | Merge base: 4653221 (branch: develop)


1 Required任务 : 8/10 通过

总执行(rerun次数) 总任务 ✅ 通过 ❌ 失败 ⏳ 运行中 ⏸️ 等待中 跳过
41(0) 41 36 5 0 0 0
任务 错误类型 置信度 日志
Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage PR问题 Job
Approval 需要 Approval Job

2 失败详情

🔴 Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — PR问题(置信度: 高)

分析器: ci_analyze_unittest_fastdeploy

失败用例:

用例 错误摘要
diff-cover PR 差异覆盖率未达到 80% 阈值,workflow 将覆盖率退出码置为 9

关键日志:

[FAILURE]: Process completed with exit code 9.
.github/workflows/_unit_test_coverage.yml: diff-cover python_coverage_all.xml --diff-file=diff.txt --fail-under=80 --json-report diff_coverage.json || COVERAGE_EXIT_CODE=9
Verify Code Coverage Threshold: exit "$COVERAGE_EXIT_CODE"
  • 根因摘要: PR差异覆盖率低于80%

该 job 的 TEST_EXIT_CODE=8 分支代表单测失败,COVERAGE_EXIT_CODE=9 分支代表 diff coverage 未达标;本次失败码为 9,因此不是单测断言失败,而是覆盖率阈值失败。PR 只新增了 fastdeploy/envs.pyFD_PD_LOG_REQUEST 环境变量和 fastdeploy/engine/common_engine.py 中三处 FD_PD_LOG_REQUEST 日志分支,这些新增行需要被测试覆盖到 80% 以上。深度日志接口未返回 diff_coverage.json 或 case 级日志,因此具体未覆盖行号以 CI 产出的 coverage 报告为准。

修复建议:

  1. FD_PD_LOG_REQUEST=1 的 prefill 发送请求和 decode 接收请求路径补充单元测试,覆盖 fastdeploy/engine/common_engine.py 新增日志分支。
  2. fastdeploy/envs.py 中新增的 FD_PD_LOG_REQUEST 环境变量解析补充测试,确认默认值和开启值行为。

关联变更: fastdeploy/envs.pyfastdeploy/engine/common_engine.py

🔴 Approval — 需要 Approval(置信度: 高)

分析器: builtin

失败用例: 无

关键日志:

[FAILURE]: Process completed with exit code 6.
  • 根因摘要: 需要人工审批

该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。

修复建议:

  1. 请有权限的维护者通过人工审批后继续执行 CI。

关联变更: 无

@hong19860320 hong19860320 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants