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

飞桨框架API易用性提升开源任务 #55883

Closed
zhwesky2010 opened this issue Aug 1, 2023 · 40 comments
Closed

飞桨框架API易用性提升开源任务 #55883

zhwesky2010 opened this issue Aug 1, 2023 · 40 comments
Assignees
Labels
HappyOpenSource 快乐开源活动issue与PR status/close 已关闭

Comments

@zhwesky2010
Copy link
Contributor

zhwesky2010 commented Aug 1, 2023

整体背景

大家好,为了提升模型迁移的效率,我们建设了 代码自动转换工具: PaddlePaddle Code Convert Toolkits,为了降低 代码自动转换工具 中转换规则Matcher的开发难度,我们需要对部分框架API的功能和易用性进行增强。

🍻 你需要做的是

我们已将任务记录在《在线任务明细表》,一共55个任务,其中 问题描述 这一列阐述了当前Paddle API的问题;修改方案 这一列阐述了该API的升级修改思路,即你需要开发的内容;预计成本 这一列阐述了该任务的预估难度及成本。大家可根据这三列信息,来评估和选择自己适合的任务,并自由认领任务,认领时直接在本issue下回复 任务ID 即可,欢迎大家来认领任务和提PR ~

✨ 注意:

  1. 该任务时间:PR 截止合入时间是2024/3/31。

  2. 开发流程与Paddle代码贡献流程完全一致,可参考Paddle官网文档:代码贡献流程

  3. API修改时,请注意同时修改 API中文文档(位于doc repo中)API英文文档

  4. PR请先通过CI检查后再发起review,避免增加不必要的review成本。

  5. PR标题格式:No.1~35 paddle.xxx易用性提升PR描述需要附上本issue,在提交PR后我们会内部指派reviewer,由该reviewer负责合入。

  6. 历史上的 good first issue 列表,也欢迎来提 PR 解决~ 欢迎联系花花加入社区,和我们一起快乐开源

image


Overall Background:

Hello everyone, in order to improve the efficiency of model migration, we have built a code auto-conversion tool: PaddlePaddle Code Convert Toolkits. To reduce the development difficulty of conversion rules Matcher in the code auto-conversion tool, we need to enhance the functionality and usability of some framework APIs.

What You Need to Do:

We have recorded the tasks in the Online Task Details, totaling 35 tasks. The "Issue" column explains the current issues with the Paddle API, the "Solution" column outlines the upgrade and modification approach for that API, which is what you need to develop. The "Workload Estimate" column describes the estimated difficulty and cost of the task. You can evaluate and choose tasks that suit you based on these three columns and freely claim tasks. When claiming a task, simply reply with the task ID in this issue. Welcome everyone to claim tasks and submit PRs~

Note:

  1. The deadline for this task: The PR deadline for merging is October 31, 2023.
  2. The development process is completely consistent with the Paddle code contribution process. You can refer to the Paddle official website documentation: Code Contribution Process.
  3. When modifying APIs, please remember to update the API Chinese documentation (located in the doc repo) and API English documentation at the same time.
  4. Please initiate a review only after passing the CI checks to avoid unnecessary review costs.
  5. PR Title Format: No.1~35 paddle.xxx usability improvement. PR descriptions should include a reference to this issue. After submitting a PR, we will internally assign a reviewer responsible for merging.
  6. List of historical good first issues is also welcome for PR solutions~ Feel free to contact Hua Hua to join the community and enjoy open source together!
@zhwesky2010 zhwesky2010 changed the title 飞桨API易用性提升: paddle.diff 飞桨框架API易用性提升开源任务 Aug 2, 2023
@zhwesky2010
Copy link
Contributor Author

zhwesky2010 commented Aug 2, 2023

🍻 任务列表(整体进度 8/34)

按 merge 的时间顺序,排名不分先后: @XavierZXY (1) @Liyulingyue (1) @enkilee (1) @YibinLiu666 (4)

