[Cherry-Pick] [Optimization] TopP=1.0 using _random_sample (#7892) and Triton SamplerBackend (#7639)#7910
[Cherry-Pick] [Optimization] TopP=1.0 using _random_sample (#7892) and Triton SamplerBackend (#7639)#7910ckl117 wants to merge 11 commits into
Conversation
|
Thanks for your contribution! |
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览Required 任务当前 8/10 通过;仍有 2 个 Required 失败(其中
2 任务状态汇总2.1 Required任务 : 8/10 通过
2.2 可选任务 — 23/26 通过
3 失败详情(仅 required)Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage — 覆盖率未达标(置信度: 高)Run FastDeploy Unit Tests and Coverage / run_tests_with_coverage
失败用例: 无。日志显示 根因详情: 关键日志: 修复建议:
修复建议摘要: 补测Triton采样新增分支或豁免JIT代码 关联变更: 链接: 查看日志 Approval — 需要人工审批(置信度: 高)该 Job 需要人工 Approval,完成审批后 CI 才会继续执行。 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/2.6 #7910 +/- ##
==============================================
Coverage ? 71.86%
==============================================
Files ? 383
Lines ? 55075
Branches ? 8621
==============================================
Hits ? 39579
Misses ? 12718
Partials ? 2778
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:
|
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-26 23:33:18
📋 Review 摘要
PR 概述:Cherry-pick 两项优化:Triton 采样后端(#7639)和 top_p=1.0 采样路径优化(#7892)
变更范围:model_executor/layers/sample/、worker/gpu_model_runner.py、envs.py
影响面 Tag:[OP] [Optimization]
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | top_k_top_p_triton.py:44 |
_TRITON_BUFFER_CACHE 模块级缓存无界增长 |
| 🟡 建议 | gpu_model_runner.py |
A6:通用路径变更需确认多硬件 ModelRunner 是否同步 |
历史 Findings 修复情况
| Finding | 问题 | 状态 |
|---|---|---|
| F1 | FD_ENABLE_TOP_P_ONE_OPT 默认值为 "1"(启用) |
|
| F2 | 移除 topp_seed 设备拷贝可能导致运行时错误 |
|
| F3 | top_p_list 类型标注过宽 |
|
| F4 | 模块级全局 warning 抑制范围过广 |
📝 PR 规范检查
标题格式存在小问题:[Cherry-Pick] 与 [Optimization] 之间有多余空格,标准格式应为 [Cherry-Pick][Tag](无空格)。## Modifications、## Usage or Command、## Accuracy Tests 三个 section 内容为空,需补充。
标题建议(可直接复制):
[Cherry-Pick][Optimization] TopP=1.0 using _random_sample (#7892) and Triton SamplerBackend (#7639)
PR 描述建议(点击展开,可直接复制)
## Motivation
1. 支持 Triton 采样后端,基于 Qrita 论文实现高性能 top-k/top-p Triton kernel(#7639)
2. 优化 top_p=1.0 场景的采样路径(#7892)
3. 新增环境变量 `FD_ENABLE_TOP_P_ONE_OPT`,方便 RL 场景验证,待验证通过后移除
## Modifications
- `fastdeploy/envs.py`:新增 `FD_ENABLE_TOP_P_ONE_OPT` 环境变量;更新 `FD_SAMPLING_CLASS` 注释,新增 `"triton"` 选项
- `fastdeploy/model_executor/layers/sample/meta_data.py`:`SamplingMetadata` 新增 `top_p_list` 字段
- `fastdeploy/model_executor/layers/sample/ops/top_k_top_p_sampling.py`:提取 `dispatch_top_k_renorm_probs` 公共函数;移除 `topp_seed` 的显式设备拷贝
- `fastdeploy/model_executor/layers/sample/ops/top_k_top_p_triton.py`:新增基于 Qrita 论文的 Triton top-k/top-p 采样 kernel(993 行)
- `fastdeploy/model_executor/layers/sample/sampler.py`:集成 Triton 采样后端分支
- `fastdeploy/worker/gpu_model_runner.py`:适配新采样逻辑
- `fastdeploy/worker/input_batch.py`:适配 `top_p_list` 字段
- `tests/layers/test_triton_sampler.py`:新增 Triton 采样器单测
## Usage or Command
```bash
# 启用 Triton 采样后端
FD_SAMPLING_CLASS=triton python ...
# 启用 top_p=1.0 优化(默认已启用,可通过设为 0 关闭)
FD_ENABLE_TOP_P_ONE_OPT=1 python ...
```
## 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.
- [x] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] 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.总体评价
Triton 采样后端实现完整,新增了单测。历史 F1-F4 问题仍未修复,建议在合入前重点关注 F2(topp_seed 设备拷贝移除的潜在运行时风险)。
| import triton # noqa: E402 | ||
| import triton.language as tl # noqa: E402 | ||
|
|
||
| _TRITON_TABLE_CACHE: dict[tuple[paddle.device], tuple[paddle.Tensor, paddle.Tensor]] = {} |
There was a problem hiding this comment.
🟡 建议 _TRITON_BUFFER_CACHE 为模块级全局字典,在长期运行的服务场景中会随不同 (device, dtype, vocab_size) 组合持续增长,无淘汰机制。
建议添加最大容量限制或使用 weakref 管理生命周期,避免显存/内存泄漏。
Motivation
支持triton采样后端 #7639
优化top_p=1.0采样 #7892
新增环境变量
FD_ENABLE_TOP_P_ONE_OPT=1,方便RL验证,待验证通过后删掉环境变量。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.