Skip to content

【Inference Optimize】Calculate paddle_peak_increase using paddle_allocated_mem_after_run - #4355

Merged
gongshaotian merged 1 commit into
PaddlePaddle:developfrom
chang-wenbin:fix_gpu_worker
Oct 10, 2025
Merged

gongshaotian merged 1 commit into
PaddlePaddle:developfrom
chang-wenbin:fix_gpu_worker

Conversation

@chang-wenbin

@chang-wenbin chang-wenbin commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator

Calculate paddle_peak_increase using paddle_allocated_mem_after_run:
paddle_peak_increase = paddle_allocated_mem_after_run - paddle_allocated_mem_before_run
This way paddle_peak_increase is closer to the actual situation.

The reserved variable returns the current memory size managed by the Allocator. The allocated variable returns the current memory size allocated to the Tensor. The difference we are concerned about here is the memory size allocated to the active Tensor before and after the profile. Therefore, theoretically, using paddle_allocated_mem_after_run - paddle_allocated_mem_before_run can meet the requirement. Using reserved may cause the calculated difference to be artificially high, resulting in a smaller memory size allocated to the kv-cache

@paddle-bot

paddle-bot Bot commented Oct 10, 2025

Copy link
Copy Markdown

Thanks for your contribution!

@gongshaotian gongshaotian left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@gongshaotian
gongshaotian merged commit 533896f into PaddlePaddle:develop Oct 10, 2025
25 of 29 checks passed
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