任务 ID 认领人 Github Paddle PR 链接 中文文档 链接(如有)
01 ✅(2023/8/29) @XavierZXY #56681 #56736 PaddlePaddle/docs#6148
02
03✅(2023/8/29) @Liyulingyue #56470 #56728 PaddlePaddle/docs#6147
04
05✅(2023/10/17) @enkilee #56761
06✅ 验证后发现是参数的随机初始化导致结果不同,无需修改
07✅(2023/12/22) @YibinLiu666 #60084 PaddlePaddle/docs#6415
08
09✅(2023/11/13) @YibinLiu666 #58632 PaddlePaddle/docs#6291
10 @YibinLiu666
11
12
13
14 @YibinLiu666
15
16
17
18
19
20
21 @YibinLiu666 #60275
22
23
24
25
26
27✅(2023/12/4) @YibinLiu666 #59163
28
29
30
31
32
33 ✅(2023/12/19) @YibinLiu666 #60054
34

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Aug 3, 2023
@paddle-bot paddle-bot bot added status/following-up 跟进中 and removed status/new-issue 新建 labels Aug 4, 2023
@GreatV
Copy link
Contributor

GreatV commented Aug 5, 2023

@snorfyang 任务明细表还没更新,估计还需要一段时间。

@Ligoml Ligoml removed status/following-up 跟进中 type/others 其他问题 labels Aug 9, 2023
@zhwesky2010
Copy link
Contributor Author

在线任务明细表链接是不是错了 @zhwesky2010

你好,已更新在线任务明细表

@GreatV
Copy link
Contributor

GreatV commented Aug 17, 2023

认领

序号 api 认领人 PR
26 paddle.linalg.solve @GreatV

@enkilee
Copy link
Contributor

enkilee commented Aug 18, 2023

认领

序号 api 认领人 PR
12 paddle.nn.utils.parameters_to_vector @enkilee #56761

@luotao1
Copy link
Contributor

luotao1 commented Aug 18, 2023

@Ningsir 任务22的API paddle.distributed.rpc.shutdown 是之前你贡献的,请问有时间来增强功能么?

@longranger2
Copy link
Contributor

认领2

@BeingGod
Copy link
Contributor

认领15-19

@jinyouzhi
Copy link
Contributor

认领21

@Asthestarsfalll
Copy link
Contributor

认领10 11

@yangguohao
Copy link
Contributor

任务 No.14 中的问题:

  1. Pytorch margin 可以为负数。Pytorch 在文档上写的 margin 是 non-negative,但是可以传入负数,且正常计算不报错。Paddle 中加入了报错。
  2. 计算的 distance 可以为负数。Pytorch 中 anchor 与 positive 和 negative 分别计算出的 distance 可以为负数。Paddle 中同样也加入了判断会报错。
    以上两个问题的修改与 Pytorch 对齐即可吗

@zhwesky2010
Copy link
Contributor Author

任务 No.14 中的问题:

  1. Pytorch margin 可以为负数。Pytorch 在文档上写的 margin 是 non-negative,但是可以传入负数,且正常计算不报错。Paddle 中加入了报错。
  2. 计算的 distance 可以为负数。Pytorch 中 anchor 与 positive 和 negative 分别计算出的 distance 可以为负数。Paddle 中同样也加入了判断会报错。
    以上两个问题的修改与 Pytorch 对齐即可吗

关于你说的这两个差异,需要看下torch可以设置为负数是否合理,如果合理的话paddle也是应该支持的

除了这两个差异外,https://github.com/PaddlePaddle/PaConvert/blob/master/tests/test_nn_functional_triplet_margin_with_distance_loss.py#L22-L79 这几个case计算出的结果,pytorch与paddle不同,还需要看下是否paddle计算得不对

@yangguohao
Copy link
Contributor

任务 No.14 中的问题:

  1. Pytorch margin 可以为负数。Pytorch 在文档上写的 margin 是 non-negative,但是可以传入负数,且正常计算不报错。Paddle 中加入了报错。
  2. 计算的 distance 可以为负数。Pytorch 中 anchor 与 positive 和 negative 分别计算出的 distance 可以为负数。Paddle 中同样也加入了判断会报错。
    以上两个问题的修改与 Pytorch 对齐即可吗

关于你说的这两个差异,需要看下torch可以设置为负数是否合理,如果合理的话paddle也是应该支持的

