Skip to content

nn.Embedding/F.embedding support scale_grad_by_freq 易用性提升 #70090

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 5 commits into from
Dec 16, 2024

Conversation

NKNaN
Copy link
Contributor

@NKNaN NKNaN commented Dec 10, 2024

PR Category

User Experience

PR Types

Improvements

Description

为避免不兼容修改,新增 embedding_with_scaled_gradient op,前向复用 embedding_kernel,反向新增 embedding_with_scaled_gradient_grad_kernel。

Copy link

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

@paddle-bot paddle-bot bot added the contributor External developers label Dec 10, 2024
@@ -1714,6 +1714,8 @@ class Embedding(Layer):
The local word vector needs to be transformed into numpy format, and the shape of local word
vector should be consistent with :attr:`num_embeddings` . Then :ref:`api_paddle_nn_initializer_Assign`
is used to load custom or pre-trained word vectors. See code example for details.
scale_grad_by_freq(bool, optional): Indicating whether to scale the gradients by the inverse frequency of the
Copy link
Contributor

Choose a reason for hiding this comment

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

这个是新增参数,且是最后面的的,按道理直接修改原kernel不会不兼容吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

原kernel的配置是动静不一致的,情况比较复杂,反向kernel要修改的话涉及很多个文件,我不确定会不会改错了。前几天试着改了一下但是最后在pir模式中 scale_grad_by_freq 没法正确传参。

paddle\phi\ops\yaml\inconsistent\dygraph_backward.yaml
image
paddle\phi\ops\yaml\inconsistent\static_backward.yaml
image
paddle\phi\ops\yaml\op_compat.yaml
image

Copy link
Contributor

@zhwesky2010 zhwesky2010 Dec 10, 2024

Choose a reason for hiding this comment

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

原kernel的配置是动静不一致的,情况比较复杂,反向kernel要修改的话涉及很多个文件,我不确定会不会改错了。前几天试着改了一下但是最后在pir模式中 scale_grad_by_freq 没法正确传参。

paddle\phi\ops\yaml\inconsistent\dygraph_backward.yaml image paddle\phi\ops\yaml\inconsistent\static_backward.yaml image paddle\phi\ops\yaml\op_compat.yaml image

kernel命名为scale_grad_by_frea是不规范的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/PaddlePaddle/Paddle/pull/70124/files
我不知道是不是哪里配置的不对

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/PaddlePaddle/Paddle/pull/70124/files 我不知道是不是哪里配置的不对

这个kernel的命名优化一下吧

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1 luotao1 merged commit 74c477f into PaddlePaddle:develop Dec 16, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants