Skip to content

perf(sm100): small-M single-wave 1D1D GEMM heuristic - #175

Merged
zcnrex merged 1 commit into
devfrom
chunan/sm100-1d1d-small-m-heuristic
Dec 1, 2026
Merged

zcnrex merged 1 commit into
devfrom
chunan/sm100-1d1d-small-m-heuristic

Conversation

@zcnrex

@zcnrex zcnrex commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Split out from #165 (csrc/jit_kernels/heuristics/config.hpp, csrc/jit_kernels/heuristics/sm100.hpp):

  • Account for cluster_m B-multicast (ceil_div(num_m_blocks, cluster_m)) when computing effective B weight reads (num_effective_m_blocks) for single-wave small-M (num_waves == 1, 64 <= get_expected_m() <= 256, get_expected_n() >= 4096) Normal Kernel1D1D GEMMs.
  • Prioritize smaller num_effective_m_blocks and then higher last_wave_util before cluster-size tie-breaking when active.
  • Keep tiny-M (M <= 32) and small-N (N <= 2048) on dev's swap_ab=1 16x128 c=1x2 layout to avoid 1-warp epilogue (STORE_BLOCK_M=32) and 8× UTCCP SF_B overfetch (block_n=16) regressions.
  • Only compute and print num_effective_m_blocks in LayoutInfo::operator<< when active (> 0), keeping SM90/SM120/large-M/multi-wave DG_PRINT_CONFIGS output unchanged.

Verification & Performance

  • SM103 (NVIDIA B300 SXM6 AC, 148 SMs, CUDA 13.0, cold L2 via bench_kineto 256 MB flush) — rebased on dev, tested 82 cases across FP8 (1×128/128×128), MXFP4 (32×32), and FP8×FP4 (128×32) for M ∈ {8, 16, 32, 64, 128, 192, 256, 512}, N ∈ {1024, 2048, 4096, 5120, 7168, 12288}, K ∈ {4096, 7168, 16384}:
    • All accuracy checks pass (calc_diff within dtype tolerances).
    • 1.04× – 1.14× speedup on M=64, 128, N >= 4096 (e.g., mxfp4 M=128 N=12288 K=4096: 9.39 → 8.25 us (1.14×); fp8 M=128 N=12288 K=4096: 13.66 → 12.42 us (1.10×); fp8 M=64 N=4096 K=16384: 19.74 → 17.85 us (1.11×); mxfp4 M=128 N=7168 K=4096: 1.05×).
    • Eliminated all M <= 32 (0.84× → 1.00×) and N <= 2048 (0.94×–0.96× → 1.00×) regressions.

Account for cluster_m B-multicast (ceil_div(num_m_blocks, cluster_m)) when scoring single-wave small-M (64 <= expected_m <= 256, expected_n >= 4096) Normal 1D1D GEMMs, prioritizing fewer effective M-blocks and then higher last_wave_util.

Gate num_effective_m_blocks on num_waves == 1 (and expected_m >= 64, expected_n >= 4096) so tiny-M (M <= 32) and small-N (N <= 2048) retain swap_ab=1 16x128 c=1x2 without epilogue/SF_B regressions, and LayoutInfo::operator<< only prints num_effective_m_blocks when the heuristic is active.
@zcnrex
zcnrex force-pushed the chunan/sm100-1d1d-small-m-heuristic branch from 2ce87e2 to 05792b5 Compare December 1, 2026 07:14
@zcnrex
zcnrex merged commit 6a16134 into dev Dec 1, 2026
@zcnrex
zcnrex deleted the chunan/sm100-1d1d-small-m-heuristic branch December 1, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant