Skip to content

[Cherry-Pick][Optimization] Use triton qk_norm both in Prefill and Decode.(#7213)#7305

Open
EmmonsCurse wants to merge 1 commit intoPaddlePaddle:release/2.5from
EmmonsCurse:cherry-pick/7213/release/2.5
Open

[Cherry-Pick][Optimization] Use triton qk_norm both in Prefill and Decode.(#7213)#7305
EmmonsCurse wants to merge 1 commit intoPaddlePaddle:release/2.5from
EmmonsCurse:cherry-pick/7213/release/2.5

Conversation

@EmmonsCurse
Copy link
Copy Markdown
Collaborator

Cherry-pick of #7213 (authored by @K11OntheBoat) to release/2.5.

devPR:#7213


Motivation

Prefill 阶段使用QKRMSNorm融合算子. 部分模型 单Kernel部分加速2~7倍. Prefill 空泡较大的模型单次Forward可加速2倍左右.

Modifications

使用QKRMSNorm 替代paddle 散Op

Usage or Command

Accuracy Tests

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.

Co-authored-by: “liuruian” <liuruian@baidu.com>
@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 10, 2026

Thanks for your contribution!

Copy link
Copy Markdown

@fastdeploy-bot fastdeploy-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-10 16:01 CST

📋 Review 摘要

PR 概述:在 Prefill 和 Decode 阶段都使用 Triton QK RMSNorm 融合算子,移除 CUDA Graph 模式限制

变更范围fastdeploy/model_executor/layers/normalization.pytests/e2e/test_Qwen3VL_serving.py

影响面 Tag[OP]

PR 规范检查

✅ 标题包含有效 Tag [Cherry-Pick][Optimization]
✅ Motivation 和 Modifications 填写完整

问题

级别 文件 概述
🟡 建议 test_Qwen3VL_serving.py:176 测试预期输出变更未在 PR 描述中说明原因

总体评价

代码变更合理,移除 step_use_cudagraph 条件后 triton kernel 在 Prefill 阶段也能使用,符合优化目的。triton kernel 实现支持动态 batch size,且有独立的数值精度测试验证正确性。


# base result
content2 = "视频中手机支架的颜色是黑色的。"
content2 = "视频中手机支架的颜色是黑色。"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 建议 测试预期输出从 "视频中手机支架的颜色是黑色的。" 修改为 "视频中手机支架的颜色是黑色。",这个变更应该在 PR 描述中说明原因。

建议在 PR 描述中补充说明:由于改用 triton qk_rmsnorm_fused kernel 替代 paddle 算子,导致模型输出在端到端测试中存在微小差异(属于正常范围内的浮点计算差异)。

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.5@1e0ab31). Learn more about missing BASE report.

Files with missing lines Patch % Lines
fastdeploy/model_executor/layers/normalization.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.5    #7305   +/-   ##
==============================================
  Coverage               ?   69.93%           
==============================================
  Files                  ?      390           
  Lines                  ?    54417           
  Branches               ?     8581           
==============================================
  Hits                   ?    38056           
  Misses                 ?    13619           
  Partials               ?     2742           
Flag Coverage Δ
GPU 69.93% <0.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 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.

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