Skip to content

[SOT] Check without graph for fallback code only #73515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

SigureMo
Copy link
Member

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

我们目前有一个策略,就是针对一个 code,如果连续多次都没有感知到其内有 graph,就直接回退到动态图,这个目前主要针对的应该是有 fallback 的场景,而非 fallback,也就是生成了 code 的场景,一般不会没有 graph,就算没有,也应该是在新的 code 里处理而不是在这里

目前处理方式是有问题的,StepInfoManager 是为每个 original code 来记录 step count,但实际记录的分别如下:

  • 对于 fallback 场景,当然会为 original code 标记是否有 graph,因为 fallback 回 original code 了,其内的函数会去标记这件事
  • 对于非 fallback 场景,是会为生成的 code 标记是否有 graph,因为实际执行的是这个,而不是 original code

这里两者 step 记录的不匹配导致出现如下问题

  • original code 在第一轮编译了一个 new code 1,之后跑了 20 次,new code 1 在第一轮就被标记为有图了
  • 接着 original code 在第 21 轮编译了一个 new code 2,由于 original code 已经跑了 20 轮,所以不会再记录是否有图,new code 2 没有机会再记录为有图,10 轮后直接 fallback 回动态图

这里问题只出现在非 fallback 的情况,fallback 的情况因为记录的 code 是统一的,因此不会出问题

而非 fallback 的情况已经生成 code 了,一般不会没有 graph,因此本 PR 移除对该 case 的处理,仅针对 fallback case

@SigureMo SigureMo requested a review from Copilot June 21, 2025 11:29
Copy link

paddle-bot bot commented Jun 21, 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 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 addresses a bug in the step-counting mechanism for the fallback code path by restricting the condition to fallback cases only.

  • Updated condition to check only for fallback (code is None and no graph exists)
  • Removed the non-fallback branch that invoked eval_frame_default and callback update
  • Adjusted the reference handling of disable_eval_frame
Comments suppressed due to low confidence (2)

paddle/fluid/pybind/sot/eval_frame.c:324

  • The updated condition limits the check to fallback scenarios, omitting the early return via eval_frame_default and callback update. Please confirm that this removal is intentional and does not affect other fallback code paths.
  if (code == Py_None && is_code_without_graph(PyFrame_GET_CODE(frame))) {

paddle/fluid/pybind/sot/eval_frame.c:325

  • Since disable_eval_frame likely points to one of the singleton PyBool objects (Py_True or Py_False), review if the manual decref/incref is necessary to avoid potential reference mismanagement.
    Py_DECREF(disable_eval_frame);

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.

2 participants