Skip to content

Commit d2c56b9

Browse files
jakpiaseclaudeCopilot
authored
[rocm-libraries] ROCm/rocm-libraries#10179 (commit 6c627c2)
feat(ck) [CK] Wavelet gemm pipeline for conv fwd ## Motivation In the current CShuffleV3 conv fwd kernel, the in-kernel conv-to-GEMM transform generates significant INT32 VALU pressure per MFMA instruction. On VALU-heavy shapes (e.g., G=1, 3×3, C=256), these index computation ops compete with MFMA for VALU issue slots, creating a bottleneck that cannot be resolved by pipeline prefetching alone. This PR adds a wave-specialized ("wavelet") convolutions forward kernel that splits workgroup threads into two roles: - **Load waves**: conv-to-GEMM address computation + global memory loads + LDS writes (all VALU/VMEM) - **Math waves**: LDS reads + MFMA + CShuffle epilogue (no index computation) By physically separating the two instruction classes onto different waves, VALU and MFMA execute on different hardware functional units without contention. ## Technical Details **Wave pipeline (modified):** - `gridwise_gemm_waveletmodel.hpp` — load/math wave pipeline structs with `sched_group_barrier` scheduling hints to front-load VMEM reads before address-advance VALU **Two wave ratios:** - **(4,4)**: 256 load + 256 math = 512 threads (8 waves). Best on large shapes. - **(4,2)**: 256 load + 128 math = 384 threads (6 waves). Best on small shapes (fewer sync barriers, denser MFMA per math wave). JIRA ID : ROCM-21620 --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 9ee9de6 commit d2c56b9

15 files changed

Lines changed: 2186 additions & 2 deletions

‎example/09_convnd_fwd/CMakeLists.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ add_example_executable(example_convnd_fwd_xdl_bf8_fp8 convnd_fwd_xdl_bf8_fp8.cpp
1313
add_example_executable(example_convnd_fwd_dl_fp16 convnd_fwd_dl_fp16.cpp)
1414
add_example_executable(example_convnd_fwd_dl_fp32 convnd_fwd_dl_fp32.cpp)
1515
add_example_executable(example_convnd_fwd_dl_int8 convnd_fwd_dl_int8.cpp)
16+
# Wavelet XDL instances use MPerXdl=32/NPerXdl=32 (MFMA), not supported on gfx11/gfx12
17+
list(APPEND gpu_list_wavelet gfx908 gfx90a gfx942 gfx950)
18+
set(target_wavelet 0)
19+
foreach(gpu IN LISTS GPU_TARGETS)
20+
if(gpu IN_LIST gpu_list_wavelet AND target_wavelet EQUAL 0)
21+
add_example_executable(example_convnd_fwd_wavelet_xdl_fp16 convnd_fwd_wavelet_xdl_fp16.cpp)
22+
set(target_wavelet 1)
23+
endif()
24+
endforeach()
1625

1726
# only build fp64 example for the following targets
1827
list(APPEND gpu_list gfx90a gfx942 gfx950)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
2+
// SPDX-License-Identifier: MIT
3+
4+
#include "convnd_fwd_common.hpp"
5+
#include "ck/tensor_operation/gpu/device/impl/device_grouped_conv_fwd_multiple_abd_xdl_waveletmodel_cshuffle_v3.hpp"
6+
#include "ck/library/utility/convolution_host_tensor_descriptor_helper.hpp"
7+
8+
using InDataType = ck::half_t;
9+
using WeiDataType = ck::half_t;
10+
using AccDataType = float;
11+
using CShuffleDataType = ck::half_t;
12+
using OutDataType = ck::half_t;
13+
14+
template <ck::index_t... Is>
15+
using S = ck::Sequence<Is...>;
16+
17+
using InElementOp = ck::tensor_operation::element_wise::PassThrough;
18+
using WeiElementOp = ck::tensor_operation::element_wise::PassThrough;
19+
using OutElementOp = ck::tensor_operation::element_wise::PassThrough;
20+
21+
static constexpr auto ConvSpec =
22+
ck::tensor_operation::device::ConvolutionForwardSpecialization::Default;
23+
24+
template <ck::index_t NDimSpatial, typename InLayout, typename WeiLayout, typename OutLayout>
25+
using DeviceGroupedConvNDFwdInstance =
26+
ck::tensor_operation::device::DeviceGroupedConvFwdMultipleABD_WaveletModel_Xdl_CShuffle_V3<
27+
NDimSpatial,
28+
InLayout,
29+
WeiLayout,
30+
ck::Tuple<>,
31+
OutLayout,
32+
InDataType,
33+
WeiDataType,
34+
AccDataType,
35+
CShuffleDataType,
36+
ck::Tuple<>,
37+
OutDataType,
38+
InElementOp,
39+
WeiElementOp,
40+
OutElementOp,
41+
ConvSpec, // ConvForwardSpecialization
42+
256, // TileLoadThreadGroupSize
43+
256, // TileMathThreadGroupSize
44+
128, // MPerBlock
45+
64, // NPerBlock
46+
64, // KPerBlock
47+
8, // K1
48+
32, // MPerXdl
49+
32, // NPerXdl
50+
1, // MXdlPerWave
51+
2, // NXdlPerWave
52+
S<8, 32, 1>, // ABlockTransferThreadClusterLengths_AK0_M_AK1
53+
S<1, 0, 2>, // ABlockTransferThreadClusterArrangeOrder
54+
S<1, 0, 2>, // ABlockTransferSrcAccessOrder
55+
2, // ABlockTransferSrcVectorDim
56+
8, // ABlockTransferSrcScalarPerVector
57+
8, // ABlockTransferDstScalarPerVector_AK1
58+
1, // ABlockLdsExtraM
59+
S<8, 32, 1>, // BBlockTransferThreadClusterLengths_BK0_N_BK1
60+
S<1, 0, 2>, // BBlockTransferThreadClusterArrangeOrder
61+
S<1, 0, 2>, // BBlockTransferSrcAccessOrder
62+
2, // BBlockTransferSrcVectorDim
63+
8, // BBlockTransferSrcScalarPerVector
64+
8, // BBlockTransferDstScalarPerVector_BK1
65+
1, // BBlockLdsExtraN
66+
1,
67+
1,
68+
S<1, 32, 1, 8>,
69+
4>;
70+
71+
#include "run_convnd_fwd_example.inc"
72+
73+
int main(int argc, char* argv[]) { return run_convnd_fwd_example(argc, argv) ? 0 : 1; }

‎include/ck/tensor_operation/gpu/device/impl/device_grouped_conv_fwd_multiple_abd_xdl_cshuffle_v3.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,12 +1478,12 @@ struct DeviceGroupedConvFwdMultipleABD_Xdl_CShuffle_V3
14781478
// with Conv Multiple D instances
14791479
if constexpr(isMultiABD)
14801480
{
1481-
return false;
14821481
if(ck::EnvIsEnabled(CK_ENV(CK_LOGGING)))
14831482
{
14841483
std::cout << "The MultiABD is not supported!" << " In " << __FILE__ << ":"
14851484
<< __LINE__ << ", in function: " << __func__ << std::endl;
14861485
}
1486+
return false;
14871487
}
14881488

14891489
// check device

0 commit comments

Comments
 (0)