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

[phi] Decoupled phi from fluid tracking issue #47615

Closed
GreatV opened this issue Nov 2, 2022 · 6 comments
Closed

[phi] Decoupled phi from fluid tracking issue #47615

GreatV opened this issue Nov 2, 2022 · 6 comments
Assignees
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/new-feature 确认的新需求

Comments

@GreatV
Copy link
Contributor

GreatV commented Nov 2, 2022

问题描述 Please describe your issue

项目说明

用于跟踪 Call-for-Contributions: 飞桨算子体系重构 - PHI算子库独立编译 并记录该计划下各个子任务的计划和进度。

主要工作

当前 PHI 解耦独立编译基本可以分为以下两个阶段的工作。

头文件依赖解耦(整体进展 103/103)

按 merge 的时间顺序,排名不分先后:@GreatV (8), @jzhang533 (1), @chenwhql (6), @huangjiyi (53), @AndPuQing (7), @Silv3S (1), @jczaja (1), @Asthestarsfalll (2) @Patrick-Star125 (5) @DrRyanHuang (1),@engineer1109(3), @RedContritio (3) @YuanRisheng (8) @gouzil(2)@jinyouzhi(1) @jiahy0825(1)

编号 细分头文件 存量数 难度 相关PR 作者
======= collective ========
1 paddle/fluid/distributed/collective/ProcessGroup.h 4 困难 #51651 @YuanRisheng
2 paddle/fluid/distributed/collective/ProcessGroupNCCL.h 1 困难 #51651 @YuanRisheng
======= eager ========
3 paddle/fluid/eager/api/utils/global_utils.h ✅ (2022/11/08) 3 简单 #47739 @GreatV
======= framework ========
4 paddle/fluid/framework/convert_utils.h ✅ (2022/11/17) 17 中等 #48001 #48168 @huangjiyi
5 paddle/fluid/framework/custom_operator.h 1 中等 @jiahy0825
6 paddle/fluid/framework/data_layout.h ✅ (2022/11/09) 2 简单 #47770 @huangjiyi
7 paddle/fluid/framework/data_type.h ✅ (2022/11/09) 9 简单 #47776 @GreatV
8 paddle/fluid/framework/eigen.h ✅ (2022/11/08) 9 简单 #47675 @jzhang533
9 paddle/fluid/framework/expect.h ✅ (2022/11/05) 1 简单 #46342 @chenwhql
10 paddle/fluid/framework/generator.h ✅ (2022/11/10) 9 简单 #47822 @GreatV
11 paddle/fluid/framework/gpu_utils.h ✅ (2022/11/16) 1 中等 #48020 @huangjiyi
12 paddle/fluid/framework/infershape_utils.h ✅ (2022/11/09) 2 中等 #47714 @chenwhql
13 paddle/fluid/framework/lod_tensor.h ✅ (2022/11/11) 2 简单 #47840 @GreatV
14 paddle/fluid/framework/mixed_vector.h ✅ 5 中等 #50282 @huangjiyi
15 paddle/fluid/framework/op_registry.h ✅ (2022/11/11) 5 简单 #47868 @GreatV
16 paddle/fluid/framework/op_version_registry.h ✅ (2022/11/09) 1 简单 #47714 @chenwhql
17 paddle/fluid/framework/operator.h 2 中等 #51472 #50624 @jinyouzhi @RedContritio
18 paddle/fluid/framework/tensor.h ✅ (2023/2/20) 4 简单 #50475 @RedContritio
19 paddle/fluid/framework/tensor_util.h ✅ 43 困难 #49885 #50139 #50264 #50538 #50608 @engineer1109 @huangjiyi
20 paddle/fluid/framework/threadpool.h ✅ (2022/11/21) 1 中等 #48075 @AndPuQing
21 paddle/fluid/framework/variable.h ✅ 2 中等 #50407 @huangjiyi
22 paddle/fluid/framework/version.h ✅ 1 困难 #50608 @huangjiyi
======= imperative ========
23 paddle/fluid/imperative/gradient_accumulator.h ✅ 1 中等 #50385 @huangjiyi
======= memory ========
24 paddle/fluid/memory/allocation/allocator.h 3 困难 #50419 @YuanRisheng
25 paddle/fluid/memory/buffer.h 2 中等 #51288 @YuanRisheng
26 paddle/fluid/memory/malloc.h 18 困难 #50419 @YuanRisheng
27 paddle/fluid/memory/memcpy.h 47 困难 #50870 @YuanRisheng
28 paddle/fluid/memory/memory.h 18 困难 #50870 @YuanRisheng
======= operators ========
29 paddle/fluid/operators/amp/fp16_type_traits.h ✅ (2022/11/18) 5 中等 #48051 @huangjiyi
30 paddle/fluid/operators/conv_op.h ✅ (2022/11/15) 1 中等 #47914 @GreatV
31 paddle/fluid/operators/detection/bbox_util.h ✅ (2022/12/8) 1 中等 #48761 @Patrick-Star125
32 paddle/fluid/operators/detection/poly_util.h ✅ (2022/12/5) 1 中等 #48499 @Patrick-Star125
33 paddle/fluid/operators/dropout_impl.cu.h ✅ (2022/12/20) 2 中等 #49139 @huangjiyi
34 paddle/fluid/operators/eigen/eigen_function.h ✅ (2022/11/11) 5 简单 #47842 @huangjiyi
35 paddle/fluid/operators/elementwise/elementwise_op_function.h ✅ (2022/11/15) 1 简单 #47870 @huangjiyi
36 paddle/fluid/operators/elementwise/elementwise_op_impl.cu.h ✅ (2022/11/15) 3 简单 #47870 @huangjiyi
37 paddle/fluid/operators/gather_scatter_kernel.h ✅ (2022/12/19) 8 中等 #49132 @huangjiyi
38 paddle/fluid/operators/jit/kernels.h 6 困难 #50911 @gouzil
39 paddle/fluid/operators/layer_norm_kernel.cu.h ✅ 2 中等 #50506 @huangjiyi
40 paddle/fluid/operators/layout_utils.h ✅ 2 中等 #50355 @huangjiyi
41 paddle/fluid/operators/math.h ✅ (2022/11/17) 6 中等 #48062 @huangjiyi
42 paddle/fluid/operators/math/cross_entropy.h ✅ (2022/11/21) 3 中等 #48160 @huangjiyi
43 paddle/fluid/operators/math/im2col.h ✅ (2022/11/23) 9 中等 #48174 @huangjiyi
44 paddle/fluid/operators/math/inclusive_scan.h ✅ (2022/12/12) 2 中等 #48980 @Patrick-Star125
45 paddle/fluid/operators/math/matrix_bit_code.h ✅ (2022/12/19) 2 中等 #49131 @huangjiyi
46 paddle/fluid/operators/math/maxouting.h ✅ (2022/12/19) 2 中等 #49131 @huangjiyi
47 paddle/fluid/operators/math/sequence_padding.h 2 中等 #50639 @huangjiyi
48 paddle/fluid/operators/math/sequence_scale.h 2 中等 #49668 @DrRyanHuang
49 paddle/fluid/operators/math/softmax.h ✅ (2022/12/15) 6 中等 #48970 @huangjiyi
50 paddle/fluid/operators/math/softmax_impl.h ✅ (2022/12/15) 2 中等 #48970 @huangjiyi
51 paddle/fluid/operators/math/vol2col.h ✅(2022/11/22) 5 中等 #48175 @huangjiyi
52 paddle/fluid/operators/mkldnn/axpy_handler.h ✅(2022/11/15) 1 中等 #47779 @Silv3S
53 paddle/fluid/operators/norm_utils.cu.h ✅(2022/12/12) 2 中等 #48930 @huangjiyi
54 paddle/fluid/operators/ops_extra_info.h ✅ (2022/12/9) 1 中等 #48926 @huangjiyi
55 paddle/fluid/operators/strided_memcpy.h ✅ 4 困难 #50346 @huangjiyi
56 paddle/fluid/operators/top_k_function_cuda.h ✅ (2022/11/28) 4 中等 #48251 @Asthestarsfalll
57 paddle/fluid/operators/transpose_op.cu.h ✅ (2022/11/30) 1 中等 #48286 @Patrick-Star125
58 paddle/fluid/operators/utils.h 5 中等 #50624 @RedContritio
59 paddle/fluid/platform/bfloat16.h ✅ (2022/11/11) 4 简单 #47831 @AndPuQing
60 paddle/fluid/platform/collective_helper.h 3 中等 #51651 @YuanRisheng
61 paddle/fluid/platform/complex.h ✅ (2022/11/15) 4 简单 #47926 @huangjiyi
62 paddle/fluid/platform/cpu_info.h✅ (2022/11/28) 5 中等 #48403 @AndPuQing
63 paddle/fluid/platform/cuda_graph_with_memory_pool.h ✅ (2022/12/20) 2 中等 #49139 @huangjiyi
64 paddle/fluid/platform/cudnn_workspace_helper.h 6 中等 已完成 未知
======= device ========
65 paddle/fluid/platform/device_context.h 24 困难 #50865 #51541 #51559 @huangjiyi
66 paddle/fluid/platform/device/custom/enforce_custom.h ✅ (2022/11/29) 1 中等 #48422 @Asthestarsfalll
67 paddle/fluid/platform/device/device_wrapper.h 4 中等 #50749 @gouzil
68 paddle/fluid/platform/device/gpu/cuda/cuda_graph.h ✅ (2022/12/08) 1 中等 #48686 @huangjiyi
69 paddle/fluid/platform/device/gpu/cuda/cudnn_helper.h ✅ (2022/11/28) 2 中等 #48415 @huangjiyi
70 paddle/fluid/platform/device/gpu/cuda/cudnn_desc.h ✅ (2022/11/28) 1 中等 #48415 @huangjiyi
71 paddle/fluid/platform/device/gpu/gpu_device_function.h ✅ (2022/11/22) 16 中等 #48097 #48117 @huangjiyi
72 paddle/fluid/platform/device/gpu/gpu_dnn.h ✅ (2022/11/28) 14 中等 #48415 @huangjiyi
73 paddle/fluid/platform/device/gpu/gpu_info.h ✅ (2022/12/8) 10 中等 #48811 @Patrick-Star125
74 paddle/fluid/platform/device/gpu/gpu_launch_config.h ✅ (2022/11/10) 14 简单 #47808 @AndPuQing
75 paddle/fluid/platform/device/gpu/gpu_primitives.h✅ (2022/11/18) 56 困难 #48015
#48063
@GreatV
76 paddle/fluid/platform/device/gpu/nccl_helper.h 4 中等 #51651 @YuanRisheng
77 paddle/fluid/platform/device/gpu/rocm/miopen_helper.h ✅ (2022/11/28) 2 中等 #48415 @huangjiyi
78 paddle/fluid/platform/device/xpu/xpu_header.h ✅ (2022/11/28) 2 中等 #48420 @huangjiyi
79 paddle/fluid/platform/device/xpu/xpu_op_list.h ✅ (2022/11/28) 1 中等 #48420 @huangjiyi
80 paddle/fluid/platform/device_memory_aligment.h ✅ (2022/12/05) 2 中等 #48694 @huangjiyi
======= dynload ========
81 paddle/fluid/platform/dynload/cublas.h ✅ (2022/11/09) 1 简单 #47778 @huangjiyi
82 paddle/fluid/platform/dynload/cudnn.h ✅ (2022/11/09) 1 简单 #47787 @huangjiyi
83 paddle/fluid/platform/dynload/mklml.h ✅ (2022/11/09) 3 简单 #47787 @huangjiyi
84 paddle/fluid/platform/dynload/rocblas.h ✅ (2022/11/09) 1 简单 #47787 @huangjiyi
85 paddle/fluid/platform/enforce.h ✅ (2022/11/24) 24 中等 #48049 @AndPuQing
86 paddle/fluid/platform/errors.h ✅ (2022/11/10) 1 简单 #47815 @huangjiyi
87 paddle/fluid/platform/fast_divmod.h ✅ (2022/11/10) 4 简单 #47815 @huangjiyi
88 paddle/fluid/platform/flags.h ✅ (2022/12/09) 4 困难 #48696 @AndPuQing
89 paddle/fluid/platform/float16.h ✅ (2022/11/10) 5 简单 #47817 @huangjiyi
90 paddle/fluid/platform/for_range.h ✅ (2022/11/10) 6 简单 #47817 @huangjiyi
91 paddle/fluid/platform/function_traits.h ✅ (2022/11/17) 1 中等 #48065 @GreatV
92 paddle/fluid/platform/init.h 1 困难 #51511 @YuanRisheng
93 paddle/fluid/platform/mkldnn_utils.h ✅ (2022/11/9) 1 中等 #46768 @jczaja
94 paddle/fluid/platform/place.h ✅ (2022/11/10) 9 简单 #47823 @huangjiyi
======= profiler ========
95 paddle/fluid/platform/profiler.h 5 困难 #50191 @YuanRisheng
96 paddle/fluid/platform/profiler/event_tracing.h 11 困难 #50183 @YuanRisheng
97 paddle/fluid/platform/profiler/supplement_tracing.h 9 困难 #50721 @YuanRisheng
98 paddle/fluid/platform/transform.h ✅ 8 中等 #50498 @huangjiyi
======= cmake ========
99 paddle/fluid/operators/generated_op.cc ✅ (2022/11/09) 1 中等 #47714 @chenwhql
100 paddle/fluid/operators/generated_sparse_op.cc ✅ (2022/11/09) 1 中等 #47714 @chenwhql
101 paddle/fluid/operators/ops_extra_info.cc ✅ (2022/11/09) 1 中等 #47714 @chenwhql
======= others ========
102 paddle/fluid/platform/macros.h ✅ (2022/11/21) 1 简单 #48069 @AndPuQing
103 paddle/fluid/platform/device/gpu/rocm/miopen_desc.h✅ (2022/11/28) 1 中等 #48415 @huangjiyi

