Skip to content

[SOT] Place dynamic shape tensor on CPU#76416

Merged
SigureMo merged 3 commits intoPaddlePaddle:developfrom
cattidea:sot/place-dynamic-shape-tensor-on-cpu
Nov 15, 2025
Merged

[SOT] Place dynamic shape tensor on CPU#76416
SigureMo merged 3 commits intoPaddlePaddle:developfrom
cattidea:sot/place-dynamic-shape-tensor-on-cpu

Conversation

@SigureMo
Copy link
Member

PR Category

Execute Infrastructure

PR Types

Performance

Description

避免将 dynamic shape Tensor 在 Program 开始前 move 到 GPU 上,从而导致静态图部分反复 memcpy 回 CPU

@SigureMo SigureMo requested a review from Copilot November 14, 2025 08:20
@paddle-bot
Copy link

paddle-bot bot commented Nov 14, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes performance by preventing dynamic shape tensors from being unnecessarily moved to GPU at program initialization, avoiding repeated memory copies back to CPU during static graph execution. This is a performance improvement specifically for the SOT (Symbol Operator Tracing) module.

  • Changed SymbolicVariable tensor creation to use fill_constant with force_cpu=True instead of paddle.full
  • Added heuristic function maybe_dynamic_shape_tensor to identify likely dynamic shape tensors
  • Modified _prepare_inputs to skip GPU placement for identified dynamic shape tensors

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
python/paddle/jit/sot/opcode_translator/executor/function_graph.py Refactored symbolic variable tensor creation to use fill_constant with force_cpu=True flag
python/paddle/jit/dy2static/utils.py Added heuristic function to detect potential dynamic shape tensors
python/paddle/jit/dy2static/pir_partial_program.py Integrated dynamic shape tensor detection to skip GPU placement during input preparation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

SigureMo and others added 2 commits November 14, 2025 16:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop@bf887b7). Learn more about missing BASE report.

Files with missing lines Patch % Lines
python/paddle/jit/dy2static/utils.py 75.00% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (80.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #76416   +/-   ##
==========================================
  Coverage           ?   80.00%           
==========================================
  Files              ?        2           
  Lines              ?       15           
  Branches           ?        0           
==========================================
  Hits               ?       12           
  Misses             ?        3           
  Partials           ?        0           

☔ 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.

@SigureMo SigureMo changed the title [SOT] Place dynamic shape tensor on CPU [SOT][CINN] Place dynamic shape tensor on CPU Nov 14, 2025
@SigureMo SigureMo requested review from gouzil and zrr1999 November 14, 2025 18:28
@SigureMo SigureMo changed the title [SOT][CINN] Place dynamic shape tensor on CPU [SOT] Place dynamic shape tensor on CPU Nov 15, 2025
@SigureMo SigureMo merged commit eb3635c into PaddlePaddle:develop Nov 15, 2025
118 of 124 checks passed
@SigureMo SigureMo deleted the sot/place-dynamic-shape-tensor-on-cpu branch November 15, 2025 16:01
LittleHeroZZZX pushed a commit to LittleHeroZZZX/Paddle that referenced this pull request Nov 19, 2025
---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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