Repository navigation
[TRTLLM-17005][refactor] Component-local C++ Tests (Part 10) #22990
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
base: main
Are you sure you want to change the base?
Changes from all commits
6c1cf8e
3ae98ab
dfb911b
7007897
34d8a10
3954cc0
8b24c32
d164dfe
ddb977f
4e6a58f
e91a394
9b4ca73
042416d
8264a71
40ed923
a45fda4
9eead6c
96abcc4
90946c3
205db74
17d3d69
f8b00ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Funatiq marked this conversation as resolved.
Resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,10 +38,6 @@ add_subdirectory(csa2SparseContext) | |
| add_subdirectory(csa2SparseDecode) | ||
| add_subdirectory(fusedSampling) | ||
|
|
||
| file(GLOB_RECURSE SRC_CPP *.cpp) | ||
| file(GLOB_RECURSE SRC_CU *.cu) | ||
|
|
||
| list(REMOVE_ITEM SRC_CU "${CMAKE_CURRENT_SOURCE_DIR}/kvCachePartialCopy.cu") | ||
| add_library(tllm_kernel_kv_cache_copy STATIC kvCachePartialCopy.cu) | ||
| add_library(tllm::kernel_kv_cache_copy ALIAS tllm_kernel_kv_cache_copy) | ||
| target_link_libraries(tllm_kernel_kv_cache_copy PUBLIC tllm::common_cuda) | ||
|
|
@@ -51,56 +47,6 @@ set_target_properties( | |
| CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
| add_cuda_architectures(tllm_kernel_kv_cache_copy 89) | ||
|
|
||
| # Exclude files in the cutlass_kernels, decoderMaskedMultiheadAttention and | ||
| # selectiveScan trtllmGenKernels folder | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "cutlass_kernels/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "cutlass_kernels/.*") | ||
| # Everything under moe/ is that directory's own business: its backend | ||
| # sub-directories build their own targets, and moe/CMakeLists.txt hands the rest | ||
| # back as MOE_KERNELS_SRC, which joins kernels_src below. Anchored on | ||
| # "/kernels/" because the glob above yields absolute paths. | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "/kernels/moe/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "/kernels/moe/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "flashMLA/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "flashMLA/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "contextFusedMultiHeadAttention/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "contextFusedMultiHeadAttention/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "decoderMaskedMultiheadAttention/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "decoderMaskedMultiheadAttention/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "trtllmGenKernels/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "trtllmGenKernels/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "selectiveScan/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "selectiveScan/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "userbuffers/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "userbuffers/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "fusedLayernormKernels/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "fusedGatedRMSNormQuant/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "mamba2MTPSSMCache/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "kdaDecode/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "kdaDecode/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "kimiK3AttnRes/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "kimiK3AttnRes/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "mhcKernels/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "mhcKernels/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "compressorKernels/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "compressorKernels/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "csa2SparseContext/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "csa2SparseContext/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "csa2SparseDecode/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "csa2SparseDecode/.*") | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "fusedSampling/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "fusedSampling/.*") | ||
| # Marlin is built as its own architecture-scoped OBJECT library below. | ||
| list(FILTER SRC_CPP EXCLUDE REGEX "marlin/.*") | ||
| list(FILTER SRC_CU EXCLUDE REGEX "marlin/.*") | ||
| # The MiniMax-M3 decode attention kernels are built as their own | ||
| # architecture-scoped OBJECT library below. | ||
| list(FILTER SRC_CU EXCLUDE REGEX | ||
| "minimaxM3/(fusedDecodeAttn|attnMega|attnC1)\\.cu$") | ||
| # The MiniMax-M3 sm_107 decode kernels are built as their own sm_107-only OBJECT | ||
| # library below. | ||
| list(FILTER SRC_CU EXCLUDE REGEX "minimaxM3Sm107(Tp[248])?/.*") | ||
|
|
||
| # Lower CUDA optimization level when FAST_BUILD is enabled to speed up | ||
| # compilation. CMake by default adds -O3 to CMAKE_CUDA_FLAGS_RELEASE. We | ||
| # override it here before creating the target to avoid the "incompatible | ||
|
|
@@ -115,25 +61,26 @@ if(FAST_BUILD) | |
| endif() | ||
|
|
||
| include(kernelComponents.cmake) | ||
| include(residualKernelComponents.cmake) | ||
|
Funatiq marked this conversation as resolved.
Resolved
|
||
| set(TLLM_KERNEL_COMPONENT_TARGETS | ||
| ${TLLM_KERNEL_COMPONENT_TARGETS} | ||
| PARENT_SCOPE) | ||
|
|
||
| # Marlin NVFP4: build Ada/Hopper kernels and the dense W4A16/repack kernels used | ||
| # on SM12x. Unsupported device passes emit empty kernel stubs. | ||
| file(GLOB_RECURSE MARLIN_SRC "marlin/*.cu" "marlin/*.cpp") | ||
| if(MARLIN_SRC) | ||
| add_library(marlin_src OBJECT ${MARLIN_SRC}) | ||
| set_property(TARGET marlin_src PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
| set_property(TARGET marlin_src PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
| target_include_directories( | ||
| marlin_src | ||
| PRIVATE | ||
| $<TARGET_PROPERTY:${INTERNAL_CUTLASS_KERNELS_TARGET},INTERFACE_INCLUDE_DIRECTORIES> | ||
| ) | ||
| target_link_libraries(marlin_src PRIVATE trtllm_gen_fmha_interface) | ||
| set_cuda_architectures(marlin_src 89 90 120f) | ||
| endif() | ||
| # Marlin builds Ada/Hopper and SM12x kernels; unsupported device passes emit | ||
| # empty stubs. kernels_src packages the objects for legacy aggregate consumers. | ||
| add_library( | ||
| marlin_src OBJECT | ||
| marlin/marlin_nvfp4_dispatch_utils.cpp marlin/marlin_nvfp4_gemm.cu | ||
| marlin/marlin_nvfp4_moe_gemm.cu marlin/marlin_repack.cu) | ||
| set_property(TARGET marlin_src PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
| set_property(TARGET marlin_src PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
| target_include_directories( | ||
| marlin_src | ||
| PRIVATE | ||
| $<TARGET_PROPERTY:${INTERNAL_CUTLASS_KERNELS_TARGET},INTERFACE_INCLUDE_DIRECTORIES> | ||
| ) | ||
| target_link_libraries(marlin_src PRIVATE trtllm_gen_fmha_interface) | ||
| set_cuda_architectures(marlin_src 89 90 120f) | ||
|
|
||
| # MiniMax-M3 decode attention: block-scaled tcgen05 MMAs (.scale_vec::1X) exist | ||
| # on the arch-specific sm_100a / sm_103a targets only, not on the sm_100f family | ||
|
|
@@ -148,11 +95,10 @@ set_cuda_architectures(minimax_m3_attn_src 100 103) | |
|
|
||
| # MiniMax-M3 sm_107 decode kernels (minimaxM3Sm107Tp{2,4,8}/): written for | ||
| # sm_107 only (PDL griddepcontrol, sm_10x-only PTX), so they are compiled for | ||
| # the sm_10x entries of this build's architectures only (the same targets, e.g. | ||
| # the sm_100f family, that kernels_src compiles its sm_10x code for), not for | ||
| # the older ones. A build without an sm_10x architecture compiles them for | ||
| # sm_107a: their torch ops link against the host launchers, and only the sm_107 | ||
| # targets launch them. | ||
| # the sm_10x entries of this build's architectures only, including the sm_100f | ||
| # family, not for the older ones. A build without an sm_10x architecture | ||
| # compiles them for sm_107a: their torch ops link against the host launchers, | ||
| # and only the sm_107 targets launch them. | ||
| file(GLOB MINIMAX_M3_SM107_SRC minimaxM3Sm107/*.cu minimaxM3Sm107Tp2/*.cu | ||
| minimaxM3Sm107Tp4/*.cu minimaxM3Sm107Tp8/*.cu) | ||
| add_library(minimax_m3_sm107_src OBJECT ${MINIMAX_M3_SM107_SRC}) | ||
|
|
@@ -173,17 +119,62 @@ endif() | |
| set_property(TARGET minimax_m3_sm107_src PROPERTY CUDA_ARCHITECTURES | ||
| ${MINIMAX_M3_SM107_ARCHS}) | ||
|
|
||
| # Compatibility archive: specialized object libraries have one compilation | ||
| # owner, and ordinary kernel families are selected through component libraries. | ||
| add_library( | ||
| kernels_src STATIC | ||
| ${SRC_CPP} ${SRC_CU} ${MOE_KERNELS_SRC} | ||
| $<$<TARGET_EXISTS:marlin_src>:$<TARGET_OBJECTS:marlin_src>> | ||
| $<TARGET_OBJECTS:minimax_m3_attn_src> $<TARGET_OBJECTS:minimax_m3_sm107_src>) | ||
| $<TARGET_OBJECTS:minimax_m3_attn_src> | ||
| $<TARGET_OBJECTS:minimax_m3_sm107_src> | ||
| $<TARGET_OBJECTS:moe_dynamic_eplb_src> | ||
| $<TARGET_OBJECTS:marlin_src> | ||
| $<TARGET_OBJECTS:causalConv1d_src> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These four OBJECT targets were built on main but never linked: the shipped causalConv1d/groupRmsNorm/dsv3/llama4 objects came from the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed and fixed in f8b00eac92f. To be precise, the register caps did affect the standalone OBJECT targets, but those objects were not linked into the shipped libraries before this refactor. The shipped kernel copies instead came from the recursive The fix removes the causalConv1d/group RMSNorm caps and adds conditional SM89 compilation to both owners, retaining single compilation ownership and object packaging. The generated compile commands differ only by the removed cap and added SM89; The historical linkage was confirmed from CMake declarations. I have not rebuilt historical main, compared SASS byte-for-byte, or run GPU performance tests. |
||
| $<TARGET_OBJECTS:groupRmsNormKernels_src> | ||
| $<TARGET_OBJECTS:dsv3_min_latency_kernels> | ||
| $<TARGET_OBJECTS:llama4_min_latency_kernels>) | ||
| set_property(TARGET kernels_src PROPERTY POSITION_INDEPENDENT_CODE ON) | ||
| set_property(TARGET kernels_src PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON) | ||
| target_include_directories( | ||
| kernels_src | ||
| PUBLIC | ||
| $<TARGET_PROPERTY:${INTERNAL_CUTLASS_KERNELS_TARGET},INTERFACE_INCLUDE_DIRECTORIES> | ||
| ) | ||
| target_link_libraries(kernels_src PUBLIC trtllm_gen_fmha_interface) | ||
| tllm_link_kernel_aggregate(kernels_src) | ||
| # Specialized backend objects also require SM89 in the aggregate device link. | ||
| add_cuda_architectures(kernels_src 89) | ||
|
|
||
| include(kernelSourceOwnership.cmake) | ||
| get_property( | ||
| kernel_targets | ||
| DIRECTORY | ||
| PROPERTY BUILDSYSTEM_TARGETS) | ||
| set(kernel_ownership_options) | ||
| if(NOT ENABLE_MULTI_DEVICE) | ||
| list(APPEND kernel_ownership_options DISABLED_SOURCES | ||
| customAllReduceKernels.cu) | ||
| endif() | ||
| tllm_check_kernel_source_ownership( | ||
| ${kernel_ownership_options} | ||
| TARGETS | ||
| ${kernel_targets} | ||
| DELEGATED_DIRECTORIES | ||
| cutlass_kernels | ||
| contextFusedMultiHeadAttention | ||
| decoderMaskedMultiheadAttention | ||
| flashMLA | ||
| trtllmGenKernels | ||
| selectiveScan | ||
| userbuffers | ||
| fusedLayernormKernels | ||
| fusedGatedRMSNormQuant | ||
| mamba2MTPSSMCache | ||
| kdaDecode | ||
| kimiK3AttnRes | ||
| mhcKernels | ||
| compressorKernels | ||
| fusedSampling | ||
| csa2SparseContext | ||
| csa2SparseDecode | ||
| moe/loadBalance/dynamicEplb | ||
| moe/cutlass=cutlass_kernels | ||
| moe/trtllmGen | ||
| moe/cuteDsl) | ||
Uh oh!
There was an error while loading. Please reload this page.