PHI 独立编译

当头文件的依赖清理完毕,我们可以修改当前 Paddle 的编译方式,将 PHI 作为独立的 Library 对象进行编译,这需要对于编译原理和 CMake 语法比较熟悉的同学先设计编译改动方案,经过飞桨研发工程师和社区开发者一起评审后再推进执行。

@paddle-bot
Copy link

paddle-bot bot commented Nov 2, 2022

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档常见问题历史IssueAI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

@paddle-bot paddle-bot bot added the PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc label Nov 2, 2022
@GreatV
Copy link
Contributor Author

GreatV commented Nov 2, 2022

@luotao1 @chenwhql 麻烦看一下是否有遗漏或者分解地太细了。

@luotao1
Copy link
Contributor

luotao1 commented Nov 8, 2022

头文件依赖解耦具体说明 ( 整理 by @GreatV

首先,paddle/phi 目录下仍然有许多文件在 include paddle/fluid 目录下的文件。

基于本文撰写时 Paddle repo 的最新 commit d5e7d20 在 paddle/phi 下搜索 #include "paddle/fluid 并去掉 tests 子目录,可以匹配到 355 个文件中包含 583 个结果,首要任务就是要将这 583 个 include 去掉。

使用如下命令查找include的结果,共583个结果:

grep -In -r --exclude-dir=tests "paddle/fluid/" paddle/phi
paddle/phi/core/kernel_factory.cc:20:#include "paddle/fluid/platform/device/xpu/xpu_op_list.h"
paddle/phi/core/string_tensor.cc:17:#include "paddle/fluid/memory/malloc.h"
paddle/phi/core/tensor_utils.cc:23:#include "paddle/fluid/memory/malloc.h"
paddle/phi/core/tensor_utils.cc:24:#include "paddle/fluid/memory/memcpy.h"
paddle/phi/core/tensor_utils.cc:25:#include "paddle/fluid/platform/device_context.h"
paddle/phi/core/cuda_stream.h:32:#include "paddle/fluid/platform/enforce.h"
paddle/phi/core/dense_tensor_impl.cc:15:#include "paddle/fluid/memory/malloc.h"
paddle/phi/core/dense_tensor_impl.cc:23:#include "paddle/fluid/platform/mkldnn_utils.h"
paddle/phi/core/serialization.cc:21:#include "paddle/fluid/framework/tensor_util.h"
paddle/phi/core/serialization.cc:22:#include "paddle/fluid/framework/version.h"
paddle/phi/core/dense_tensor.cc:40:#include "paddle/fluid/memory/malloc.h"
paddle/phi/core/device_context.cc:18:#include "paddle/fluid/platform/device/gpu/cuda/cuda_graph.h"
paddle/phi/core/selected_rows_impl.cc:20:#include "paddle/fluid/memory/memcpy.h"
paddle/phi/api/lib/backward_api.cc.tmp:16:#include "paddle/fluid/eager/api/utils/global_utils.h"
paddle/phi/api/lib/backward_api.cc.tmp:17:#include "paddle/fluid/platform/profiler/event_tracing.h"
paddle/phi/api/lib/backward_api.cc.tmp:18:#include "paddle/fluid/platform/profiler/supplement_tracing.h"
paddle/phi/api/lib/context_pool.cc:20:#include "paddle/fluid/platform/init.h"
paddle/phi/api/lib/api.cc:18:#include "paddle/fluid/platform/profiler/event_tracing.h"
paddle/phi/api/lib/api.cc:19:#include "paddle/fluid/platform/profiler/supplement_tracing.h"
paddle/phi/api/lib/op_meta_info.cc:22:#include "paddle/fluid/framework/custom_operator.h"
... 

使用如下命令查找匹配到的文件,共355个结果:

grep -Il -r --exclude-dir=tests "paddle/fluid/" paddle/phi
paddle/phi/core/kernel_factory.cc
paddle/phi/core/string_tensor.cc
paddle/phi/core/tensor_utils.cc
paddle/phi/core/cuda_stream.h
paddle/phi/core/dense_tensor_impl.cc
paddle/phi/core/serialization.cc
paddle/phi/core/dense_tensor.cc
paddle/phi/core/device_context.cc
paddle/phi/core/selected_rows_impl.cc
paddle/phi/api/lib/backward_api.cc.tmp
paddle/phi/api/lib/context_pool.cc
paddle/phi/api/lib/api.cc
paddle/phi/api/lib/op_meta_info.cc
paddle/phi/api/lib/CMakeLists.txt
paddle/phi/api/lib/dygraph_api.cc.tmp
paddle/phi/api/lib/dygraph_api.cc
paddle/phi/api/lib/utils/tensor_utils.h
paddle/phi/api/lib/utils/allocator.h
...

对包含的头文件去重,发现共有100个左右不同的头文件:

grep -Irn --exclude-dir=tests "paddle/fluid/*" paddle/phi | grep "paddle/fluid" | grep -v party | awk '{print $NF}' | sort | uniq -c | sort -nr
56 "paddle/fluid/platform/device/gpu/gpu_primitives.h"
47 "paddle/fluid/memory/memcpy.h"
43 "paddle/fluid/framework/tensor_util.h"
24 "paddle/fluid/platform/enforce.h"
23 "paddle/fluid/platform/device_context.h"
18 "paddle/fluid/memory/memory.h"
18 "paddle/fluid/memory/malloc.h"
17 "paddle/fluid/framework/convert_utils.h"
16 "paddle/fluid/platform/device/gpu/gpu_device_function.h"
14 "paddle/fluid/platform/device/gpu/gpu_launch_config.h"
14 "paddle/fluid/platform/device/gpu/gpu_dnn.h"
11 "paddle/fluid/platform/profiler/event_tracing.h"
10 "paddle/fluid/platform/device/gpu/gpu_info.h"
9 "paddle/fluid/platform/profiler/supplement_tracing.h"

...

具体的头文件可总结如下:

难度标记说明:结合任务说明中对于三类不同情况的介绍,根据所依赖模块的解耦复杂程度,将下列每个头文件所对应的解耦工作进行难度标记,分为三个等级:“简单”, “中等”,“困难(复杂)”,这里概要介绍一下,详细可以参考任务说明:

  • 简单:具体情况包括,1)头文件无使用可以直接移除,2)头文件在phi下有可替换的头文件
  • 中等:具体情况包括,1)需要先将部分函数迁移至phi目录,再更换头文件;2. 需要将部分phi中代码移回fluid
  • 困难:具体情况包括:1)现阶段模块依赖复杂,解耦需要在phi目录下先设计实现相应子功能或接口用于替换;2)依赖的模块过于复杂,整体迁移成本很高

注:人工标记,可能存在一定误判,大家可以根据情况更正

@luotao1
Copy link
Contributor

luotao1 commented Mar 29, 2023

头文件依赖解耦已全部完成,感谢参与的小伙伴们!

@GreatV (8), @jzhang533 (1), @chenwhql (6), @huangjiyi (53), @AndPuQing (7), @Silv3S (1), @jczaja (1), @Asthestarsfalll (2) @Patrick-Star125 (5) @DrRyanHuang (1),@engineer1109(3), @RedContritio (3) @YuanRisheng (8) @gouzil(2)@jinyouzhi(1) @jiahy0825(1)

结项小结等4月底完成 PHI 独立编译后发出。

@luotao1 luotao1 closed this as completed Mar 29, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Call for Contributions Mar 29, 2023
@paddle-bot paddle-bot bot added the status/close 已关闭 label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PFCC Paddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfcc status/close 已关闭 type/new-feature 确认的新需求
Projects
Development

No branches or pull requests

9 participants