除了这两个差异外,https://github.com/PaddlePaddle/PaConvert/blob/master/tests/test_nn_functional_triplet_margin_with_distance_loss.py#L22-L79 这几个case计算出的结果,pytorch与paddle不同,还需要看下是否paddle计算得不对

我认为错误是测试文件中的 nn.Embeddings 生成的随机数与 Paddle 下生成的数据不同导致的。在固定 numpy 种子数,将 numpy 数据同时转为 torch 和 Paddle 下数据测试结果都是一致的。

image

另外 torch 的文档中都提到了,关于 Margin 和 distance_function 都是非负的(non-negative),但是代码中没有加入判断。

@XavierZXY
Copy link
Contributor

XavierZXY commented Aug 23, 2023

认领任务01

序号 api 认领人 PR 中文文档
1 paddle.diff @XavierZXY #56681 #6148

@akshatvishu
Copy link
Contributor

akshatvishu commented Sep 11, 2023

Claim 3

Also, if 8 and 25 are merged then please update the table with the same (currently only 8 is showing claimed)

@luotao1
Copy link
Contributor

luotao1 commented Sep 15, 2023

@akshatvishu We update the English Online Task Details and issue descrption.

@akshatvishu
Copy link
Contributor

@akshatvishu We update the English Online Task Details and issue descrption.

Much appreciated! Thanks for doing it!

@luotao1
Copy link
Contributor

luotao1 commented Sep 15, 2023

Of course, I am willing to contribute in any way thats possible. Can you provide more info on that, the links you provided has informations only in Chinese.

@dhanush-2501 We update the English Online Task Details and issue descrption.

@YibinLiu666
Copy link
Contributor

认领18

@YibinLiu666
Copy link
Contributor

认领35

@YibinLiu666
Copy link
Contributor

任务 No.35 中的问题:
paddle pool 的gpu实现是调用的cudnn接口,但是cudnn中的pool没有dilation这个参数

@zhwesky2010
Copy link
Contributor Author

zhwesky2010 commented Nov 15, 2023

任务 No.35 中的问题: paddle pool 的gpu实现是调用的cudnn接口,但是cudnn中的pool没有dilation这个参数

pool的GPU算子实现,是自行编写的cuda 核函数,这个在哪里看到的cudnn调用呢?如果是自行编写的cuda函数,就可以自定义的修改增强逻辑了。

infoflow 2023-11-15 17-36-47

@YibinLiu666
Copy link
Contributor

YibinLiu666 commented Nov 15, 2023

任务 No.35 中的问题: paddle pool 的gpu实现是调用的cudnn接口,但是cudnn中的pool没有dilation这个参数

pool的GPU算子实现,是自行编写的cuda 核函数,这个在哪里看到的cudnn调用呢?如果是自行编写的cuda函数,就可以自定义的修改增强逻辑了。

我看maxpool调用的c op是在https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/api/yaml/legacy_ops.yaml 这个里面定义的pool2d,然后我看https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/kernels/pool_kernel.h 里面有个Pool2dGPUDNNKernel的接口也被注册到pool2d,这个实现是用cudnn实现的。

@YibinLiu666
Copy link
Contributor

认领43、51

@zhwesky2010
Copy link
Contributor Author

任务 No.35 中的问题: paddle pool 的gpu实现是调用的cudnn接口,但是cudnn中的pool没有dilation这个参数

pool的GPU算子实现,是自行编写的cuda 核函数,这个在哪里看到的cudnn调用呢?如果是自行编写的cuda函数,就可以自定义的修改增强逻辑了。

我看maxpool调用的c op是在https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/api/yaml/legacy_ops.yaml 这个里面定义的pool2d,然后我看https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/kernels/pool_kernel.h 里面有个Pool2dGPUDNNKernel的接口也被注册到pool2d,这个实现是用cudnn实现的。

这个API有CPU、GPU(不适用cudnn)、GPUDNN(使用cudnn)的算子、XPU算子,使用cudnn应该也有办法实现,是将stride、dilation多个参数加工处理后,最终调用的cudnn接口。

@YibinLiu666
Copy link
Contributor

任务 No.35 中的问题: paddle pool 的gpu实现是调用的cudnn接口,但是cudnn中的pool没有dilation这个参数

