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

Codegen integration #3415

Open
wants to merge 76 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
b27ea94
initial push
arai713 Aug 5, 2024
4f0914c
adding my solver
arai713 Aug 5, 2024
21cb293
cleared up compiler issues, waiting on codegen build with CK
arai713 Aug 7, 2024
fa5aab1
cleaned up code
arai713 Aug 12, 2024
183e041
update requirements.txt
arai713 Aug 14, 2024
4eede0f
testing new CK build
arai713 Aug 15, 2024
8e8962a
adding ck_rtc build
arai713 Aug 19, 2024
7137fa2
instances only build
arai713 Aug 22, 2024
3e10af6
updated rtc build
arai713 Aug 26, 2024
4e2d480
updated source file compilation, solver compiling, need to fix invoker
arai713 Aug 26, 2024
463e523
added invoker, solver compiling but gets skipped
arai713 Aug 29, 2024
3d0418a
formatting
arai713 Sep 3, 2024
d60b719
updated codegen build
arai713 Sep 5, 2024
1c2fe72
updating CMakes to include ck_host component from CK
arai713 Sep 6, 2024
5549cfd
removing some includes
arai713 Sep 6, 2024
e5244e1
temporarily adding generated kernel to src/kernel directory for testi…
arai713 Sep 13, 2024
9bf88a0
adding compiler options
arai713 Sep 13, 2024
83d5d68
updating build to include header guards due to hiprtc compilation issues
arai713 Sep 13, 2024
b96442b
updating requirements
arai713 Sep 13, 2024
972c64b
changed CK hash
arai713 Sep 13, 2024
68a75c6
update compiler args and another update for requirements.txt
arai713 Sep 16, 2024
ce43539
changed some files in CK
arai713 Sep 19, 2024
d4998f4
updated utility files in CK for standard header inclusion issue with …
arai713 Sep 24, 2024
9f3e845
some more header guards
arai713 Sep 25, 2024
98d36a8
resolved some conflicts in CK utility files
arai713 Sep 26, 2024
5c67169
resolved error in data_type file in CK
arai713 Sep 27, 2024
f86c624
resolved errors in a few CK utility files
arai713 Sep 30, 2024
2bf2c4c
added header guards/replicated functionality in CK device files
arai713 Oct 1, 2024
35f0c39
resolved standard header errors in gridwise gemm files and device_gro…
arai713 Oct 2, 2024
4263020
resolved error with CK's numerics file
arai713 Oct 2, 2024
b056269
resolved errors in CK's gridwise files
arai713 Oct 8, 2024
53eed4a
replaces standard header functionlity in threadwise files and header …
arai713 Oct 9, 2024
30b16f7
temp fix for namespace error
arai713 Oct 11, 2024
550eaa2
replaced standard header usage in elementwise files and codegen devic…
arai713 Oct 14, 2024
746f0a8
fixing merge conflicts after merge with develop
arai713 Oct 15, 2024
b81029e
added compiler argument to build codegen
arai713 Oct 15, 2024
a01c0b3
merged my CK codegen branch with develop
arai713 Oct 15, 2024
18294af
updating codegen compiler argument to ON
arai713 Oct 16, 2024
ee99eb1
temporarily removed command line compiler argument for codegen
arai713 Oct 16, 2024
b062ec2
temporarily removing codegen compiler flag in CK for testing
arai713 Oct 16, 2024
c4a1ea6
changed CK commit hash in Dockerfile
arai713 Oct 17, 2024
9d9483c
resolved error in solver files from merge with develop
arai713 Oct 18, 2024
80a87f4
added codegen compiler flag in CK again, set default to ON
arai713 Oct 18, 2024
0a712a1
resolved enable_if_t standard header usage error, added codegen compi…
arai713 Oct 18, 2024
28a0a10
added codegen compiler flag to Dockerfile
arai713 Oct 18, 2024
8b793bc
fixed codegen compiler flag issue
arai713 Oct 18, 2024
2b1191f
renamed codegen solver
arai713 Oct 28, 2024
6ab9d72
added in gtest for codegen
arai713 Oct 28, 2024
3d51f2c
solver using AddKernels now, still have an issue with problem desc/cm…
arai713 Nov 14, 2024
6481117
updting CK commit hash to get new changes
arai713 Nov 14, 2024
a2c7ce5
fixing build command for codegen
arai713 Nov 14, 2024
2df0c6c
updated CK commit hash
arai713 Nov 27, 2024
c8340fb
temporariy removing codegen from CMake
arai713 Nov 27, 2024
5f90f89
updated Dockerfile
arai713 Nov 27, 2024
3b05faa
fixed error in the Dockerfile
arai713 Nov 28, 2024
f0641f1
removed the hardcoded generated file I added in kernels directory for…
arai713 Nov 28, 2024
a96e0d9
removed version using KernelInfo for compilation, switched to and fin…
arai713 Nov 28, 2024
7492445
Fixed gtest. debugged error with mapping CK problem description to MI…
arai713 Nov 28, 2024
19614e5
resolving merge conflicts
arai713 Nov 28, 2024
0c7fb9c
added standalone codegen build into Dockerfilew
arai713 Nov 28, 2024
e5547b7
updated codegen build in Dockerfile
arai713 Nov 29, 2024
6d1a610
resolved stdexcept include errors: updated CK commit hash
arai713 Nov 29, 2024
df67fda
finished debugging integration of standalone codegen build - working now
arai713 Dec 1, 2024
36ecea9
cleaned up solver: removed commented code and debug prints
arai713 Dec 1, 2024
6014b9a
Merge branch 'develop' into codegen
arai713 Dec 2, 2024
fe1be1b
resolved comments from reviews
arai713 Dec 2, 2024
802140b
fixed errors in gtest file with extra variable
arai713 Dec 2, 2024
703065a
fixed naming issue in gtest
arai713 Dec 2, 2024
19f37d0
formatting fix
arai713 Dec 2, 2024
b971566
Merge branch 'develop' into codegen
arai713 Dec 4, 2024
9363043
Merge branch 'develop' into codegen
arai713 Dec 5, 2024
5ecbe39
removed some unneeded code
arai713 Jan 7, 2025
de10103
updating CK commit hash
arai713 Jan 7, 2025
894cb6c
Merge branch 'develop' into codegen
arai713 Jan 7, 2025
61c44f9
updating to latest CK commit
arai713 Jan 8, 2025
0668cc4
Merge branch 'codegen' of github.com:ROCm/MIOpen into codegen
arai713 Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ if(NOT WIN32 AND NOT MIOPEN_WORKAROUND_USE_BOOST_FILESYSTEM)
check_cxx_linker_flag(-lstdc++fs HAS_LIB_STD_FILESYSTEM)
endif()

list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}/llvm ${CMAKE_INSTALL_PREFIX}/hip /opt/rocm /opt/rocm/llvm /opt/rocm/hip)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}/llvm ${CMAKE_INSTALL_PREFIX}/hip /opt/rocm /opt/rocm/llvm /opt/rocm/hip /usr/local/lib)

option(ENABLE_HIP_WORKAROUNDS Off)
set(MIOPEN_INSTALL_CXX_HEADERS Off CACHE BOOL "Install MIOpen's C++ header interface")
Expand Down Expand Up @@ -328,6 +328,8 @@ add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:HIP_COMPILER_FLAGS=${HIP_COMPI
# HIP
if( MIOPEN_BACKEND STREQUAL "HIP" OR MIOPEN_BACKEND STREQUAL "HIPOC" OR MIOPEN_BACKEND STREQUAL "HIPNOGPU")
if(MIOPEN_USE_COMPOSABLEKERNEL)
include(/usr/local/lib/cmake/composable_kernel_host/ck_host_targets.cmake)
find_package(ck_host)
find_package(composable_kernel 1.0.0 COMPONENTS device_other_operations device_gemm_operations device_conv_operations device_reduction_operations device_mha_operations)
endif()
if( MIOPEN_BACKEND STREQUAL "HIPNOGPU")
Expand Down
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ DEBIAN_FRONTEND=noninteractive apt-get purge -y --allow-unauthenticated \
miopen-hip

# TODO: it should be able to automatically get commit hash from requirements.txt
ARG CK_COMMIT=fb948120d2d674607e70d0e7587dcb249c0e74c7
#TODO: swap my branch CK commit out with the proper commit once my branch in CK is merged
ARG CK_COMMIT=3b9a77df7e526d2fa30534e64da3fa779c3e7d9b
RUN wget -O ck.tar.gz https://www.github.com/ROCm/composable_kernel/archive/${CK_COMMIT}.tar.gz && \
tar zxvf ck.tar.gz &&\
cd composable_kernel-${CK_COMMIT} && \
Expand All @@ -125,8 +126,13 @@ RUN wget -O ck.tar.gz https://www.github.com/ROCm/composable_kernel/archive/${CK
-D CMAKE_BUILD_TYPE=Release \
-D GPU_ARCHS="gfx908;gfx90a;gfx942;gfx1100" \
-D CMAKE_CXX_FLAGS=" -O3 " .. && \
make -j $(nproc) install

make -j $(nproc) install && \
rm -rf CMakeCache.txt &&\
CXX=/opt/rocm/llvm/bin/clang++ cmake ../codegen \
-D CMAKE_CXX_COMPILER_LAUNCHER="${COMPILER_LAUNCHER}" \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS=" -O3 " && \
make -j $(nproc) install
# Composable Kernel installed separated from rbuild to take in values from GPU_ARCHS
# this can minimize build time
RUN sed -i '/composable_kernel/d' /requirements.txt
Expand All @@ -150,4 +156,4 @@ RUN pip3 install --upgrade cmake==3.27.5
# groupadd can add one group a time
RUN groupadd -f render
RUN groupadd -f video
RUN usermod -a -G render,video root
RUN usermod -a -G render,video root
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ nlohmann/json@v3.11.2 -DJSON_MultipleHeaders=ON -DJSON_BuildTests=Off
ROCm/FunctionalPlus@v0.2.18-p0
ROCm/eigen@3.4.0
ROCm/frugally-deep@9683d557eb672ee2304f80f6682c51242d748a50
ROCm/composable_kernel@fb948120d2d674607e70d0e7587dcb249c0e74c7 -DCMAKE_BUILD_TYPE=Release
ROCm/composable_kernel@3b9a77df7e526d2fa30534e64da3fa779c3e7d9b -DCMAKE_BUILD_TYPE=Release
google/googletest@v1.14.0
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ set( MIOpen_Source
solver/softmarginloss/forward_softmarginloss.cpp
solver/softmax/attn_softmax.cpp
solver/softmax/softmax.cpp
solver/codegen_conv_hip_implicit_gemm_2d_grouped_fwd_xdlops.cpp
subbuffers.cpp
t5layernorm_api.cpp
target_properties.cpp
Expand Down Expand Up @@ -844,10 +845,11 @@ endfunction()

target_include_directories(MIOpen PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/include>
/usr/local/lib/composable_kernel_host/include
)

if(MIOPEN_USE_COMPOSABLEKERNEL)
set(MIOPEN_CK_LINK_FLAGS composable_kernel::device_other_operations composable_kernel::device_gemm_operations composable_kernel::device_conv_operations composable_kernel::device_reduction_operations composable_kernel::device_mha_operations hip::host)
set(MIOPEN_CK_LINK_FLAGS composable_kernel::device_other_operations composable_kernel::device_gemm_operations composable_kernel::device_conv_operations composable_kernel::device_reduction_operations composable_kernel::device_mha_operations composable_kernel::ck_host hip::host)
endif()

if(WIN32)
Expand Down
20 changes: 20 additions & 0 deletions src/include/miopen/conv/solvers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4494,6 +4494,26 @@ struct ConvHipImplicitGemmGroupFwdXdlops final
bool CheckCKApplicability(const miopen::conv::ProblemDescription&) const;
};

struct ConvHipImplicitGemmGroupFwdXdlopsCodegen final : ConvSolver
{
// TODO: update this fcn
const std::string& SolverDbId() const override
{
return GetSolverDbId<ConvHipImplicitGemmGroupFwdXdlopsCodegen>();
}

MIOPEN_INTERNALS_EXPORT size_t GetWorkspaceSize(
const ExecutionContext&, const miopen::conv::ProblemDescription&) const override;

bool MayNeedWorkspace() const override { return true; }

MIOPEN_INTERNALS_EXPORT bool
IsApplicable(const ExecutionContext&, const miopen::conv::ProblemDescription&) const override;

MIOPEN_INTERNALS_EXPORT ConvSolution
GetSolution(const ExecutionContext&, const miopen::conv::ProblemDescription&) const override;
};

struct PerformanceConfigHipImplicitGemm3DGroupFwdXdlops
: PerfConfigBaseCK<PerformanceConfigHipImplicitGemm3DGroupFwdXdlops>
{
Expand Down
1 change: 1 addition & 0 deletions src/mlo_dir_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static auto GetImplicitGemmSolvers()
miopen::solver::conv::ConvHipImplicitGemmGroupBwdXdlops,
miopen::solver::conv::ConvHipImplicitGemm3DGroupFwdXdlops,
miopen::solver::conv::ConvHipImplicitGemm3DGroupBwdXdlops,
miopen::solver::conv::ConvHipImplicitGemmGroupFwdXdlopsCodegen,
#endif // MIOPEN_BACKEND_HIP && MIOPEN_USE_COMPOSABLEKERNEL
miopen::solver::conv::ConvAsmImplicitGemmGTCDynamicFwdDlopsNCHWC>{};
}
Expand Down
5 changes: 5 additions & 0 deletions src/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,11 @@ inline SolverRegistrar::SolverRegistrar(IdRegistryData& registry)
multimarginloss::MultiMarginLossForward{}.SolverDbId());

Register(registry, ++id, Primitive::Mha, mha::MhaCKFlashAttentionV2Forward{}.SolverDbId());

RegisterWithSolver(registry,
++id,
conv::ConvHipImplicitGemmGroupFwdXdlopsCodegen{},
miopenConvolutionAlgoImplicitGEMM);
// IMPORTANT: New solvers should be added to the end of the function, and don't leave a white
// space between this comment and the newly registered solver(s)!
}
Expand Down
Loading
Loading