Skip to content

[SOT] Fallback when breakgraph in for loop#76104

Merged
SigureMo merged 2 commits into
PaddlePaddle:developfrom
cattidea:sot/fallback-when-breakgraph-on-for-loop
Oct 29, 2025
Merged

[SOT] Fallback when breakgraph in for loop#76104
SigureMo merged 2 commits into
PaddlePaddle:developfrom
cattidea:sot/fallback-when-breakgraph-on-for-loop

Conversation

@SigureMo

@SigureMo SigureMo commented Oct 29, 2025

Copy link
Copy Markdown
Member

PR Category

Execute Infrastructure

PR Types

Performance

Description

SOT 移除针对 for-loop 的 break graph 处理,在 for-loop 中产生的 break graph 往往会产生大量的碎子图,反而会导致性能降低

此外,for-loop 的实现不再需要抽取函数并 inline call,后续移除

@paddle-bot

paddle-bot Bot commented Oct 29, 2025

Copy link
Copy Markdown

你的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.

@SigureMo SigureMo requested review from Copilot and removed request for DrRyanHuang, gouzil and zrr1999 October 29, 2025 06:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes the loop breakgraph logic from the SOT (Symbolic Opcode Translator) and simplifies the FOR_ITER handling by always falling back instead of attempting to break the graph. The changes eliminate complex loop reconstruction code and replace it with simpler fallback behavior.

  • Removed the _break_graph_when_for_loop method and associated loop breakgraph resume function logic
  • Simplified FOR_ITER to always fallback on BreakGraphError instead of attempting loop reconstruction
  • Updated test files to use @strict_mode_guard(False) decorator for tests that now require fallback behavior
  • Cleaned up enum values and removed unused imports

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py Removed _break_graph_when_for_loop method (~250 lines), simplified FOR_ITER error handling to always fallback, removed unused imports, cleaned up formatting
python/paddle/jit/sot/opcode_translator/executor/pycode_generator.py Removed unused ResumeFunctionType enum values for loop breakgraph and renumbered remaining values
test/sot/test_12_for_loop.py Added @strict_mode_guard(False) to multiple test methods, removed decorator from function definition, renamed test method
test/sot/test_min_graph_size.py Added strict_mode_guard import and decorator to test class method
test/sot/test_inplace_api.py Added strict_mode_guard import and decorator to test method
test/sot/test_builtin_zip.py Added @strict_mode_guard(False) decorator to test method
Comments suppressed due to low confidence (1)

test/sot/test_builtin_zip.py:101

  • [nitpick] Inconsistent decorator ordering: in test_reconstruct method (line 95-96), @min_graph_size_guard is placed before @strict_mode_guard, but in test_zip_user_defined_iter (line 100-101), the order is reversed. Consider using a consistent decorator ordering throughout the test class for better readability.
    @strict_mode_guard(False)
    @min_graph_size_guard(0)

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


def get_compute_fn_and_update_changed_vars(
self, restore_names, stack, end_idx, extra_store_vars
self, restore_names, stack, end_idx

Copilot AI Oct 29, 2025

Copy link

Choose a reason for hiding this comment

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

The docstring for this method still references the removed extra_store_vars parameter. The docstring at line 2215 should be updated to remove the mention of extra_store_vars: for iterator, we need store the holder if it is a Tensor.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

不理我……

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

image

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #76104   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         2           
  Lines              ?         4           
  Branches           ?         0           
===========================================
  Hits               ?         4           
  Misses             ?         0           
  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 merged commit d03a359 into PaddlePaddle:develop Oct 29, 2025
72 of 73 checks passed
@SigureMo SigureMo deleted the sot/fallback-when-breakgraph-on-for-loop branch October 29, 2025 11:07
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