pool的GPU算子实现,是自行编写的cuda 核函数,这个在哪里看到的cudnn调用呢?如果是自行编写的cuda函数,就可以自定义的修改增强逻辑了。

我看maxpool调用的c op是在https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/api/yaml/legacy_ops.yaml 这个里面定义的pool2d,然后我看https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/phi/kernels/pool_kernel.h 里面有个Pool2dGPUDNNKernel的接口也被注册到pool2d,这个实现是用cudnn实现的。

这个API有CPU、GPU(不适用cudnn)、GPUDNN(使用cudnn)的算子、XPU算子,使用cudnn应该也有办法实现,是将stride、dilation多个参数加工处理后,最终调用的cudnn接口。

好的,我再想一下怎么加工处理

@YibinLiu666
Copy link
Contributor

YibinLiu666 commented Nov 16, 2023

关于问题43的问题:
在修复此问题的bug时发现paddle的take_along_axis与torch的gather行为也不一致,不一致的代码如下:
import torch
t = torch.tensor([[1, 2], [3, 4]])
i=torch.tensor([[1]])
result = torch.gather(t,1,i)
torch对应的输出是tensor([[2]]),而paddle输出结果是
Tensor(shape=[2, 1], dtype=int64, place=Place(gpu:0), stop_gradient=True, [[2], [4]])
在完成该任务时需要一起解决吗

@zhwesky2010
Copy link
Contributor Author

zhwesky2010 commented Nov 17, 2023

关于问题43的问题: 在修复此问题的bug时发现paddle的take_along_axis与torch的gather行为也不一致,不一致的代码如下: import torch t = torch.tensor([[1, 2], [3, 4]]) i=torch.tensor([[1]]) result = torch.gather(t,1,i) torch对应的输出是tensor([[2]]),而paddle输出结果是 Tensor(shape=[2, 1], dtype=int64, place=Place(gpu:0), stop_gradient=True, [[2], [4]]) 在完成该任务时需要一起解决吗

@YibinLiu666 需要一起解决的,应该是之前没有扫描到。

@Olive-2019
Copy link

关于任务27、28的问题:
任务27:paddle不支持remove_duplicate,但是支持逻辑几乎一样的 include_sublayers
任务28:paddle不支持memo,但是支持逻辑几乎一样的 layers_set

解决方案:

  1. 忽略该意见
  2. 在文档中补充paddle参数和pytorch参数的等价关系(建议)
  3. 参数改名(不建议,这样之前的用户需要修改代码)
  4. 加入memoremove_duplicate参数,保持与include_sublayerslayers_set的逻辑同步,允许使用pytorch的同名参数(不太建议,加入冗余代码)

请问这两个任务采取哪种解决方案?

@zhwesky2010
Copy link
Contributor Author

zhwesky2010 commented Nov 29, 2023

关于任务27、28的问题: 任务27:paddle不支持remove_duplicate,但是支持逻辑几乎一样的 include_sublayers 任务28:paddle不支持memo,但是支持逻辑几乎一样的 layers_set

解决方案:

  1. 忽略该意见
  2. 在文档中补充paddle参数和pytorch参数的等价关系(建议)
  3. 参数改名(不建议,这样之前的用户需要修改代码)
  4. 加入memoremove_duplicate参数,保持与include_sublayerslayers_set的逻辑同步,允许使用pytorch的同名参数(不太建议,加入冗余代码)

请问这两个任务采取哪种解决方案?

建议要拿torch代码测试一下,是否完全一致,如果完全一致或者有简单的转写方式,则不需要调整API,写入映射文档中即可。如果差异很大,则需要扩充API的功能才可支持转写。

@YibinLiu666
Copy link
Contributor

第6题中 paddle.nn.functional.triplet_margin_with_distance_loss 与torch中不一样的复现代码能否提供一下

@zhwesky2010
Copy link
Contributor Author

第6题中 paddle.nn.functional.triplet_margin_with_distance_loss 与torch中不一样的复现代码能否提供一下

你好,这个验证后发现是参数的随机初始化导致结果不同,无需修改,关闭任务。

@YibinLiu666
Copy link
Contributor

认领7、10、14、21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HappyOpenSource 快乐开源活动issue与PR status/close 已关闭
Projects
Development

No branches or pull requests