Speed up CUDA build by splitting SM80 MoE GEMM generated files#29614
Merged
Conversation
kunal-vaishnavi
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The SM80 fused MoE GEMM launchers were generated as two monolithic translation units —
fused_moe_gemm_sm80_bf16.generated.cuandfused_moe_gemm_sm80_f16.generated.cu— each packing 30 CUTLASS kernel instantiations (5 tile shapes × 3 stages × 2 epilogues) into a single.cufile. nvcc's--threadsflag only parallelizes across GPU architectures (80;90) within a file; it does not parallelize template instantiations inside one translation unit. As a result each of these two objects was a long, serial compile on the build's critical path (each ~5–6 min in a Debug80;90build), and Ninja could only overlap the two of them.This PR updates the kernel generator to split the SM80 instantiations by tile shape, producing 10 smaller files (5 tile shapes × 2 dtypes, 6 kernels each) that Ninja compiles in parallel.
Key Changes
generate_moe_kernels.py: the SM80 loop now groups instantiations by(element_type, tile_shape)and emits one file per group, namedfused_moe_gemm_sm80_{dtype}_m{M}_n{N}_k{K}.generated.cu. Addedglob-based cleanup that removes stale SM80 generated files (the old monolithic per-dtype files and any files from a previous tile configuration) so they are not compiled.cmake already discovers these via
GLOB_RECURSE ... CONFIGURE_DEPENDS, so no cmake changes are needed — the new files are picked up automatically on the next configure.Testing
CMAKE_CUDA_ARCHITECTURES="80;90"build:To regenerate after future tile-shape changes: