Commit 3edeb00
authored
【UnitTestFix No.19】Fix test_fused_dot_product_attention_op_static.py (#76405)
- 移除了 `list(REMOVE_ITEM TEST_OPS test_fused_dot_product_attention_op_static)`
- 在Windows上使用如下cmake命令 `cmake .. -GNinja -DWITH_GPU=ON -DWITH_UNITY_BUILD=ON -DCUDA_ARCH_NAME=Auto -DWITH_TENSORRT=ON -DTENSORRT_ROOT=D:\TensorRT-10.13.3.9 -DWITH_TESTING=ON` ,编译成功
测试用例报错如下:
```shell
Start testing: Nov 05 21:48 中国标准时间
----------------------------------------------------------
1488/2270 Testing: test_fused_dot_product_attention_op_static
1488/2270 Test: test_fused_dot_product_attention_op_static
Command: "D:/Program Files/CMake/bin/cmake.exe" "-E" "env" "PYTHONPATH=D:/Lenovo/Paddle/build/python" "D:/Users/Lenovo/AppData/Local/Programs/Python/Python310/python.exe" "D:/Lenovo/Paddle/tools/test_runner.py" "test_fused_dot_product_attention_op_static"
Directory: D:/Lenovo/Paddle/build/test/legacy_test
"test_fused_dot_product_attention_op_static" start time: Nov 05 21:48 中国标准时间
Output:
----------------------------------------------------------
test_fused_dot_product_attention_op_static failed
E
======================================================================
ERROR: test_static_op (test_fused_dot_product_attention_op_static.TestFusedDotProductAttentionStatic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\Lenovo\Paddle\build\test\legacy_test\test_fused_dot_product_attention_op_static.py", line 74, in test_static_op
out0 = fused_dot_product_attention(q, k, v, mask)
File "D:\Lenovo\Paddle\build\python\paddle\incubate\nn\functional\fused_dot_product_attention.py", line 202, in fused_dot_product_attention
out, _, _ = _C_ops.fused_dot_product_attention(
RuntimeError: (NotFound) The kernel `fused_dot_product_attention` is not registered.
[Hint: Expected iter != kernels_.end(), but received iter == kernels_.end().] (at D:\Lenovo\Paddle\paddle\phi\core\kernel_factory.cc:276)
----------------------------------------------------------------------
Ran 1 test in 0.135s
FAILED (errors=1)
<end of output>
Test time = 4.86 sec
----------------------------------------------------------
Test Failed.
"test_fused_dot_product_attention_op_static" end time: Nov 05 21:48 中国标准时间
"test_fused_dot_product_attention_op_static" time elapsed: 00:00:04
----------------------------------------------------------
End testing: Nov 05 21:48 中国标准时间
```
- 添加 `-DWITH_CUDNN_FRONTEND=ON` 后,出现以下编译错误:
```shell
[1675/3580] Linking CXX shared library paddle\phi\phi.dll
FAILED: paddle/phi/phi.dll paddle/phi/phi.lib
C:\WINDOWS\system32\cmd.exe /C "cd . && "D:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --msvc-ver=1944 --intdir=paddle\phi\CMakeFiles\phi.dir --rc="D:\Windows Kits\10\bin\10.0.26100.0\x64\rc.exe" --mt="D:\Windows Kits\10\bin\10.0.26100.0\x64\mt.exe" --manifests -- "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\link.exe" /nologo @CMakeFiles\phi.rsp /out:paddle\phi\phi.dll /implib:paddle\phi\phi.lib /pdb:paddle\phi\phi.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4006 /ignore:4221 /NODEFAULTLIB:MSVCRT.LIB /INCREMENTAL:NO && cd ."
LINK: command "D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\phi.rsp /out:paddle\phi\phi.dll /implib:paddle\phi\phi.lib /pdb:paddle\phi\phi.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4006 /ignore:4221 /NODEFAULTLIB:MSVCRT.LIB /INCREMENTAL:NO /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
正在创建库 paddle\phi\phi.lib 和对象 paddle\phi\phi.exp
fused_dconv_drelu_dbn_kernel.cu.obj : error LNK2019: 无法解析的外部符号 "bool paddle_flags::FLAGS_cudnn_deterministic" (?FLAGS_cudnn_deterministic@paddle_flags@@3_NA),函数 "void __cdecl phi::fusion::FusedDconvDreluDbnKernel<struct phi::dtype::float16,class phi::GPUContext>(class phi::GPUContext const &,class phi::DenseTensor const &,class phi::DenseTensor const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class phi::DenseTensor const &,class phi::DenseTensor const &,class phi::DenseTensor const &,class phi::DenseTensor const &,class phi::DenseTensor const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class paddle::optional<class phi::DenseTensor> const &,class std::vector<int,class std::allocator<int> > const &,class std::vector<int,class std::allocator<int> > const &,class std::vector<int,class std::allocator<int> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,bool,bool,bool,bool,class phi::DenseTensor *,class phi::DenseTensor *,class phi::DenseTensor *,class phi::DenseTensor *,class phi::DenseTensor *,class phi::DenseTensor *,class phi::DenseTensor *)" (??$FusedDconvDreluDbnKernel@Ufloat16@dtype@phi@@VGPUContext@3@@Fusion@phi@@YAXAEBVGPUContext@1@AEBVDenseTensor@1@1AEBV?$optional@VDenseTensor@phi@@@paddle@@22221111122222AEBV?$vector@HV?$allocator@H@std@@@std@@33AEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@7@H4_N555PEAV31@666666@Z) 中引用了该符号
fused_dot_product_attention_op.cu.obj : error LNK2001: 无法解析的外部符号 "bool paddle_flags::FLAGS_cudnn_deterministic" (?FLAGS_cudnn_deterministic@paddle_flags@@3_NA)
fused_scale_bias_add_relu_kernel.cu.obj : error LNK2001: 无法解析的外部符号 "bool paddle_flags::FLAGS_cudnn_deterministic" (?FLAGS_cudnn_deterministic@paddle_flags@@3_NA)
fused_scale_bias_relu_conv_bn_kernel.cu.obj : error LNK2001: 无法解析的外部符号 "bool paddle_flags::FLAGS_cudnn_deterministic" (?FLAGS_cudnn_deterministic@paddle_flags@@3_NA)
paddle\phi\phi.dll : fatal error LNK1120: 1 个无法解析的外部命令
[1682/3580] Building CXX object paddle\fluid\framework\ir\...s.dir\conv2d_trans_filter_dilations_nxn_to_1x1_pass.cc.obj
ninja: build stopped: subcommand failed.
```
在以下四个GPU融合算子内核文件中:
- fused_dconv_drelu_dbn_kernel.cu
- fused_dot_product_attention_op.cu
- fused_scale_bias_add_relu_kernel.cu
- fused_scale_bias_relu_conv_bn_kernel.cu
将 `PHI_DECLARE_bool(cudnn_deterministic)` 修改为 `COMMON_DECLARE_bool(cudnn_deterministic)`, 应当是上次进行大规模重构过程中遗漏的修改。
编译成功后运行测试用例,报错如下:
```shell
Start testing: Nov 13 18:02 中国标准时间
----------------------------------------------------------
1491/2280 Testing: test_fused_dot_product_attention_op_static
1491/2280 Test: test_fused_dot_product_attention_op_static
Command: "D:/Program Files/CMake/bin/cmake.exe" "-E" "env" "PYTHONPATH=D:/Lenovo/Paddle/build/python" "D:/Users/Lenovo/AppData/Local/Programs/Python/Python310/python.exe" "D:/Lenovo/Paddle/tools/test_runner.py" "test_fused_dot_product_attention_op_static"
Directory: D:/Lenovo/Paddle/build/test/legacy_test
"test_fused_dot_product_attention_op_static" start time: Nov 13 18:02 中国标准时间
Output:
----------------------------------------------------------
WARNING: Logging before InitGoogleLogging() is written to STDERR
W1113 18:02:59.023836 18612 gpu_resources.cc:116] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 13.0, Runtime API Version: 13.0
test_fused_dot_product_attention_op_static failed
E
======================================================================
ERROR: test_static_op (test_fused_dot_product_attention_op_static.TestFusedDotProductAttentionStatic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:\Lenovo\Paddle\build\test\legacy_test\test_fused_dot_product_attention_op_static.py", line 106, in test_static_op
outs = fused_dot_product_attention(q, k, v, mask)
File "D:\Lenovo\Paddle\build\python\paddle\incubate\nn\functional\fused_dot_product_attention.py", line 202, in fused_dot_product_attention
out, _, _ = _C_ops.fused_dot_product_attention(
ValueError: (InvalidArgument) fused_dot_product_attention(): argument 'q' (position 0) must be Tensor, but got paddle.base.libpaddle.pir.Value (at D:\Lenovo\Paddle\paddle\fluid\pybind\eager_utils.cc:1531)
----------------------------------------------------------------------
Ran 1 test in 0.787s
FAILED (errors=1)
<end of output>
Test time = 5.86 sec
----------------------------------------------------------
Test Failed.
"test_fused_dot_product_attention_op_static" end time: Nov 13 18:03 中国标准时间
"test_fused_dot_product_attention_op_static" time elapsed: 00:00:05
----------------------------------------------------------
End testing: Nov 13 18:03 中国标准时间
```
- 添加了 `OldIrGuard` 上下文管理器来禁用PIR(Program Intermediate Representation)模式
- 修改了静态图测试的结构,使用独立的 `main_program` 和 `startup_program`
- 明确调用 `exe.run(startup_program)` 进行初始化
**作用:**
- **兼容新旧IR系统**: 确保测试在传统静态图模式下运行,而不是新的PIR模式
- **修复测试问题**: 提高测试的稳定性和正确性1 parent 49cb7d9 commit 3edeb00
File tree
6 files changed
+62
-51
lines changed- paddle/phi/kernels/fusion/gpu
- test/legacy_test
6 files changed
+62
-51
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
| |||
Lines changed: 58 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
| 115 | + | |
109 | 116 | | |
| 117 | + | |
110 | 118 | | |
111 | 119 | | |
112 | 120 | | |
| |||
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
151 | 163 | | |
152 | 164 | | |
153 | 165 | | |
| |||
0 commit comments