Skip to content

[Cherry-Pick][Optimization] Optimization for gather_logprob by 10GB (#5817)(#5846)#5834

Merged
qingqing01 merged 2 commits intoPaddlePaddle:release/2.4from
ckl117:2.4_opt_logprob_mem
Dec 31, 2025
Merged

[Cherry-Pick][Optimization] Optimization for gather_logprob by 10GB (#5817)(#5846)#5834
qingqing01 merged 2 commits intoPaddlePaddle:release/2.4from
ckl117:2.4_opt_logprob_mem

Conversation

@ckl117
Copy link
Collaborator

@ckl117 ckl117 commented Dec 30, 2025

Motivation

Reduce peak GPU memory usage of (x>=y).sum(-1) by 10GB and 50% performance improvement of (x>=y).sum(-1) when token_num=8k.

Modifications

Implement (x>=y).sum(-1) using Triton

Usage or Command

No

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.

…5817)

* opt logprobs gather_logprob,reduce device memory usage by 10GB when token_num=8k
@codecov-commenter
Copy link

codecov-commenter commented Dec 30, 2025

Codecov Report

❌ Patch coverage is 60.60606% with 13 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/2.4@0d29f6d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...astdeploy/model_executor/layers/sample/logprobs.py 58.06% 12 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/2.4    #5834   +/-   ##
==============================================
  Coverage               ?   58.93%           
==============================================
  Files                  ?      329           
  Lines                  ?    40781           
  Branches               ?     6209           
==============================================
  Hits                   ?    24034           
  Misses                 ?    14867           
  Partials               ?     1880           
Flag Coverage Δ
GPU 58.93% <60.60%> (?)

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.

@paddle-bot
Copy link

paddle-bot bot commented Dec 30, 2025

Thanks for your contribution!

@ckl117 ckl117 changed the title [Cherry-Pick][Optimization] Optimization for gather_logprob by 10GB (#5817) [Cherry-Pick][Optimization] Optimization for gather_logprob by 10GB (#5817)(#5846) Dec 31, 2025
@qingqing01 qingqing01 merged commit 9a7eb33 into PaddlePaddle:release/2.4 Dec 31, 2025
14 of 18 checks passed
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