Skip to content

Conversation

AndPuQing
Copy link
Contributor

PR Category

Operator Mechanism

PR Types

New features

Description

为embedding添加了 max_norm, norm_type 参数,并添加了单测

实现方法:分别实现了CPU、GPU上的EmbeddingRenormKernel,并注册了inplace算子

Copy link

paddle-bot bot commented Mar 30, 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 Mar 30, 2024
Copy link

paddle-bot bot commented Mar 30, 2024

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

@zhwesky2010
Copy link
Contributor

@AndPuQing 你好,需要看一下大量CI没通过的原因

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

覆盖率流水线没过,如果这些函数本地测试都跑进了,请提供本地截图

Copy link

paddle-ci-bot bot commented Apr 14, 2024

Sorry to inform you that 8b803d9's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@luotao1 luotao1 added the API label Apr 24, 2024
Copy link

paddle-ci-bot bot commented Jun 25, 2024

Sorry to inform you that c9d0326's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@zhwesky2010
Copy link
Contributor

@AndPuQing 冲突麻烦修改一下

r"""
This operator is used to update the embedding weight by renorm.
"""
if in_dynamic_mode():
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. 这里能否 不新加kernel,直接复用已有kernel,因为embedding renorm kernel里其实也复用的是pnorm(paddle.linalg.norm
  2. 如果不能复用norm,是不是因为inplace的问题,那能否直接在原有 paddle.linalg.norm 的基础上改造使得其支持,尽可能复用已有的计算逻辑
  3. paddle.nn.functional.embedding_renorm_需要公开出来不,torch有这个没

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1.2. 现在修改为了利用现有API组装这个算子,inplace 使用 paddle.scatter_

  1. 用户是可以直接调用torch.embedding_renorm_的,但是没有doc

@@ -127,10 +129,33 @@ def one_hot(
return one_hot_out


@inplace_apis_in_dygraph_only
Copy link
Contributor

@zhwesky2010 zhwesky2010 Jul 3, 2024

Choose a reason for hiding this comment

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

这个还需要吗,因为组合的API都是动静统一的,是因为组合里面的有纯动态图下的API吗?@AndPuQing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scatter_ 是 inplace_apis_in_dygraph_only

@inplace_apis_in_dygraph_only

@@ -17,6 +17,7 @@
import numpy as np

import paddle
from paddle.nn.functional.input import embedding_renorm_
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

@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

@zhwesky2010
Copy link
Contributor

@AndPuQing 这个还少一个参数scale_grad_by_freq,该任务完成了2/3

@zhwesky2010
Copy link
Contributor

zhwesky2010 commented Jul 26, 2024

@AndPuQing API英文文档没有修改,请提交一个PR。该PR合入后,请在docs里修改API中文文档、API映射文档。

以上所有文档(英文文档、中文文档、映射文档)合入后,该任务算完成。(计做2/3)

@luotao1 luotao1 merged commit 3546372 into PaddlePaddle:develop Jul 29, 2024
30 of 31 checks passed
@AndPuQing AndPuQing deleted the hack-no23 branch July 29, 2024 03:47
lixcli pushed a commit to lixcli/Paddle that referenced this pull request Aug 5, 2024
…ding 增加参数 max_norm/norm_type/scale_grad_by_freq - part (PaddlePaddle#63130)

* Add embedding_renorm_ function to functional module

* Fix embedding_renorm_ function signature

* Add max_norm and norm_type parameters to Embedding class

* Remove scale_grad_by_freq parameter from embedding function

* remove scale_grad_by_freq parameter

* add test case

* refactor: use fabs and powf functions

* refactor: use api to build embedding_renorm

* remove embedding_renorm_ function from __all__

* fix

* add static test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants