[Feature] Support set PREEMPTED_TOKEN_ID in GET_SAVE_OUTPUT_V1#7159
[Feature] Support set PREEMPTED_TOKEN_ID in GET_SAVE_OUTPUT_V1#7159rainyfly wants to merge 3 commits intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
fastdeploy-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-02 20:02 CST
📋 Review 摘要
PR 概述:在 GET_SAVE_OUTPUT_V1 模式下支持设置 PREEMPTED_TOKEN_ID 标记被抢占的请求
变更范围:worker/gpu_model_runner.py 的 _postprocess 方法
影响面 Tag:Engine Worker
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🔴 Bug | gpu_model_runner.py:2407 |
环境变量名错误,envs.GET_SAVE_OUTPUT_V1 不存在 |
总体评价
PR 意图清晰,为 V1 输出模式增加了抢占标记支持。但存在一个关键的变量名错误,会导致运行时异常,需要修复后才能合并。
|
|
||
| # 5.1. Async cpy | ||
| post_process_event = paddle.device.cuda.create_event() | ||
| if envs.GET_SAVE_OUTPUT_V1: |
There was a problem hiding this comment.
🔴 Bug 变量名错误:envs.GET_SAVE_OUTPUT_V1 不存在,应为 envs.FD_USE_GET_SAVE_OUTPUT_V1
fastdeploy/envs.py 中定义的环境变量是 FD_USE_GET_SAVE_OUTPUT_V1,当前代码使用 envs.GET_SAVE_OUTPUT_V1 会在运行时触发 AttributeError,导致条件分支永远无法进入(Python 会抛出异常)。
其他使用此环境变量的代码(如同文件的 241 行和 2300 行)都使用了正确的 envs.FD_USE_GET_SAVE_OUTPUT_V1。
建议修复:
if envs.FD_USE_GET_SAVE_OUTPUT_V1:
fastdeploy-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-03 15:24 CST
📋 Review 摘要
PR 概述:在 FD_USE_GET_SAVE_OUTPUT_V1 模式下,为被抢占的请求设置 PREEMPTED_TOKEN_ID (-9) 以通知 server 端 abort 操作已完成。
变更范围:fastdeploy/worker/gpu_model_runner.py - _postprocess 方法
影响面 Tag:Engine Scheduler
📝 PR 规范检查
PR 描述中 Motivation 和 Modifications 部分未填写具体内容,建议补充说明。
描述模板(可直接复制):
## Motivation
在使用 GET_SAVE_OUTPUT_V1 模式时,当请求被抢占(preempted)后,没有对应的采样 token。本 PR 通过设置 PREEMPTED_TOKEN_ID (-9) 来通知 server 端 abort 操作已完成,使抢占流程能够正确结束。
## Modifications
- 在 `gpu_model_runner.py` 的 `_postprocess` 方法中,当 `FD_USE_GET_SAVE_OUTPUT_V1` 开启时,检查 `last_preempted_idx`
- 对于被抢占的请求,将其 `sampled_token_ids` 设置为 `PREEMPTED_TOKEN_ID`问题
未发现阻塞性问题。
总体评价
代码逻辑清晰,与已有的 token_processor.py 中处理 PREEMPTED_TOKEN_ID 的逻辑保持一致。建议补充 PR 描述以便于后续维护和代码审查。
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7159 +/- ##
==========================================
Coverage ? 73.86%
==========================================
Files ? 376
Lines ? 52888
Branches ? 8250
==========================================
Hits ? 39064
Misses ? 11095
Partials ? 2729
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Motivation
Modifications
Usage or Command
Accuracy Tests
Checklist
[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]]pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.