CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[PIR-Auto-Parallel] set op_role
and chunk_id
for fuse linear pass
#70889
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
[PIR-Auto-Parallel] set op_role
and chunk_id
for fuse linear pass
#70889
Conversation
} | ||
if (add = user_it->owner()->dyn_cast<paddle::dialect::AddOp>()) { | ||
if (add->operand_source(0) != tmp) { | ||
continue; | ||
} | ||
can_fuse = true; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里没有限制matmul的输出只被add使用,替换fuse_gemm_epilogue的时候有失败的风险
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return (w_dims.size() == 2 && x_dims.size() >= 2 && | ||
bias_dims.size() == 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w,x,bias的限制约束条件最好和原来保持一致
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
): | ||
pm = pir.PassManager() | ||
pm.add_pass("fused_gemm_epilogue_pass", {}) | ||
pm.run(dense_program) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里执行过 fused_gemm_epilogue_pass 后,是不是可以从 fused_passes_list 删掉了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// fused to | ||
// %4, %5 = pd_op.fused_gemm_epilogue( %0, %1, %3 ) | ||
class FusedLinearPattern | ||
: public pir::OpRewritePattern<paddle::dialect::MatmulOp> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么不用 DrrPattern 了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fuse pass 转移到 PP 和 gradient merge 之前进行调用,需要保证 fuse 后新算子的 op_role 和 chunk_id 与原来一致
DrrPattern 不支持获取和设置 op_role 和 chunk_id,所以采用较为底层的 PatternRewrite 接口实现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Category
Auto Parallel
PR Types
Improvements
Description
背景:在
PP
并行 或者gradient merge
策略下,PIR program 会被切分成forward
、backward
和optimizer
子图,同时插入shawdow_output
算子进行子图间数据传输,这可能会插在 fuse linear pattern 中,造成子图中 pattern 识别失败,使得 fuse linear pass 不能生效该 PR 将 fuse linear pass 转移到
PP
并行 和gradient merge
策略之前进行调用,但融合的fused_gemm_epilogue
算子会丢失op_role
和chunk_id
的属性,在 pass 中增加op_role
和chunk_id
的属性设置,保证pp
和gradient merge
正常执行PCard-89139