Skip to content

[SOT][DynamicShape] Fix SymbolicVariable get_py_value reversed call and break graph on infermeta encount TypeError #70009

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

@SigureMo SigureMo commented Dec 6, 2024

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

目前 Fallback 回静态 shape 的策略有点 bug,比如 SymbolicVariable(10) * SymbolicVariable(0.25) 的结果的 Tracker 里的 method 是 __mul__,但实际上触发的是 float.__rmul__,而这里按照记录的 __mul__ 计算的结果是 (10).__mul__(0.25) = NotImplemented,导致后续挂掉

因此将 SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE 开启默认,直接打断,不走 Fallback 回静态 shape,预期可能有部分模型有性能下降,但正确性优先 暂时通过转为 __rmul__ 解决,之后需要寻找一个更好的方案

另外就是有些 API 动静不统一,比如 randperm 的第一个参数 n,输入是 int,动态图下 API 可以将 Tensor cast 为 int,但动转静后传入 Value 是会挂的,因此如果遇到 TypeError 直接 BreakGraph 确保正确性

PCard-66972

…d break graph on infermeta encount `TypeError`
Copy link

paddle-bot bot commented Dec 6, 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.

@SigureMo SigureMo changed the title [SOT][DynamicShape] Enable SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE and break graph on infermeta encount TypeError [SOT][DynamicShape][3.13] Enable SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE and break graph on infermeta encount TypeError Dec 6, 2024
@SigureMo SigureMo requested a review from Copilot December 6, 2024 06:56
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 4 out of 4 changed files in this pull request and generated 1 suggestion.

Comments skipped due to low confidence (2)

python/paddle/jit/sot/opcode_translator/executor/function_graph.py:666

  • The word 'encount' should be 'encounter'.
raise BreakGraphError(f"InferMeta encount {type(e)}, but all args are not symbolic.")

python/paddle/jit/sot/opcode_translator/executor/function_graph.py:693

  • The word 'encount' should be 'encounter'.
raise BreakGraphError(f"InferMeta encount {type(e)}, but all args are not symbolic.")

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
gouzil
gouzil previously approved these changes Dec 6, 2024
@SigureMo SigureMo requested a review from Copilot December 6, 2024 07:27
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 4 out of 4 changed files in this pull request and generated 1 suggestion.

Comments skipped due to low confidence (2)

python/paddle/jit/sot/opcode_translator/executor/function_graph.py:666

  • The error message contains a typo: 'encount'. It should be 'encountered'.
raise BreakGraphError(f"InferMeta encount {type(e)}, but all args are not symbolic.")

python/paddle/jit/sot/opcode_translator/executor/function_graph.py:693

  • The error message contains a typo: 'encount'. It should be 'encountered'.
raise BreakGraphError(f"InferMeta encount {type(e)}, but all args are not symbolic.")

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: gouzil <66515297+gouzil@users.noreply.github.com>
zrr1999
zrr1999 previously approved these changes Dec 8, 2024
@SigureMo SigureMo changed the title [SOT][DynamicShape][3.13] Enable SOT_BREAK_GRAPH_ON_GET_SYMBOLIC_VALUE and break graph on infermeta encount TypeError [SOT][DynamicShape][3.13] Fix SymbolicVariable get_py_value reversed call and break graph on infermeta encount TypeError Dec 9, 2024
@SigureMo SigureMo requested a review from Copilot December 9, 2024 08:58
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 4 out of 4 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (1)

python/paddle/jit/sot/opcode_translator/executor/variables/basic.py:109

  • The function 'method_to_reverse_method' is not covered by any tests. Please add a test case to ensure its correctness.
def method_to_reverse_method(method_name: str) -> str | None:

@SigureMo SigureMo requested review from gouzil and zrr1999 December 9, 2024 09:01
@SigureMo SigureMo changed the title [SOT][DynamicShape][3.13] Fix SymbolicVariable get_py_value reversed call and break graph on infermeta encount TypeError [SOT][DynamicShape] Fix SymbolicVariable get_py_value reversed call and break graph on infermeta encount TypeError Dec 9, 2024
@SigureMo SigureMo merged commit de50a92 into PaddlePaddle:develop Dec 9, 2024
28 checks passed
@SigureMo SigureMo deleted the sot/enable-break-graph-on-get-symbolic-value-and-break-graph-on-infermeta-encount-type-error branch December 9, 2024 16:14
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