Skip to content

[SOT] Add inline call codeobj to global guard #69803

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

Conversation

SigureMo
Copy link
Member

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

因为我们现在并不会将 inline call 的 codeobj 加入到 guard 中,因此在调用不同函数时是有可能错误命中 guard 的

比如

def apply_fn(fn, x):
    return fn(x)


def fn1(x):
    return x + 1


def fn2(x):
    return x - 1

static_fn = paddle.jit.to_static(apply_fn, full_graph=False)
static_fn(fn1, 1)
static_fn(fn2, 1)

这里的 guard 是没有函数的 codeobj 的

因此在 inline call 时将其添加到 global guard 中,确保会 guard 住这个 code

PCard-66972

Copy link

paddle-bot bot commented Nov 28, 2024

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

@@ -273,6 +274,7 @@ def inline_call(self) -> VariableBase:
"""
Execute the inline call of the function.
"""
self._graph.add_global_guarded_variable(self._code_var)
Copy link
Member Author

Choose a reason for hiding this comment

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

放在 run 前后差别不大

  • 放在前面,如果内部 breakgraph,global guard 会 rollback
  • 放在后面,成功后才会加,也是一样的

Copy link
Member Author

Choose a reason for hiding this comment

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

目前没有专门设计 CodeObjectVariable,因此使用的是基类的 guard,会触发 xxx == ___object_yyy== 会比较重,这里后续可优化为 ID MATCH

@SigureMo SigureMo requested a review from Copilot November 28, 2024 15:20
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.

Copilot reviewed 3 out of 3 changed files in this pull request and generated no suggestions.

@SigureMo SigureMo merged commit 97bacd1 into PaddlePaddle:develop Nov 29, 2024
27 of 28 checks passed
@SigureMo SigureMo deleted the sot/add-inline-call-codeobj-to-global-guard branch November 29, 2024 06: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.

2 participants