Skip to content
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

【Hackathon 5th No.112】move fused_gemm_epilogue to phi and add the yaml of identity_loss #59363

Merged
merged 29 commits into from
Dec 21, 2023

Conversation

zeroRains
Copy link
Contributor

PR types

Others

PR changes

Others

Description

move fused_gemm_epilogue to phi

Copy link

paddle-bot bot commented Nov 25, 2023

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

@paddle-bot paddle-bot bot added the contributor External developers label Nov 25, 2023
@zeroRains zeroRains changed the title 【Hackathon 5th No.103】 move fused_gemm_epilogue to phi- part 【Hackathon 5th No.112】 move fused_gemm_epilogue to phi- part Nov 25, 2023
@zeroRains
Copy link
Contributor Author

zeroRains commented Nov 25, 2023

这种在编译时出现的IR错误应该怎么定位呢,希望能获得一些建议~

image

Comment on lines 3514 to 3515
- op: write_to_array
backward : fused_gemm_epilogue_grad
Copy link
Contributor

Choose a reason for hiding this comment

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

这里看起来写错了?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这就改,(:з」∠)

@YuanRisheng
Copy link
Contributor

YuanRisheng commented Nov 29, 2023

这种在编译时出现的IR错误应该怎么定位呢,希望能获得一些建议~

image

这种在编译时出现的IR错误应该怎么定位呢,希望能获得一些建议~

image

这个算子已经在manual_op.cc里有了手写的pir代码,无法再次通过yaml文件来生成,所以会出现如上错误,这个比较特殊,这里无法将原来的op.cc文件彻底删除,只能删除原文件的Kernel实现部分,将op定义保留,可以参考一下fused_softmax_mask这个算子。
然后接着有俩种解决方法:
1,优先考虑配置Legacy_ops.yaml文件,配置这个后会产生动态图使用的api供python端使用,需要将python端代码:_legacy_C_ops.fused_gemm_epilogue修改成_C_ops.fused_gemm_epilogue,配置这个yaml文件对静态图没影响
2,如果1方案出现了各种问题不太好处理,yaml文件就别配置了,但是这个方法无法达到算子迁移的全部目的

@zeroRains
Copy link
Contributor Author

这种在编译时出现的IR错误应该怎么定位呢,希望能获得一些建议~
image

这种在编译时出现的IR错误应该怎么定位呢,希望能获得一些建议~
image

这个算子已经在manual_op.cc里有了手写的pir代码,无法再次通过yaml文件来生成,所以会出现如上错误,这个比较特殊,这里无法将原来的op.cc文件彻底删除,只能删除原文件的Kernel实现部分,将op定义保留,可以参考一下fused_softmax_mask这个算子。 然后接着有俩种解决方法: 1,优先考虑配置Legacy_ops.yaml文件,配置这个后会产生动态图使用的api供python端使用,需要将python端代码:_legacy_C_ops.fused_gemm_epilogue修改成_C_ops.fused_gemm_epilogue,配置这个yaml文件对静态图没影响 2,如果1方案出现了各种问题不太好处理,yaml文件就别配置了,但是这个方法无法达到算子迁移的全部目的

谢谢老师,我学习一下~

@zeroRains zeroRains changed the title 【Hackathon 5th No.112】 move fused_gemm_epilogue to phi- part 【Hackathon 5th No.112】 move fused_gemm_epilogue to phi and add the yaml of identity_los- part Dec 1, 2023
@zeroRains zeroRains changed the title 【Hackathon 5th No.112】 move fused_gemm_epilogue to phi and add the yaml of identity_los- part 【Hackathon 5th No.112】move fused_gemm_epilogue to phi and add the yaml of identity_loss- part Dec 1, 2023
Comment on lines 116 to 120
op->SetInput(framework::GradVarName("Out"), this->OutputGrad("Out"));

op->SetOutput("DX", this->InputGrad("X"));
op->SetOutput("DY", this->InputGrad("Y"));
op->SetOutput("DBias", this->InputGrad("Bias"));
op->SetOutput(framework::GradVarName("X"), this->InputGrad("X"));
op->SetOutput(framework::GradVarName("Y"), this->InputGrad("Y"));
op->SetOutput(framework::GradVarName("Bias"), this->InputGrad("Bias"));
Copy link
Contributor

Choose a reason for hiding this comment

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

这里随意修改Op定义会有问题,因为在op定义后,很多其他组件可能就默认使用定义好的名字,这里修改后会造成命名对不上,建议恢复原状

REGISTER_OPERATOR(fused_gemm_epilogue_grad,
ops::FusedGemmEpilogueGradOp,
ops::FusedGemmEpilogueGradOpMaker);
FusedGemmEpilogueGradInferShapeFunctor);
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以不删除ops::FusedGemmEpilogueGradOpMaker吗

@zeroRains zeroRains force-pushed the 112_fused branch 2 times, most recently from 4c34b68 to c41b7eb Compare December 16, 2023 06:18
@zeroRains
Copy link
Contributor Author

麻烦老师帮忙看一下这个是什么attribute type,我看GpuPS和Kunlun-R200的CI都是这个类型有问题。

image

@luotao1
Copy link
Contributor

luotao1 commented Dec 20, 2023

@zeroRains

  1. fused_gemm_epilogue: @YuanRisheng 在找高版本CUDA机器和kunlun机器复现
  2. identity_loss:可以分开提PR,先完成 add the yaml of identity_loss

@YuanRisheng
Copy link
Contributor

YuanRisheng commented Dec 20, 2023

@zeroRains sig文件写的有问题,这样改试试:

KernelSignature FusedGemmEpilogueGradOpArgumentMapping(
    const ArgumentMappingContext& ctx) {
  return KernelSignature("fused_gemm_epilogue_grad",
                         {"X", "Y", "ReserveSpace","DOut"},
                         {"trans_x", "trans_y", "activation_grad"},
                         {"DX", "DY", "DBias"});
}

@zeroRains
Copy link
Contributor Author

@YuanRisheng 好像可以了

YuanRisheng
YuanRisheng previously approved these changes Dec 21, 2023
@luotao1 luotao1 changed the title 【Hackathon 5th No.112】move fused_gemm_epilogue to phi and add the yaml of identity_loss- part 【Hackathon 5th No.112】move fused_gemm_epilogue to phi and add the yaml of identity_loss Dec 21, 2023
Comment on lines 1238 to 1239
data_type : x
backend : x
Copy link
Contributor

Choose a reason for hiding this comment

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

输入tensor只有一个x, 这里的dtype和backend可以不配置

Comment on lines 529 to 533
void IdentityLossGradInferMeta(const MetaTensor& x,
const MetaTensor& out_grad,
const int reduction,
MetaTensor* x_grad);

Copy link
Contributor

Choose a reason for hiding this comment

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

InferMeta函数按照字母序放置

@luotao1 luotao1 merged commit 3976459 into PaddlePaddle:develop Dec 21, 2023
29 checks passed
@zeroRains zeroRains deleted the 112_fused branch January 30, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants