Skip to content

[Optimization] Avoid unnecessary penalty computation - #6078

Merged
zhoutianzi666 merged 3 commits into
PaddlePaddle:developfrom
Sunny-bot1:opt_penalty
Jan 19, 2026
Merged

zhoutianzi666 merged 3 commits into
PaddlePaddle:developfrom
Sunny-bot1:opt_penalty

Conversation

@Sunny-bot1

Copy link
Copy Markdown
Collaborator

Motivation

重复惩罚计算后处理耗时占比高,但很多时候我们没有传入penalty score,无需进行这些计算

image

Modifications

  • pre-commit
  • 判断score的值为默认值时,跳过计算
  if (alpha == 1.f && beta == 0.f && gamma == 0.f) {
    return;
  }

image

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.

@paddle-bot

paddle-bot Bot commented Jan 18, 2026

Copy link
Copy Markdown

Thanks for your contribution!

@codecov-commenter

codecov-commenter commented Jan 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@ac6fa6d). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6078   +/-   ##
==========================================
  Coverage           ?   67.42%           
==========================================
  Files              ?      350           
  Lines              ?    45320           
  Branches           ?     6967           
==========================================
  Hits               ?    30559           
  Misses             ?    12521           
  Partials           ?     2240           
Flag Coverage Δ
GPU 67.42% <ø> (?)

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.

Comment on lines +72 to +77
float alpha = penalty_scores[bi];
float beta = frequency_score[bi];
float gamma = presence_score[bi];
if (alpha == 1.f && beta == 0.f && gamma == 0.f) {
return;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

修改1

Comment on lines +125 to +127
if (alpha == 1.f && beta == 0.f && gamma == 0.f && temperature == 1.f) {
return;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

修改2

@zhoutianzi666
zhoutianzi666 merged commit a4144e0 into PaddlePaddle:develop Jan 19, 2026
21 of 24 checks passed
LLSGYN pushed a commit to LLSGYN/FastDeploy that referenced this pull request Feb 2, 2026
chang-wenbin pushed a commit to chang-wenbin/FastDeploy that referenced this pull request Mar 2, 2026
xiaoguoguo626807 pushed a commit to xiaoguoguo626807/FastDeploy that referenced this pull request May 7, 2026
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.

3 participants