Skip to content

[SOT][3.13] split certain LOAD_ATTR in 3.13+ & replace get_items and flatten_items withflatten_inner_vars,while replacing special cases with inheritance & remove method_name attribute in MethodVariable #70927

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

Merged
merged 14 commits into from
Jan 23, 2025

Conversation

GoldenStain
Copy link
Contributor

@GoldenStain GoldenStain commented Jan 21, 2025

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

修复Bug

问题case:
class MyLayer(paddle.nn.Layer):
    def __init__(self):
        super().__init__()
        self.head = paddle.nn.Linear(3, 10)

    def forward_features(self, x):
        paddle.jit.sot.psdb.breakgraph()
        return x

    def forward(self, x):
        x = self.forward_features(x)
        return self.head(x)

MIN_GRAPH_SIZE超过该子图size的时候,连续两次执行forward函数会出现缺少位置参数的错误。
在test/sot/test_min_graph_size.py中添加了针对此问题的新测试test_layer_multiple_times

原因

我们生成的字节码中,LOAD_ATTR的最低位是1,交给python执行的时候,在第二次执行时,将原本load一个method+NULL的行为改为了load一个function+NULL,导致函数执行时找不到self.

bug fix

在3.13+中,手动把最低一位为1的LOAD_ATTR拆分为LOAD_ATTR+PUSH_NULL的组合
经过确认,虽然3.12就引入了通过最低位来标志LOAD_ATTR执行路径的方式,但是3.12不会出现该问题。

get_items & flatten_items -> flatten_inner_vars

规范接口名称,并且把原来的特判改成了继承。

PCard-66972

@GoldenStain GoldenStain changed the title [SOT] split certain LOAD_ATTR in 3.12+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars [SOT] split certain LOAD_ATTR in 3.12+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars,while replacing special cases with inheritance Jan 21, 2025
@SigureMo SigureMo changed the title [SOT] split certain LOAD_ATTR in 3.12+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars,while replacing special cases with inheritance [SOT][3.13] split certain LOAD_ATTR in 3.12+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars,while replacing special cases with inheritance Jan 21, 2025
@GoldenStain GoldenStain changed the title [SOT][3.13] split certain LOAD_ATTR in 3.12+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars,while replacing special cases with inheritance [SOT][3.13] split certain LOAD_ATTR in 3.13+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars,while replacing special cases with inheritance Jan 21, 2025
@GoldenStain GoldenStain changed the title [SOT][3.13] split certain LOAD_ATTR in 3.13+ & replace get_items and flatten_items with get_inner_vars and flatten_inner_vars,while replacing special cases with inheritance [SOT][3.13] split certain LOAD_ATTR in 3.13+ & replace get_items and flatten_items withflatten_inner_vars,while replacing special cases with inheritance Jan 22, 2025
@GoldenStain GoldenStain changed the title [SOT][3.13] split certain LOAD_ATTR in 3.13+ & replace get_items and flatten_items withflatten_inner_vars,while replacing special cases with inheritance [SOT][3.13] split certain LOAD_ATTR in 3.13+ & replace get_items and flatten_items withflatten_inner_vars,while replacing special cases with inheritance & remove method_name attribute in MethodVariable Jan 22, 2025
@SigureMo
Copy link
Member

问题case

问题 case 不应该只写在 PR 描述里,应该确保写在单测里,这样我们才能确保后续不会因为遇到相同问题造成回归,只要通过 CI 就能保证没有大问题

而如果 CI 检测不出来,合入之后的天级别、周级别 CE 才检测出来的话,反馈周期长,且会在 develop 影响大量下游场景,在修复完成前都会影响相关模型监控以及相关同学的开发,无论是对于自己负责的模块还是下游模块都会有影响

另一方面,相关 case 写在 CI 里我们才能放心进行代码重构,CI 过了就能拦截 90% 的问题,但如果 CI 单测体系不完备的话,今天刚修的 bug,过几个月再重构代码基本就忘掉了(团队开发更是如此),那没有单测覆盖到的逻辑就可能因此漏掉,后续还要再修一遍,浪费大量人力

这个 case 写在 test/sot/test_min_graph_size.py 里,确保使用 @min_graph_size_guard(10)

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit dcb9419 into PaddlePaddle:develop Jan 23, 2025
32 checks passed
@GoldenStain GoldenStain deleted the clas-problem-solving branch March 19, 2025 13:56
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