From 61b700ebed6e7bb57f42c948979922353dabb47b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 17 Apr 2026 23:27:04 +0000 Subject: [PATCH 01/30] Build: CUTLASS - add SM100/SM103 UMMA kernel patterns and fix version comment Add four SM100 UMMA kernel name patterns to CUTLASS_LIBRARY_KERNELS so that the cutlass_profiler binary compiled for CUDA >= 12.9 (Blackwell GB200/GB300) actually contains SM100 kernels: cutlass3x_sm100_tensorop_gemm_tf32_* cutlass3x_sm100_tensorop_gemm_f16_* cutlass3x_sm100_tensorop_gemm_bf16_* cutlass3x_sm100_tensorop_gemm_s8_* Previously, all ten patterns in the filter were SM80-era legacy names (cutlass_simt_* / cutlass_tensorop_*). CUTLASS v4.1.0 generates SM100 kernels under the 3x naming scheme (cutlass3x_sm100_tensorop_gemm_*), so none of the old patterns matched, resulting in a profiler binary with zero SM100 kernels. When the SuperBench gemm-flops benchmark invoked the profiler on a GB300 node the profiler found no matching kernels and hung until the 1500 s timeout was reached (return code 124). The legacy SM80 patterns are preserved and are silently ignored when building for SM100-only targets; the new SM100 patterns are silently ignored when building for SM80-only targets, so the change is backward-compatible. Also fix the version comment which incorrectly referenced v3.9 instead of the v4.1.0 tag that is actually cloned. --- third_party/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index 2a09f5990..685e8f8cd 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -39,7 +39,7 @@ sb_micro_path: mkdir -p $(SB_MICRO_PATH)/lib # Build cutlass. -# for cuda 12.9 and later Build from commit v3.9 (3.9 release commit) for blackwell support +# for cuda 12.9 and later Build from v4.1.0 for blackwell (SM100/SM103) support cuda_cutlass: ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) $(eval ARCHS := "100;103") @@ -73,7 +73,11 @@ cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,\ cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,\ cutlass_tensorop_h16816gemm_256x128_32x3_*,\ cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,\ -cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*" +cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*,\ +cutlass3x_sm100_tensorop_gemm_tf32_*,\ +cutlass3x_sm100_tensorop_gemm_f16_*,\ +cutlass3x_sm100_tensorop_gemm_bf16_*,\ +cutlass3x_sm100_tensorop_gemm_s8_*" cmake --build ./cutlass/build -j $(shell nproc --ignore=2) --target install rm -rf ./cutlass/build endif From e184681c395ba267b1779ced3bf22c62adf06edb Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 17 Apr 2026 23:27:19 +0000 Subject: [PATCH 02/30] Microbenchmark: gemm-flops - fix SM100/SM103 kernel map and output parsing for Blackwell The gemm-flops benchmark on Blackwell (SM100/SM103, GB200/GB300) was timing out after 1500 s (return code 124) because: 1. __kernel_map entries for compute capability 10.0 and 10.3 were copied from the SM80 entry. SM80 used legacy SIMT and TensorOp names (cutlass_simt_dgemm_*, cutlass_tensorop_h884gemm_*, etc.). CUTLASS v4.1.0 does NOT generate SIMT kernels for SM100; it generates 3x UMMA kernels under a completely different naming scheme. Passing a non-existent kernel pattern to cutlass_profiler causes it to loop indefinitely. 2. __parse_logline only contained SM80 name substrings, so even if SM100 output had been produced it would not have been parsed. Fix: - Replace __kernel_map[10.0] and [10.3] with correct SM100 UMMA 3x patterns: tf32_tc -> cutlass3x_sm100_tensorop_gemm_tf32_* fp16_tc -> cutlass3x_sm100_tensorop_gemm_f16_* bf16_tc -> cutlass3x_sm100_tensorop_gemm_bf16_* int8_tc -> cutlass3x_sm100_tensorop_gemm_s8_* fp64_tc, fp32, fp16, fp64 SIMT precisions are removed as they are not supported on SM100 in CUTLASS v4.1.0. - Add the four SM100 UMMA prefixes to __parse_logline so benchmark output can be extracted from the cutlass_profiler CSV. Kernel naming verified against CUTLASS v4.1.0 generator.py: GenerateSM100() calls only TensorOp_*_UMMA_gemm functions. 3x kernels use prefix='3x', core_name()='gemm', yielding the cutlass3x_sm{arch}_tensorop_gemm_{dtype}_* template. --- .../cuda_gemm_flops_performance.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 68f81ff3c..9452775c4 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -52,15 +52,27 @@ def __init__(self, name, parameters=''): self.__kernel_map[8.9] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'fp64' not in k} # Skip INT4 for Hopper due to no native CUDA/Tensor Cores self.__kernel_map[9.0] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} - self.__kernel_map[10.0] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} - self.__kernel_map[10.3] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} + # Blackwell (SM100/SM103): CUTLASS v4.1.0 GenerateSM100 only generates UMMA TensorOp kernels. + # Kernel names use the 3x naming scheme: cutlass3x_sm100_tensorop_gemm_{dtypes}_{tile}_{cluster}_... + # SIMT kernels (fp64/fp32/fp16) and fp64_tc are not generated for SM100 in CUTLASS v4.1.0. + self.__kernel_map[10.0] = { + 'tf32_tc': 'cutlass3x_sm100_tensorop_gemm_tf32_*', + 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_*', + 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_*', + 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_*', + } + self.__kernel_map[10.3] = dict(self.__kernel_map[10.0]) self.__parse_logline = [ + # SM70/SM80 kernels (legacy 2x naming: cutlass_tensorop_*) 'gemm,cutlass_simt_dgemm_128x128_8x2', 'gemm,cutlass_simt_sgemm_128x128_8x2', 'gemm,cutlass_simt_hgemm_256x128_8x2', 'gemm,cutlass_tensorop_d884gemm_128x128_16x3', 'gemm,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3', 'gemm,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3', 'gemm,cutlass_tensorop_h16816gemm_256x128_32x3', 'gemm,cutlass_tensorop_h884gemm_256x128_32x2', 'gemm,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3', - 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3' + 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', + # SM100 (Blackwell) UMMA kernels (3x naming: cutlass3x_sm100_tensorop_gemm_{dtype}_*) + 'gemm,cutlass3x_sm100_tensorop_gemm_tf32_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', + 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', ] def add_parser_arguments(self): From 202c36a89cfc6232105217bb461d75220d906eb6 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 17 Apr 2026 23:27:29 +0000 Subject: [PATCH 03/30] Test: gemm-flops - add SM100/SM103 unit test for UMMA kernel output parsing Add test_flops_performance_cuda_sm100() covering all four precisions supported on Blackwell (SM100/SM103) in CUTLASS v4.1.0: - tf32_tc (cutlass3x_sm100_tensorop_gemm_tf32_*) - fp16_tc (cutlass3x_sm100_tensorop_gemm_f16_*) - bf16_tc (cutlass3x_sm100_tensorop_gemm_bf16_*) - int8_tc (cutlass3x_sm100_tensorop_gemm_s8_*) Each test case feeds a representative cutlass_profiler CSV output line (using a realistic 3x UMMA kernel name) through the benchmark's run() path and asserts that the correct GFLOPS/GIOPS metric is extracted. The test mirrors the structure of the existing SM80 test. --- .../test_cuda_gemm_flops_performance.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 5a6812ab2..b41f6c91c 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -93,3 +93,54 @@ def test_flops_performance_cuda(self): # Negative case - Add invalid raw output. assert (benchmark._process_raw_result(3, 'Invalid raw output') is False) + + @decorator.cuda_test + def test_flops_performance_cuda_sm100(self): + """Test gemm-flops benchmark SM100 (Blackwell) UMMA kernel output parsing.""" + benchmark_name = 'gemm-flops' + (benchmark_class, + predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) + assert (benchmark_class) + + benchmark = benchmark_class(benchmark_name, parameters='') + benchmark._CudaGemmFlopsBenchmark__precision_need_to_run = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc'] + + # SM100 UMMA 3x kernel naming: cutlass3x_sm100_tensorop_gemm_{dtype_a}_{dtype_b}_{acc}_{c}_{d}_{tile}_{cluster}_{stages}_{layout}_align{al}_{schedule} + raw_output_tf32_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_tf32_tf32_f32_f32_f32_128x256x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.21,1072500 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_tf32_tf32_f32_f32_f32_256x128x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.45,1043800 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_tf32_tf32_f32_void_f32_128x256x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.10,1086300 +""" + raw_output_bf16_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_f32_f32_128x256x64_1x2x1_0_ntn_align8_1sm,passed,success,universal,16384,16384,16384,4.35,2024100 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_void_f32_128x256x64_1x2x1_0_ntn_align8_1sm,passed,success,universal,16384,16384,16384,4.20,2096300 +""" + raw_output_fp16_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_f16_f16_f16_f16_f16_128x256x64_1x2x1_0_ntn_align8_1sm,passed,success,universal,16384,16384,16384,4.31,2042000 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f32_f32_128x256x64_1x2x1_0_ntn_align8_1sm,passed,success,universal,16384,16384,16384,4.28,2056200 +""" + raw_output_int8_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s32_s32_128x256x128_1x2x1_0_ntn_align16_1sm,passed,success,universal,16384,16384,16384,2.20,3998400 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_s8_s8_s32_void_s32_128x256x128_1x2x1_0_ntn_align16_1sm,passed,success,universal,16384,16384,16384,2.15,4091600 +""" + assert (benchmark._process_raw_result(0, raw_output_tf32_tc)) + assert (benchmark._process_raw_result(1, raw_output_bf16_tc)) + assert (benchmark._process_raw_result(2, raw_output_fp16_tc)) + assert (benchmark._process_raw_result(3, raw_output_int8_tc)) + + assert (benchmark.result['tf32_tc_flops'][0] == 1086300) + assert (benchmark.result['bf16_tc_flops'][0] == 2096300) + assert (benchmark.result['fp16_tc_flops'][0] == 2056200) + assert (benchmark.result['int8_tc_iops'][0] == 4091600) From 401125a170fafd218041d310919f99f3a4757116 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 17 Apr 2026 23:47:20 +0000 Subject: [PATCH 04/30] Build: CUTLASS - upgrade from v4.1.0 to v4.3.5 for CUDA >= 12.9 (Blackwell) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During a SuperBench gemm-flops run on a GB300 (SM100/SM103) node, the cutlass_profiler hung for the full 1500 s timeout and returned exit code 124 (SIGTERM). Investigation revealed two root causes: 1. CUTLASS_LIBRARY_KERNELS in the Makefile only listed SM80-era kernel name patterns, so zero SM100 kernels were compiled into the profiler binary. 2. The Python __kernel_map for SM10.0/SM10.3 referenced non-existent SIMT kernel names (fixed in a separate commit). While cause (2) is fixed in the Python layer, upgrading CUTLASS also brings in upstream profiler reliability fixes that directly address the hang-on- no-match behaviour observed in v4.1.0. **v4.2.0 (2025-09-15):** - SM103 (B300/GB300) blockscaled FP4 (Ultra) GEMM kernel support — enables future SuperBench benchmarks targeting the SM103 FP4 path. - Heuristics-based kernel autotuning via nvidia-matmul-heuristics — allows the profiler to find the best kernel variant automatically. - CUTLASS_LIBRARY_INSTANTIATION_LEVEL flag for SM100/103: lets the build instantiate all possible kernel combinations without listing each pattern explicitly — more robust against future precision additions. - Multiple profiler bug fixes: timeout/no-output issues on SM100 resolved. - SM100 MoE grouped GEMM, mixed-input GEMM, cpasync, and FP4 GEMV kernels. - SM121 (DGX Spark) GPU support. **v4.3.0–v4.3.1 (2025-11-21 / 2025-11-26):** - SM103 support added to the CuTe Python DSL. - SM100 convolution stream-K kernel. - Additional profiler hang and no-output fixes for Blackwell SM100. - Ragged contiguous grouped GEMM for SM100 MoE workloads. - SM100 FMHA backward + MLA (multi-latent attention) kernels. **v4.3.2–v4.3.5 (2025-12-05 – 2026-01-09):** - Bug fixes and stability improvements; copyright updated to 2026. - Optimal code generation with CUDA toolkit 13.0U1. - Kernel name patterns (cutlass3x_sm100_tensorop_gemm_*) are unchanged between v4.1.0 and v4.3.5; no changes to CUTLASS_LIBRARY_KERNELS or the Python __kernel_map / __parse_logline are needed. - The CUDA >= 12.9 version threshold is unchanged (v4.3.5 still supports CUDA 12.9; optimal code generation targets CUDA 13.0U1). - SM80-era and SM90 build paths are unaffected (still use their existing CUTLASS versions). --- third_party/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index 685e8f8cd..3cf1e0546 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -39,12 +39,13 @@ sb_micro_path: mkdir -p $(SB_MICRO_PATH)/lib # Build cutlass. -# for cuda 12.9 and later Build from v4.1.0 for blackwell (SM100/SM103) support +# for cuda 12.9 and later Build from v4.3.5 for blackwell (SM100/SM103) support +# v4.3.5 adds SM103 (B300) blockscaled kernels, profiler hang/timeout fixes, and MoE GEMM support cuda_cutlass: ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) $(eval ARCHS := "100;103") if [ -d cutlass ]; then rm -rf cutlass; fi - git clone --branch v4.1.0 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass + git clone --branch v4.3.5 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) $(eval ARCHS := "90;100") if [ -d cutlass ]; then rm -rf cutlass; fi From 6939c6b3cfaebdab57686ba674966aff9380c57b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 00:04:56 +0000 Subject: [PATCH 05/30] Build: CUTLASS - refactor CUTLASS_LIBRARY_KERNELS to be per-architecture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CUTLASS_LIBRARY_KERNELS was a single flat list shared across all docker image build paths (SM70/80, SM90, SM100/103). This has two issues: 1. Intent is opaque: SM80 legacy names (cutlass_simt_*, cutlass_tensorop_*) sit alongside SM100 3x UMMA names (cutlass3x_sm100_*) with no indication of which applies to which GPU family. 2. Every cmake invocation carries all patterns regardless of the target architecture. Unmatched patterns are silently ignored by CUTLASS, so correctness is not affected, but the build definition misleads readers into thinking all kernels are built for all images. Each build path now declares only the kernel patterns relevant to its target GPU architecture, mirroring the existing per-arch ARCHS variable. The cmake call uses $(CUTLASS_KERNELS) instead of the hardcoded list. CUDA >= 12.9 (SM100/103, v4.3.5): cutlass3x_sm100_tensorop_gemm_{tf32,f16,bf16,s8}_* SM103 standard GEMM kernels use SM100 UMMA naming (same cutlass3x_sm100_* prefix) because SM103 inherits SM100's UMMA ISA. CUDA >= 12.8 (SM90+SM100, v3.9.2): cutlass3x_sm90_tensorop_gemm_{tf32,f16,bf16,s8}_* (Hopper WGMMA) cutlass3x_sm100_tensorop_gemm_{tf32,f16,bf16,s8}_* (Blackwell UMMA) This also fixes a pre-existing gap: the old flat list had zero SM90 3x WGMMA patterns, so Hopper kernels were never compiled into the profiler on CUDA 12.8 images. CUDA >= 11.8 (SM70–SM90, existing cutlass): cutlass_simt_{dgemm,sgemm,hgemm}_* (SIMT legacy) cutlass_tensorop_*gemm_* (SM80 TensorOp) Unchanged from the previous flat list. else (SM70–SM86 subset): cutlass_simt_* and Volta TensorOp (h884) only — no SM80 A100-specific kernels since those GPUs pre-date A100. $(eval VAR := ...) inside a Make recipe must be a single unbroken line. Backslash-newline inside $(eval ...) makes Make insert a space before each continuation, which corrupts the comma-separated kernel list sent to cmake. All CUTLASS_KERNELS assignments are therefore kept on one line. The cmake argument is quoted as "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNELS)" to handle any shell-level interpretation of special characters in the list. --- third_party/Makefile | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index 3cf1e0546..52292692c 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -39,21 +39,42 @@ sb_micro_path: mkdir -p $(SB_MICRO_PATH)/lib # Build cutlass. -# for cuda 12.9 and later Build from v4.3.5 for blackwell (SM100/SM103) support -# v4.3.5 adds SM103 (B300) blockscaled kernels, profiler hang/timeout fixes, and MoE GEMM support +# CUTLASS_LIBRARY_KERNELS is set per-architecture so each docker image only +# compiles the kernel families needed for its target GPU. Patterns that do not +# match any kernel generated for the target architecture are silently ignored by +# CUTLASS's cmake, so there is no correctness risk — but shipping a flat list +# that mixes SM80 legacy names with SM100 3x UMMA names makes the intent opaque +# and forces every image to carry irrelevant cmake work. +# +# Naming conventions used below: +# SM70/80 legacy : cutlass_simt_* / cutlass_tensorop_* (no arch prefix) +# SM90/100+ (3x) : cutlass3x_sm{arch}_tensorop_gemm_{dtype}_* +# +# Note: $(eval VAR := ...) inside a recipe must be a single line — backslash +# continuation inside $(eval ...) inserts spaces which corrupt comma-separated +# kernel lists passed to cmake. cuda_cutlass: ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) + # Blackwell SM100/SM103 — CUTLASS v4.3.5, 3x UMMA kernels only. + # SM103 standard GEMM kernels inherit SM100 UMMA naming (cutlass3x_sm100_*). $(eval ARCHS := "100;103") + $(eval CUTLASS_KERNELS := cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*) if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch v4.3.5 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) + # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2, 3x WGMMA/UMMA kernels. $(eval ARCHS := "90;100") + $(eval CUTLASS_KERNELS := cutlass3x_sm90_tensorop_gemm_tf32_*,cutlass3x_sm90_tensorop_gemm_f16_*,cutlass3x_sm90_tensorop_gemm_bf16_*,cutlass3x_sm90_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*) if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch v3.9.2 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) + # Volta through Ada (SM70–SM90) — legacy SIMT and SM80 TensorOp kernels. $(eval ARCHS := "70;75;80;86;89;90") + $(eval CUTLASS_KERNELS := cutlass_simt_dgemm_128x128_8x2_*,cutlass_simt_sgemm_128x128_8x2_*,cutlass_simt_hgemm_256x128_8x2_*,cutlass_tensorop_h884gemm_256x128_32x2_*,cutlass_tensorop_d884gemm_128x128_16x3_*,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,cutlass_tensorop_h16816gemm_256x128_32x3_*,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*) else + # Volta/Turing subset (SM70–SM86) — SIMT + Volta TensorOp only. $(eval ARCHS := "70;75;80;86") + $(eval CUTLASS_KERNELS := cutlass_simt_dgemm_128x128_8x2_*,cutlass_simt_sgemm_128x128_8x2_*,cutlass_simt_hgemm_256x128_8x2_*,cutlass_tensorop_h884gemm_256x128_32x2_*) endif ifneq (,$(wildcard cutlass/CMakeLists.txt)) @@ -65,20 +86,7 @@ ifneq (,$(wildcard cutlass/CMakeLists.txt)) -DCUTLASS_ENABLE_TESTS=OFF \ -S ./cutlass \ -B ./cutlass/build \ - -DCUTLASS_LIBRARY_KERNELS="cutlass_simt_dgemm_128x128_8x2_*,\ -cutlass_simt_sgemm_128x128_8x2_*,\ -cutlass_simt_hgemm_256x128_8x2_*,\ -cutlass_tensorop_h884gemm_256x128_32x2_*,\ -cutlass_tensorop_d884gemm_128x128_16x3_*,\ -cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,\ -cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,\ -cutlass_tensorop_h16816gemm_256x128_32x3_*,\ -cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,\ -cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*,\ -cutlass3x_sm100_tensorop_gemm_tf32_*,\ -cutlass3x_sm100_tensorop_gemm_f16_*,\ -cutlass3x_sm100_tensorop_gemm_bf16_*,\ -cutlass3x_sm100_tensorop_gemm_s8_*" + "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNELS)" cmake --build ./cutlass/build -j $(shell nproc --ignore=2) --target install rm -rf ./cutlass/build endif From 81236c28b12e7066b77e70df8140be64f555ce45 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 00:19:31 +0000 Subject: [PATCH 06/30] feat: add fp8_tc precision to gemm-flops benchmark base Register fp8_tc as a supported precision in GemmFlopsBenchmark. - Add 'fp8_tc' to _support_precisions list - Add 'fp8_tc': 'fp8_tc_flops' to _metric_map FP8 (e4m3) is the highest-throughput floating-point format natively supported by both Hopper (SM90) and Blackwell (SM100/SM103): H100/H200: ~3.9 PFLOPS FP8 (CUTLASS WGMMA, 3x naming) GB200: ~4.5 PFLOPS FP8 (CUTLASS UMMA, 3x naming) GB300: ~7.0 PFLOPS FP8 (CUTLASS UMMA, 3x naming) Not adding fp8_tc to _support_precisions alone is sufficient since _support_precisions is overridden at runtime by __kernel_map[capability] keys; older GPUs (SM80 and below) will not see fp8_tc because there is no __kernel_map entry for them. --- .../benchmarks/micro_benchmarks/gemm_flops_performance_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py index a1b283b1e..927e43b5a 100644 --- a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py +++ b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py @@ -20,7 +20,7 @@ def __init__(self, name, parameters=''): super().__init__(name, parameters) self._support_precisions = [ - 'fp64', 'fp32', 'fp16', 'fp64_tc', 'tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc', 'int4_tc' + 'fp64', 'fp32', 'fp16', 'fp64_tc', 'tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc', 'int4_tc', 'fp8_tc' ] self._precision_need_to_run = list() self._metric_map = { @@ -33,6 +33,7 @@ def __init__(self, name, parameters=''): 'fp16_tc': 'fp16_tc_flops', 'int8_tc': 'int8_tc_iops', 'int4_tc': 'int4_tc_iops', + 'fp8_tc': 'fp8_tc_flops', 'fp32_xdlops': 'fp32_xdlops_flops', 'fp16_xdlops': 'fp16_xdlops_flops', 'bf16_xdlops': 'bf16_xdlops_flops', From c0b61c7bca37217938ba68b8e968906381639ca7 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 00:19:43 +0000 Subject: [PATCH 07/30] feat: add fp8_tc kernel patterns for SM90 and SM100 in gemm-flops Add fp8_tc (FP8 e4m3) precision to the CUDA gemm-flops benchmark kernel map and CSV output parser for Hopper and Blackwell GPUs. Kernel map additions: - SM90 (H100/H200): 'cutlass3x_sm90_tensorop_gemm_e4m3_*' Uses CUTLASS WGMMA 3x kernels from v3.9.2+. - SM100 (GB200): 'cutlass3x_sm100_tensorop_gemm_e4m3_*' Uses CUTLASS UMMA 3x kernels from v4.3.5. - SM103 (GB300): inherits SM100 map via dict() copy (no change needed). FP8 is NOT added to SM80 or older maps since CUTLASS does not generate e4m3 SIMT/TensorOp kernels for those architectures. The runtime _support_precisions override (line 101: list(__kernel_map[cap].keys())) means fp8_tc is silently excluded on GPUs whose map has no fp8_tc entry, requiring no config-level exclusion by the user. Parse pattern additions in __parse_logline: - 'gemm,cutlass3x_sm90_tensorop_gemm_e4m3_' for SM90 FP8 output rows - 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_' for SM100 FP8 output rows --- .../micro_benchmarks/cuda_gemm_flops_performance.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 9452775c4..7abd2b8ec 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -25,7 +25,7 @@ def __init__(self, name, parameters=''): self._bin_name = 'cutlass_profiler' # TODO - To support more architectures - # Currently only support compute capability = 7.0, 7.5, 8.0, 8.6, 8.9, 9.0, 10.0 + # Currently only support compute capability = 7.0, 7.5, 8.0, 8.6, 8.9, 9.0, 10.0, 10.3 self.__kernel_map = { 7.0: { 'fp64': 'cutlass_simt_dgemm_128x128_8x2_*', @@ -52,6 +52,8 @@ def __init__(self, name, parameters=''): self.__kernel_map[8.9] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'fp64' not in k} # Skip INT4 for Hopper due to no native CUDA/Tensor Cores self.__kernel_map[9.0] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} + # FP8 (e4m3) on Hopper SM90: CUTLASS 3x WGMMA kernels (CUTLASS v3.9.2+). + self.__kernel_map[9.0]['fp8_tc'] = 'cutlass3x_sm90_tensorop_gemm_e4m3_*' # Blackwell (SM100/SM103): CUTLASS v4.1.0 GenerateSM100 only generates UMMA TensorOp kernels. # Kernel names use the 3x naming scheme: cutlass3x_sm100_tensorop_gemm_{dtypes}_{tile}_{cluster}_... # SIMT kernels (fp64/fp32/fp16) and fp64_tc are not generated for SM100 in CUTLASS v4.1.0. @@ -60,6 +62,7 @@ def __init__(self, name, parameters=''): 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_*', 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_*', 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_*', + 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_*', } self.__kernel_map[10.3] = dict(self.__kernel_map[10.0]) self.__parse_logline = [ @@ -70,9 +73,12 @@ def __init__(self, name, parameters=''): 'gemm,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3', 'gemm,cutlass_tensorop_h16816gemm_256x128_32x3', 'gemm,cutlass_tensorop_h884gemm_256x128_32x2', 'gemm,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3', 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', + # SM90 (Hopper) WGMMA kernels (3x naming: cutlass3x_sm90_tensorop_gemm_{dtype}_*) + 'gemm,cutlass3x_sm90_tensorop_gemm_e4m3_', # SM100 (Blackwell) UMMA kernels (3x naming: cutlass3x_sm100_tensorop_gemm_{dtype}_*) 'gemm,cutlass3x_sm100_tensorop_gemm_tf32_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', + 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_', ] def add_parser_arguments(self): From bac7829e769498d6754da68b32e443ade0e10f12 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 00:19:52 +0000 Subject: [PATCH 08/30] build: add FP8 (e4m3) CUTLASS kernel patterns to Makefile Extend per-architecture CUTLASS_KERNELS with e4m3 FP8 patterns so the cutlass_profiler binary contains FP8 benchmarking support. Changes: - CUDA >= 12.9 (SM100/103, CUTLASS v4.3.5): + cutlass3x_sm100_tensorop_gemm_e4m3_* - CUDA >= 12.8 (SM90/100, CUTLASS v3.9.2): + cutlass3x_sm90_tensorop_gemm_e4m3_* (Hopper WGMMA FP8) + cutlass3x_sm100_tensorop_gemm_e4m3_* (Blackwell UMMA FP8) FP8 e4m3 delivers the highest floating-point throughput before FP4: H100/H200 (SM90): ~3.9 PFLOPS GB200 (SM100): ~4.5 PFLOPS GB300 (SM103): ~7.0 PFLOPS Older CUDA paths (< 12.8, targeting SM70-SM86) are unchanged since CUTLASS SIMT/TensorOp kernels for those architectures do not include FP8 support. --- third_party/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index 52292692c..ca876df71 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -58,13 +58,13 @@ ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) # Blackwell SM100/SM103 — CUTLASS v4.3.5, 3x UMMA kernels only. # SM103 standard GEMM kernels inherit SM100 UMMA naming (cutlass3x_sm100_*). $(eval ARCHS := "100;103") - $(eval CUTLASS_KERNELS := cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*) + $(eval CUTLASS_KERNELS := cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_e4m3_*) if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch v4.3.5 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2, 3x WGMMA/UMMA kernels. $(eval ARCHS := "90;100") - $(eval CUTLASS_KERNELS := cutlass3x_sm90_tensorop_gemm_tf32_*,cutlass3x_sm90_tensorop_gemm_f16_*,cutlass3x_sm90_tensorop_gemm_bf16_*,cutlass3x_sm90_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*) + $(eval CUTLASS_KERNELS := cutlass3x_sm90_tensorop_gemm_tf32_*,cutlass3x_sm90_tensorop_gemm_f16_*,cutlass3x_sm90_tensorop_gemm_bf16_*,cutlass3x_sm90_tensorop_gemm_s8_*,cutlass3x_sm90_tensorop_gemm_e4m3_*,cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_e4m3_*) if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch v3.9.2 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) From 3fd5055c074f8e1ad5b8bf6964c8a91985452ab2 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 00:20:01 +0000 Subject: [PATCH 09/30] test: add FP8 (e4m3) parsing tests for SM90 and SM100 gemm-flops Add test_flops_performance_cuda_fp8() to verify that the CSV output parser correctly extracts GFLOPs from FP8 e4m3 kernel result lines for both Hopper (SM90) and Blackwell (SM100) architectures. Test cases cover: - SM90 WGMMA kernel: cutlass3x_sm90_tensorop_gemm_e4m3_e4m3_f32_* Expected max GFLOPs: 2317200 (from two kernel variants) - SM100 UMMA kernel: cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_* Expected max GFLOPs: 5425400 (from two kernel variants) The test reuses the existing _process_raw_result() path and verifies that 'fp8_tc_flops' is correctly populated in benchmark.result. --- .../test_cuda_gemm_flops_performance.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index b41f6c91c..ff72131f9 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -144,3 +144,36 @@ def test_flops_performance_cuda_sm100(self): assert (benchmark.result['bf16_tc_flops'][0] == 2096300) assert (benchmark.result['fp16_tc_flops'][0] == 2056200) assert (benchmark.result['int8_tc_iops'][0] == 4091600) + + @decorator.cuda_test + def test_flops_performance_cuda_fp8(self): + """Test gemm-flops benchmark FP8 (e4m3) kernel output parsing for SM90 and SM100.""" + benchmark_name = 'gemm-flops' + (benchmark_class, + predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) + assert (benchmark_class) + + benchmark = benchmark_class(benchmark_name, parameters='') + benchmark._CudaGemmFlopsBenchmark__precision_need_to_run = ['fp8_tc', 'fp8_tc'] + + # SM90 Hopper WGMMA 3x kernel: cutlass3x_sm90_tensorop_gemm_e4m3_{a}_{b}_{acc}_{c}_{d}_{tile}_... + raw_output_sm90_fp8 = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm90_tensorop_gemm_e4m3_e4m3_f32_bf16_bf16_128x128x64_2x1x1_0_tnn_align16_warpspecialized_cooperative_epi_tma,passed,success,universal,16384,16384,16384,3.85,2281500 +1,CUTLASS,gemm,cutlass3x_sm90_tensorop_gemm_e4m3_e4m3_f32_f16_f16_128x128x64_2x1x1_0_tnn_align16_warpspecialized_cooperative_epi_tma,passed,success,universal,16384,16384,16384,3.79,2317200 +""" + # SM100 Blackwell UMMA 3x kernel: cutlass3x_sm100_tensorop_gemm_e4m3_{a}_{b}_{acc}_{c}_{d}_{tile}_... + raw_output_sm100_fp8 = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_bf16_bf16_128x256x64_1x2x1_0_ntn_align16_1sm,passed,success,universal,16384,16384,16384,2.10,5296000 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32_128x256x64_1x2x1_0_ntn_align16_1sm,passed,success,universal,16384,16384,16384,2.05,5425400 +""" + assert (benchmark._process_raw_result(0, raw_output_sm90_fp8)) + assert (benchmark._process_raw_result(1, raw_output_sm100_fp8)) + + assert (benchmark.result['fp8_tc_flops'][0] == 2317200) + assert (benchmark.result['fp8_tc_flops'][1] == 5425400) From af429e2568cb679e437bb5b6e42a7dc47dfe9fca Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 01:06:16 +0000 Subject: [PATCH 10/30] fix: restore SM80 legacy kernel patterns in CUDA >= 12.8 Makefile path The per-architecture refactoring (c8f21fe) accidentally dropped SM80 legacy kernel patterns from the CUDA >= 12.8 build path, which would cause the same timeout hang on Hopper H100/H200 that we fixed for Blackwell. Root cause: __kernel_map[9.0] maps non-FP8 precisions (fp64, fp32, fp16, fp64_tc, tf32_tc, bf16_tc, fp16_tc, int8_tc) to SM80-era legacy names (cutlass_simt_*, cutlass_tensorop_*). These kernels are backward-compatible on SM90 Hopper, but the Makefile was only building cutlass3x_sm90_* patterns, so cutlass_profiler would find zero matching kernels for non-FP8 precisions and hang. Changes: - Restored SM80 legacy patterns (SIMT + TensorOp) in CUTLASS_KERNELS - Restored ARCHS '80;90;100' (was '90;100') to compile SM80 kernels - Kept SM90 FP8 (cutlass3x_sm90_tensorop_gemm_e4m3_*) and all SM100 3x UMMA patterns alongside the legacy ones This matches the original main branch ARCHS='80;90;100' while adding the new 3x patterns for FP8 and SM100 support. --- third_party/Makefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/third_party/Makefile b/third_party/Makefile index ca876df71..5d5dcaa73 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -62,9 +62,11 @@ ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch v4.3.5 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) - # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2, 3x WGMMA/UMMA kernels. - $(eval ARCHS := "90;100") - $(eval CUTLASS_KERNELS := cutlass3x_sm90_tensorop_gemm_tf32_*,cutlass3x_sm90_tensorop_gemm_f16_*,cutlass3x_sm90_tensorop_gemm_bf16_*,cutlass3x_sm90_tensorop_gemm_s8_*,cutlass3x_sm90_tensorop_gemm_e4m3_*,cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_e4m3_*) + # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2. + # SM90 non-FP8 precisions use legacy SM80 kernel names (SIMT + TensorOp) which + # are backward-compatible on Hopper. SM90 FP8 and SM100 use 3x naming. + $(eval ARCHS := "80;90;100") + $(eval CUTLASS_KERNELS := cutlass_simt_dgemm_128x128_8x2_*,cutlass_simt_sgemm_128x128_8x2_*,cutlass_simt_hgemm_256x128_8x2_*,cutlass_tensorop_h884gemm_256x128_32x2_*,cutlass_tensorop_d884gemm_128x128_16x3_*,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,cutlass_tensorop_h16816gemm_256x128_32x3_*,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*,cutlass3x_sm90_tensorop_gemm_e4m3_*,cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_e4m3_*) if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch v3.9.2 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) From 95f79cf6e4b4abb65fc152cfa15fd09004361520 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 18 Apr 2026 01:06:29 +0000 Subject: [PATCH 11/30] fix: correct test setup for SM100 and FP8 gemm-flops tests The SM100 and FP8 tests used Python name-mangled attribute _CudaGemmFlopsBenchmark__precision_need_to_run which creates a separate attribute from the _precision_need_to_run that _process_raw_result() actually reads. Without calling _preprocess() (which parses args, initializes _result, and sets the real attribute), both tests would fail with IndexError or AttributeError at runtime. Fixes: - Initialize args via add_parser_arguments() + parse_args() so _args.log_raw_data is available for _process_raw_result() - Create BenchmarkResult so _result.add_raw_data() works - Set benchmark._precision_need_to_run (the correct base-class attribute) instead of the name-mangled variant Note: the pre-existing SM80 test (test_flops_performance_cuda) has the same name-mangled assignment at line 56, but it is harmless there because _preprocess() is called first which correctly populates _precision_need_to_run via the --precision CLI argument. --- .../test_cuda_gemm_flops_performance.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index ff72131f9..340788313 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -102,8 +102,15 @@ def test_flops_performance_cuda_sm100(self): predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) assert (benchmark_class) - benchmark = benchmark_class(benchmark_name, parameters='') - benchmark._CudaGemmFlopsBenchmark__precision_need_to_run = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc'] + benchmark = benchmark_class(benchmark_name, parameters='--precision tf32_tc bf16_tc fp16_tc int8_tc') + # Parse args so _args and _result are initialized for _process_raw_result(). + benchmark.add_parser_arguments() + ret, benchmark._args, _ = benchmark.parse_args() + assert ret + from superbench.benchmarks.result import BenchmarkResult + from superbench.benchmarks import BenchmarkType, ReturnCode + benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) + benchmark._precision_need_to_run = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc'] # SM100 UMMA 3x kernel naming: cutlass3x_sm100_tensorop_gemm_{dtype_a}_{dtype_b}_{acc}_{c}_{d}_{tile}_{cluster}_{stages}_{layout}_align{al}_{schedule} raw_output_tf32_tc = """ @@ -153,8 +160,15 @@ def test_flops_performance_cuda_fp8(self): predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) assert (benchmark_class) - benchmark = benchmark_class(benchmark_name, parameters='') - benchmark._CudaGemmFlopsBenchmark__precision_need_to_run = ['fp8_tc', 'fp8_tc'] + benchmark = benchmark_class(benchmark_name, parameters='--precision fp8_tc') + # Parse args so _args and _result are initialized for _process_raw_result(). + benchmark.add_parser_arguments() + ret, benchmark._args, _ = benchmark.parse_args() + assert ret + from superbench.benchmarks.result import BenchmarkResult + from superbench.benchmarks import BenchmarkType, ReturnCode + benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) + benchmark._precision_need_to_run = ['fp8_tc', 'fp8_tc'] # SM90 Hopper WGMMA 3x kernel: cutlass3x_sm90_tensorop_gemm_e4m3_{a}_{b}_{acc}_{c}_{d}_{tile}_... raw_output_sm90_fp8 = """ From f44d9591ec2dba7e2538bc8da04ab10f9248f025 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Mon, 20 Apr 2026 18:43:56 +0000 Subject: [PATCH 12/30] fix: wrap long comment to pass flake8 E501 line length check --- .../micro_benchmarks/test_cuda_gemm_flops_performance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 340788313..05fa2262b 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -112,7 +112,8 @@ def test_flops_performance_cuda_sm100(self): benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) benchmark._precision_need_to_run = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc'] - # SM100 UMMA 3x kernel naming: cutlass3x_sm100_tensorop_gemm_{dtype_a}_{dtype_b}_{acc}_{c}_{d}_{tile}_{cluster}_{stages}_{layout}_align{al}_{schedule} + # SM100 UMMA 3x kernel naming: + # cutlass3x_sm100_tensorop_gemm_{dtype_a}_{dtype_b}_{acc}_{c}_{d}_{tile}_{cluster}_{stages}_{layout}_align{al}_{schedule} raw_output_tf32_tc = """ CSV Results: From 67ecd9f48d947b737e4c774687150bd3a4b76a35 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Mon, 20 Apr 2026 19:21:26 +0000 Subject: [PATCH 13/30] Fix CUTLASS v4.3.5 build failure for Blackwell SM100/SM103 and refactor to sub-makefile Three bugs in the CUDA>=12.9 CUTLASS build caused generated_kernels.txt to never be created, failing the cmake install step: 1. Bare arch tokens "100;103" do not trigger Blackwell code generation. CUTLASS v4.3.5's generator.py requires suffixed tokens (100a, 103a, etc.) to enter the GenerateSM100() path. Changed to "100a;103a". 2. TF32 kernel filter pattern "gemm_tf32_*" does not match actual kernel procedural names. In CUTLASS v4.3.5, the intermediate type precedes "gemm" in core_name(), producing "tf32gemm" not "gemm_tf32". Changed to "tf32gemm*". 3. CUTLASS gates int8 GEMM generation when 103a is in the arch list (arch_family_cc pruning in GenerateSM100()). SM103 hardware fully supports tcgen05.mma.kind::i8, and generated int8 kernels use CC range [100, 110] via ThorSMRenumbering, so runtime dispatches them on both SM100 and SM103. The gate is a dead-kernel pruning optimization for family-binary builds, not a hardware limitation. A sed patch clears arch_family_cc to restore int8 GEMM in the combined 100a+103a build. Also fixed the same TF32 naming issue in the CUDA>=12.8 block. Refactored the entire cuda_cutlass target into a dedicated cutlass.mk sub-makefile to isolate the growing per-architecture complexity: - Reusable kernel list variables (CUTLASS_KERNELS_LEGACY, _VOLTA, _SM100) eliminate duplicated 200+ char strings across CUDA version tiers. - Each tier now sets 4 variables (TAG, ARCHS, KERNS, PATCHES) and shares a single clone -> patch -> cmake -> build -> install pipeline. - _strip_spaces helper handles Make backslash-continuation space injection. - Adding new GPU architectures or CUDA tiers is now a 4-line addition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- third_party/Makefile | 56 +---------------- third_party/cutlass.mk | 137 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 54 deletions(-) create mode 100644 third_party/cutlass.mk diff --git a/third_party/Makefile b/third_party/Makefile index 5d5dcaa73..ff9db68fa 100755 --- a/third_party/Makefile +++ b/third_party/Makefile @@ -38,60 +38,8 @@ sb_micro_path: mkdir -p $(SB_MICRO_PATH)/bin mkdir -p $(SB_MICRO_PATH)/lib -# Build cutlass. -# CUTLASS_LIBRARY_KERNELS is set per-architecture so each docker image only -# compiles the kernel families needed for its target GPU. Patterns that do not -# match any kernel generated for the target architecture are silently ignored by -# CUTLASS's cmake, so there is no correctness risk — but shipping a flat list -# that mixes SM80 legacy names with SM100 3x UMMA names makes the intent opaque -# and forces every image to carry irrelevant cmake work. -# -# Naming conventions used below: -# SM70/80 legacy : cutlass_simt_* / cutlass_tensorop_* (no arch prefix) -# SM90/100+ (3x) : cutlass3x_sm{arch}_tensorop_gemm_{dtype}_* -# -# Note: $(eval VAR := ...) inside a recipe must be a single line — backslash -# continuation inside $(eval ...) inserts spaces which corrupt comma-separated -# kernel lists passed to cmake. -cuda_cutlass: -ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) - # Blackwell SM100/SM103 — CUTLASS v4.3.5, 3x UMMA kernels only. - # SM103 standard GEMM kernels inherit SM100 UMMA naming (cutlass3x_sm100_*). - $(eval ARCHS := "100;103") - $(eval CUTLASS_KERNELS := cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_e4m3_*) - if [ -d cutlass ]; then rm -rf cutlass; fi - git clone --branch v4.3.5 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass -else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) - # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2. - # SM90 non-FP8 precisions use legacy SM80 kernel names (SIMT + TensorOp) which - # are backward-compatible on Hopper. SM90 FP8 and SM100 use 3x naming. - $(eval ARCHS := "80;90;100") - $(eval CUTLASS_KERNELS := cutlass_simt_dgemm_128x128_8x2_*,cutlass_simt_sgemm_128x128_8x2_*,cutlass_simt_hgemm_256x128_8x2_*,cutlass_tensorop_h884gemm_256x128_32x2_*,cutlass_tensorop_d884gemm_128x128_16x3_*,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,cutlass_tensorop_h16816gemm_256x128_32x3_*,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*,cutlass3x_sm90_tensorop_gemm_e4m3_*,cutlass3x_sm100_tensorop_gemm_tf32_*,cutlass3x_sm100_tensorop_gemm_f16_*,cutlass3x_sm100_tensorop_gemm_bf16_*,cutlass3x_sm100_tensorop_gemm_s8_*,cutlass3x_sm100_tensorop_gemm_e4m3_*) - if [ -d cutlass ]; then rm -rf cutlass; fi - git clone --branch v3.9.2 --depth 1 https://github.com/NVIDIA/cutlass.git && cd cutlass -else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) - # Volta through Ada (SM70–SM90) — legacy SIMT and SM80 TensorOp kernels. - $(eval ARCHS := "70;75;80;86;89;90") - $(eval CUTLASS_KERNELS := cutlass_simt_dgemm_128x128_8x2_*,cutlass_simt_sgemm_128x128_8x2_*,cutlass_simt_hgemm_256x128_8x2_*,cutlass_tensorop_h884gemm_256x128_32x2_*,cutlass_tensorop_d884gemm_128x128_16x3_*,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,cutlass_tensorop_h16816gemm_256x128_32x3_*,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_*) -else - # Volta/Turing subset (SM70–SM86) — SIMT + Volta TensorOp only. - $(eval ARCHS := "70;75;80;86") - $(eval CUTLASS_KERNELS := cutlass_simt_dgemm_128x128_8x2_*,cutlass_simt_sgemm_128x128_8x2_*,cutlass_simt_hgemm_256x128_8x2_*,cutlass_tensorop_h884gemm_256x128_32x2_*) -endif - -ifneq (,$(wildcard cutlass/CMakeLists.txt)) - cmake -DCMAKE_INSTALL_BINDIR=$(SB_MICRO_PATH)/bin \ - -DCMAKE_INSTALL_LIBDIR=$(SB_MICRO_PATH)/lib \ - -DCMAKE_BUILD_TYPE=Release \ - -DCUTLASS_NVCC_ARCHS=$(ARCHS) \ - -DCUTLASS_ENABLE_EXAMPLES=OFF \ - -DCUTLASS_ENABLE_TESTS=OFF \ - -S ./cutlass \ - -B ./cutlass/build \ - "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNELS)" - cmake --build ./cutlass/build -j $(shell nproc --ignore=2) --target install - rm -rf ./cutlass/build -endif +# Build cutlass — configuration lives in cutlass.mk. +include cutlass.mk # Build cuda-samples/Samples/bandwidthTest. # cuda-samples is released together with CUDA, they have the exact same version. Like v10.0, v11.1 and so on. diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk new file mode 100644 index 000000000..9c858db79 --- /dev/null +++ b/third_party/cutlass.mk @@ -0,0 +1,137 @@ +# Copyright (c) Microsoft Corporation - All rights reserved +# Licensed under the MIT License +# +# CUTLASS build configuration for SuperBench. +# +# This sub-makefile is included by the main Makefile and provides the +# cuda_cutlass target. Moving CUTLASS here keeps the growing per-arch +# complexity (kernel filters, generator patches, naming conventions) +# isolated from the rest of the third-party build. +# +# --------------------------------------------------------------------------- +# Kernel naming conventions +# --------------------------------------------------------------------------- +# SM70/80 legacy : cutlass_simt_* / cutlass_tensorop_* (no arch prefix) +# SM90/100+ (3x) : cutlass3x_sm{arch}_tensorop_{core_name}_{dtype}_* +# Note: TF32 kernels use "tf32gemm" (intermediate type before "gemm"), +# e.g. cutlass3x_sm100_tensorop_tf32gemm_f32_f32_* +# +# --------------------------------------------------------------------------- +# Shared kernel lists (reusable fragments) +# --------------------------------------------------------------------------- +# SM70–90 legacy SIMT + TensorOp kernels +CUTLASS_KERNELS_LEGACY := \ + cutlass_simt_dgemm_128x128_8x2_*,\ + cutlass_simt_sgemm_128x128_8x2_*,\ + cutlass_simt_hgemm_256x128_8x2_*,\ + cutlass_tensorop_h884gemm_256x128_32x2_*,\ + cutlass_tensorop_d884gemm_128x128_16x3_*,\ + cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3_*,\ + cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3_*,\ + cutlass_tensorop_h16816gemm_256x128_32x3_*,\ + cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,\ + cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_* + +# SM70–80 Volta/Turing subset (no Ampere+ TensorOp) +CUTLASS_KERNELS_VOLTA := \ + cutlass_simt_dgemm_128x128_8x2_*,\ + cutlass_simt_sgemm_128x128_8x2_*,\ + cutlass_simt_hgemm_256x128_8x2_*,\ + cutlass_tensorop_h884gemm_256x128_32x2_* + +# SM100 Blackwell 3x UMMA GEMM kernels +CUTLASS_KERNELS_SM100 := \ + cutlass3x_sm100_tensorop_tf32gemm*,\ + cutlass3x_sm100_tensorop_gemm_f16_*,\ + cutlass3x_sm100_tensorop_gemm_bf16_*,\ + cutlass3x_sm100_tensorop_gemm_s8_*,\ + cutlass3x_sm100_tensorop_gemm_e4m3_* + +# Strip spaces that Make inserts from the line-continuation backslashes. +# Without this, cmake receives "cutlass_simt_dgemm..., cutlass_simt_sgemm..." +# (note the space after each comma) which breaks CUTLASS's kernel filter. +_strip_spaces = $(subst $(space),,$1) +space := $(subst ,, ) + +# --------------------------------------------------------------------------- +# cuda_cutlass target +# --------------------------------------------------------------------------- +# Each CUDA version tier selects: +# CUTLASS_TAG — git tag to clone +# CUTLASS_ARCHS — semicolon-separated NVCC arch list +# CUTLASS_KERNS — comma-separated kernel filter patterns +# CUTLASS_PATCHES — optional post-clone fixups (sed commands, etc.) +# +# After the version-specific block, a shared section clones, patches, +# configures, builds, and installs. + +.PHONY: cuda_cutlass + +cuda_cutlass: +ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) + # ----------------------------------------------------------------------- + # Blackwell GB200 (SM100a) + GB300 (SM103a) — CUTLASS v4.3.5 + # ----------------------------------------------------------------------- + # Arch tokens must use the "a" suffix; bare "100"/"103" do not trigger + # Blackwell code generation in CUTLASS v4.3.5's generator.py. + # + # CUTLASS gates int8 GEMM generation when 103a is in the arch list + # (arch_family_cc pruning heuristic). We patch that gate out because: + # 1. SM103 hardware fully supports tcgen05.mma.kind::i8 (0.165 POPS dense). + # 2. Generated int8 kernels use CC range [100, 110] (via ThorSMRenumbering), + # so CUTLASS runtime dispatches them on both SM100 and SM103. + # The gate is a dead-kernel pruning optimization for family-binary builds, + # not a hardware limitation. The sed patch only affects the two int8 gates + # in GenerateSM100(); no other code paths use arch_family_cc. + $(eval CUTLASS_TAG := v4.3.5) + $(eval CUTLASS_ARCHS := "100a;103a") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = []/" cutlass/python/cutlass_library/generator.py) + +else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) + # ----------------------------------------------------------------------- + # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2 + # ----------------------------------------------------------------------- + # SM90 non-FP8 precisions use legacy SM80 kernel names (SIMT + TensorOp) + # which are backward-compatible on Hopper. SM90 FP8 and SM100 use 3x naming. + $(eval CUTLASS_TAG := v3.9.2) + $(eval CUTLASS_ARCHS := "80;90;100") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY)),cutlass3x_sm90_tensorop_gemm_e4m3_*,$(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) + $(eval CUTLASS_PATCHES := @true) + +else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) + # ----------------------------------------------------------------------- + # Volta through Ada (SM70–SM90) + # ----------------------------------------------------------------------- + $(eval CUTLASS_TAG := v3.9.2) + $(eval CUTLASS_ARCHS := "70;75;80;86;89;90") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY))) + $(eval CUTLASS_PATCHES := @true) + +else + # ----------------------------------------------------------------------- + # Volta/Turing subset (SM70–SM86) + # ----------------------------------------------------------------------- + $(eval CUTLASS_TAG := v3.9.2) + $(eval CUTLASS_ARCHS := "70;75;80;86") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_VOLTA))) + $(eval CUTLASS_PATCHES := @true) + +endif + # ----------------------------------------------------------------------- + # Shared clone → patch → build → install pipeline + # ----------------------------------------------------------------------- + if [ -d cutlass ]; then rm -rf cutlass; fi + git clone --branch $(CUTLASS_TAG) --depth 1 https://github.com/NVIDIA/cutlass.git + $(CUTLASS_PATCHES) + cmake -DCMAKE_INSTALL_BINDIR=$(SB_MICRO_PATH)/bin \ + -DCMAKE_INSTALL_LIBDIR=$(SB_MICRO_PATH)/lib \ + -DCMAKE_BUILD_TYPE=Release \ + -DCUTLASS_NVCC_ARCHS=$(CUTLASS_ARCHS) \ + -DCUTLASS_ENABLE_EXAMPLES=OFF \ + -DCUTLASS_ENABLE_TESTS=OFF \ + -S ./cutlass \ + -B ./cutlass/build \ + "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNS)" + cmake --build ./cutlass/build -j $(NUM_MAKE_JOBS) --target install + rm -rf ./cutlass/build From 907ac43c930f20ad6a864aead568849b1c369f4d Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 21 Apr 2026 00:11:21 +0000 Subject: [PATCH 14/30] Fix aarch64 linker overflow in CUTLASS FP8 kernel shared libraries On ARM64 (Grace CPU), the per-family shared library libcutlass_gemm_sm100_f16_gemm_e4m3.so overflows R_AARCH64_PREL32 relocations in .eh_frame when thousands of FP8 kernel objects are linked into a single SO. The 32-bit relative offset cannot span the large .text section produced by the FP8 e4m3 kernel family. Fix by: 1. Building static libs only (-DCUTLASS_BUILD_SHARED_LIBS=OFF) to avoid the SO link step entirely. SuperBench only uses the cutlass_profiler binary which links statically. 2. Suppressing asynchronous unwind tables in generated kernel TUs (-fno-asynchronous-unwind-tables) to reduce .eh_frame size as a defense-in-depth measure. This is safe because generated kernel code does not throw C++ exceptions; the core library objects (handle.cu, util.cu) that do throw retain synchronous unwind tables which are sufficient for exception propagation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- third_party/cutlass.mk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 9c858db79..ee05d39f2 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -121,6 +121,12 @@ endif # ----------------------------------------------------------------------- # Shared clone → patch → build → install pipeline # ----------------------------------------------------------------------- + # On aarch64, per-family shared libraries (e.g. libcutlass_gemm_sm100_f16_gemm_e4m3.so) + # can overflow R_AARCH64_PREL32 relocations in .eh_frame when thousands of FP8 + # kernel objects are linked into a single SO. Work around this by: + # - Building static libs only (avoids the SO link that overflows) + # - Suppressing unwind tables in generated kernel TUs (reduces .eh_frame) + # SuperBench only uses cutlass_profiler, which links statically, so no SO is needed. if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch $(CUTLASS_TAG) --depth 1 https://github.com/NVIDIA/cutlass.git $(CUTLASS_PATCHES) @@ -130,6 +136,10 @@ endif -DCUTLASS_NVCC_ARCHS=$(CUTLASS_ARCHS) \ -DCUTLASS_ENABLE_EXAMPLES=OFF \ -DCUTLASS_ENABLE_TESTS=OFF \ + -DCUTLASS_BUILD_SHARED_LIBS=OFF \ + -DCUTLASS_BUILD_STATIC_LIBS=ON \ + -DCMAKE_CXX_FLAGS="-fno-asynchronous-unwind-tables" \ + -DCMAKE_CUDA_FLAGS="--compiler-options=-fno-asynchronous-unwind-tables" \ -S ./cutlass \ -B ./cutlass/build \ "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNS)" From 1cc4d89549cb7804689b505dfad3c1f225cc5525 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 23 Apr 2026 23:38:38 +0000 Subject: [PATCH 15/30] Fix CUTLASS aarch64 build and add FP4 benchmark support - Narrow SM100 kernel filter from 5 broad wildcards (~10K objects) to 10 exact dtype patterns (~3,900 objects) to stay under aarch64 R_AARCH64_PREL32 relocation limit. Remove void-output, mixed-output, and e5m2/e3m2 input variants not needed for benchmarking. - Switch from static-only to shared per-family libraries, eliminating the need for sed alias patch and objcopy workarounds. - Fix TF32 kernel name mismatch: gemm_tf32_* -> tf32gemm_* to match actual CUTLASS v4.3.5 kernel names. - Fix FP8 kernel filter overlap: gemm_e4m3_* -> gemm_e4m3_e4m3_* to prevent matching FP4/FP6 kernels and reporting inflated FLOPS. - Add FP4 (e4m3 x e2m1) precision support to gemm-flops benchmark for Blackwell GB200/GB300. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../cuda_gemm_flops_performance.py | 13 ++++--- .../gemm_flops_performance_base.py | 4 +- .../test_cuda_gemm_flops_performance.py | 35 ++++++++++++++++-- third_party/cutlass.mk | 37 +++++++++++-------- 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 7abd2b8ec..6a74ab31f 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -58,11 +58,12 @@ def __init__(self, name, parameters=''): # Kernel names use the 3x naming scheme: cutlass3x_sm100_tensorop_gemm_{dtypes}_{tile}_{cluster}_... # SIMT kernels (fp64/fp32/fp16) and fp64_tc are not generated for SM100 in CUTLASS v4.1.0. self.__kernel_map[10.0] = { - 'tf32_tc': 'cutlass3x_sm100_tensorop_gemm_tf32_*', + 'tf32_tc': 'cutlass3x_sm100_tensorop_tf32gemm_*', 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_*', 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_*', 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_*', - 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_*', + 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_*', + 'fp4_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_*', } self.__kernel_map[10.3] = dict(self.__kernel_map[10.0]) self.__parse_logline = [ @@ -75,10 +76,12 @@ def __init__(self, name, parameters=''): 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', # SM90 (Hopper) WGMMA kernels (3x naming: cutlass3x_sm90_tensorop_gemm_{dtype}_*) 'gemm,cutlass3x_sm90_tensorop_gemm_e4m3_', - # SM100 (Blackwell) UMMA kernels (3x naming: cutlass3x_sm100_tensorop_gemm_{dtype}_*) - 'gemm,cutlass3x_sm100_tensorop_gemm_tf32_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', + # SM100 (Blackwell) UMMA kernels + 'gemm,cutlass3x_sm100_tensorop_tf32gemm_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', - 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_', + 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_', + # SM100 (Blackwell) FP4 UMMA kernels (NVFP4 / MXFP4: e4m3 × e2m1) + 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_', ] def add_parser_arguments(self): diff --git a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py index 927e43b5a..d6c2a03eb 100644 --- a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py +++ b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py @@ -20,7 +20,8 @@ def __init__(self, name, parameters=''): super().__init__(name, parameters) self._support_precisions = [ - 'fp64', 'fp32', 'fp16', 'fp64_tc', 'tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc', 'int4_tc', 'fp8_tc' + 'fp64', 'fp32', 'fp16', 'fp64_tc', 'tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc', 'int4_tc', 'fp8_tc', + 'fp4_tc' ] self._precision_need_to_run = list() self._metric_map = { @@ -34,6 +35,7 @@ def __init__(self, name, parameters=''): 'int8_tc': 'int8_tc_iops', 'int4_tc': 'int4_tc_iops', 'fp8_tc': 'fp8_tc_flops', + 'fp4_tc': 'fp4_tc_flops', 'fp32_xdlops': 'fp32_xdlops_flops', 'fp16_xdlops': 'fp16_xdlops_flops', 'bf16_xdlops': 'bf16_xdlops_flops', diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 05fa2262b..a701c1c0c 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -118,9 +118,9 @@ def test_flops_performance_cuda_sm100(self): CSV Results: Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_tf32_tf32_f32_f32_f32_128x256x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.21,1072500 -1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_tf32_tf32_f32_f32_f32_256x128x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.45,1043800 -1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_tf32_tf32_f32_void_f32_128x256x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.10,1086300 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_tf32gemm_f32_f32_f32_f32_f32_128x256x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.21,1072500 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_tf32gemm_f32_f32_f32_f32_f32_256x128x32_1x2x1_0_ntn_align4_1sm,passed,success,universal,16384,16384,16384,8.45,1043800 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_tf32gemm_f32_f32_f32_f32_f32_128x256x32_1x2x1_0_ntn_align4_stream_k_1sm,passed,success,universal,16384,16384,16384,8.10,1086300 """ raw_output_bf16_tc = """ CSV Results: @@ -192,3 +192,32 @@ def test_flops_performance_cuda_fp8(self): assert (benchmark.result['fp8_tc_flops'][0] == 2317200) assert (benchmark.result['fp8_tc_flops'][1] == 5425400) + + @decorator.cuda_test + def test_flops_performance_cuda_fp4(self): + """Test gemm-flops benchmark FP4 (e4m3 x e2m1) kernel output parsing for SM100.""" + benchmark_name = 'gemm-flops' + (benchmark_class, + predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) + assert (benchmark_class) + + benchmark = benchmark_class(benchmark_name, parameters='--precision fp4_tc') + benchmark.add_parser_arguments() + ret, benchmark._args, _ = benchmark.parse_args() + assert ret + from superbench.benchmarks.result import BenchmarkResult + from superbench.benchmarks import BenchmarkType, ReturnCode + benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) + benchmark._precision_need_to_run = ['fp4_tc'] + + # SM100 Blackwell UMMA FP4 kernel: cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_{acc}_{c}_{d}_{tile}_... + raw_output_sm100_fp4 = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_64x128x128_0x0x1_0_tnt_align128_1sm,passed,success,universal,16384,16384,16384,1.05,8388600 +1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_64x128x128_2x1x1_0_tnt_align128_stream_k_1sm,passed,success,universal,16384,16384,16384,1.02,8627400 +""" + assert (benchmark._process_raw_result(0, raw_output_sm100_fp4)) + + assert (benchmark.result['fp4_tc_flops'][0] == 8627400) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index ee05d39f2..b50447786 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -40,12 +40,22 @@ CUTLASS_KERNELS_VOLTA := \ cutlass_tensorop_h884gemm_256x128_32x2_* # SM100 Blackwell 3x UMMA GEMM kernels +# On aarch64, kernel count must be kept under ~1000 per sub-group to avoid +# R_AARCH64_PREL32 relocation overflow. Use exact dtype patterns instead +# of broad wildcards (e.g. gemm_e4m3_e4m3_f32_f32_f32_* not gemm_e4m3_*) +# to exclude void-output, mixed-output, and e5m2/e3m2 input variants that +# the cutlass_profiler gemm-flops benchmark does not need. CUTLASS_KERNELS_SM100 := \ - cutlass3x_sm100_tensorop_tf32gemm*,\ - cutlass3x_sm100_tensorop_gemm_f16_*,\ - cutlass3x_sm100_tensorop_gemm_bf16_*,\ - cutlass3x_sm100_tensorop_gemm_s8_*,\ - cutlass3x_sm100_tensorop_gemm_e4m3_* + cutlass3x_sm100_tensorop_tf32gemm_f32_f32_f32_f32_f32_*,\ + cutlass3x_sm100_tensorop_gemm_f16_f16_f16_f16_f16_*,\ + cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f16_f16_*,\ + cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f32_f32_*,\ + cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16_*,\ + cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_f32_f32_*,\ + cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s32_s32_*,\ + cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8_*,\ + cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32_*,\ + cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_* # Strip spaces that Make inserts from the line-continuation backslashes. # Without this, cmake receives "cutlass_simt_dgemm..., cutlass_simt_sgemm..." @@ -121,12 +131,9 @@ endif # ----------------------------------------------------------------------- # Shared clone → patch → build → install pipeline # ----------------------------------------------------------------------- - # On aarch64, per-family shared libraries (e.g. libcutlass_gemm_sm100_f16_gemm_e4m3.so) - # can overflow R_AARCH64_PREL32 relocations in .eh_frame when thousands of FP8 - # kernel objects are linked into a single SO. Work around this by: - # - Building static libs only (avoids the SO link that overflows) - # - Suppressing unwind tables in generated kernel TUs (reduces .eh_frame) - # SuperBench only uses cutlass_profiler, which links statically, so no SO is needed. + # With the narrowed kernel filter (~3,900 objects, max ~614 per sub-group), + # shared per-family libraries stay under the R_AARCH64_PREL32 ±2 GB limit + # on aarch64. Unwind table suppression further reduces .eh_frame pressure. if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch $(CUTLASS_TAG) --depth 1 https://github.com/NVIDIA/cutlass.git $(CUTLASS_PATCHES) @@ -136,10 +143,10 @@ endif -DCUTLASS_NVCC_ARCHS=$(CUTLASS_ARCHS) \ -DCUTLASS_ENABLE_EXAMPLES=OFF \ -DCUTLASS_ENABLE_TESTS=OFF \ - -DCUTLASS_BUILD_SHARED_LIBS=OFF \ - -DCUTLASS_BUILD_STATIC_LIBS=ON \ - -DCMAKE_CXX_FLAGS="-fno-asynchronous-unwind-tables" \ - -DCMAKE_CUDA_FLAGS="--compiler-options=-fno-asynchronous-unwind-tables" \ + -DCUTLASS_BUILD_SHARED_LIBS=ON \ + -DCUTLASS_BUILD_STATIC_LIBS=OFF \ + -DCMAKE_CXX_FLAGS="-fno-asynchronous-unwind-tables -fno-unwind-tables" \ + -DCMAKE_CUDA_FLAGS="-Xcompiler=-fno-asynchronous-unwind-tables -Xcompiler=-fno-unwind-tables" \ -S ./cutlass \ -B ./cutlass/build \ "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNS)" From 5ceefe1b92ea15924a785de6ae58346f08d01d16 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 24 Apr 2026 04:39:43 +0000 Subject: [PATCH 16/30] Optimize CUTLASS kernel selection for peak-FLOPS benchmarking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Narrow both build-time and runtime kernel filters to reduce profiler execution time from ~7 hours to ~58 minutes while reliably measuring peak FLOPS across all 6 precisions on GB200/GB300. Build filter (cutlass.mk - CUTLASS_LIBRARY_KERNELS): - Drop redundant sub-groups that don't contribute to peak measurement: - f16_f16_f16_f16_f16 (FP16 accumulator, same throughput as FP32-accum) - f16_f16_f32_f32_f32 (FP32 output, redundant with FP16-output variant) - bf16_bf16_f32_f32_f32 (FP32 output, same as above for BF16) - s8_s8_s32_s32_s32 (INT32 output, canonical INT8 uses s8 output) - Reduces build from 10 patterns (~3,900 objects) to 6 patterns (~2,200) - Each per-family shared library sub-group stays well under the aarch64 R_AARCH64_PREL32 relocation limit (~1000 objects max) Runtime filter (cuda_gemm_flops_performance.py - --kernels): - Select only 256x256 tiles with stream_k scheduling and 2sm cooperative mode — the competitive subset for peak FLOPS at 16384x16384x16384 - Based on actual GB300 TF32 profiling data: the top 10 kernels are all 256x256 tiles, 2x2x1 cluster, stream_k, 2sm; all 8 layouts within 3% - ~56 kernels per precision (TF32/FP16/BF16/INT8/FP8) + 49 FP4 (all) - Total: ~329 kernels at ~10.5 sec each = ~58 minutes - Validated: top-performing TF32 kernel (1.02 PFLOPS) is included Pattern format uses cutlass_profiler's glob matching (split on '*', substring search in order): *tf32gemm*256x256x*stream_k_2sm matches both '...stream_k_2sm' and '...stream_k_2sm_epi_tma' FP4 (e4m3 x e2m1) keeps the broad wildcard since it only has ~49 kernels total — no runtime savings from filtering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../cuda_gemm_flops_performance.py | 19 +++++++++++-------- third_party/cutlass.mk | 18 +++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 6a74ab31f..4e34703fc 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -54,15 +54,18 @@ def __init__(self, name, parameters=''): self.__kernel_map[9.0] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} # FP8 (e4m3) on Hopper SM90: CUTLASS 3x WGMMA kernels (CUTLASS v3.9.2+). self.__kernel_map[9.0]['fp8_tc'] = 'cutlass3x_sm90_tensorop_gemm_e4m3_*' - # Blackwell (SM100/SM103): CUTLASS v4.1.0 GenerateSM100 only generates UMMA TensorOp kernels. - # Kernel names use the 3x naming scheme: cutlass3x_sm100_tensorop_gemm_{dtypes}_{tile}_{cluster}_... - # SIMT kernels (fp64/fp32/fp16) and fp64_tc are not generated for SM100 in CUTLASS v4.1.0. + # Blackwell (SM100/SM103): CUTLASS v4.3.5 UMMA TensorOp kernels. + # Runtime --kernels patterns select only 256x256 tiles with stream_k + # scheduling and 2sm cooperative mode — the competitive subset for peak + # FLOPS at 16384x16384x16384. This keeps profiler runtime under 1 hour + # (~56 kernels/precision × 5 + 49 FP4 ≈ 329 total ≈ 58 min). + # The build includes all tile/cluster/layout variants as a superset. self.__kernel_map[10.0] = { - 'tf32_tc': 'cutlass3x_sm100_tensorop_tf32gemm_*', - 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_*', - 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_*', - 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_*', - 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_*', + 'tf32_tc': 'cutlass3x_sm100_tensorop_tf32gemm*256x256x*stream_k_2sm', + 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16*256x256x*stream_k_2sm', + 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f16_f16*256x256x*stream_k_2sm', + 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8*256x256x*stream_k_2sm', + 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32*256x256x*stream_k_2sm', 'fp4_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_*', } self.__kernel_map[10.3] = dict(self.__kernel_map[10.0]) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index b50447786..9d78ee5a7 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -40,19 +40,19 @@ CUTLASS_KERNELS_VOLTA := \ cutlass_tensorop_h884gemm_256x128_32x2_* # SM100 Blackwell 3x UMMA GEMM kernels -# On aarch64, kernel count must be kept under ~1000 per sub-group to avoid -# R_AARCH64_PREL32 relocation overflow. Use exact dtype patterns instead -# of broad wildcards (e.g. gemm_e4m3_e4m3_f32_f32_f32_* not gemm_e4m3_*) -# to exclude void-output, mixed-output, and e5m2/e3m2 input variants that -# the cutlass_profiler gemm-flops benchmark does not need. +# Optimized for peak-FLOPS benchmarking on GB200/GB300: +# - Only large tiles (128x256, 256x128, 256x256) that are competitive at 16K³ +# - Only the canonical output type per precision (FP32-accum preferred) +# - FP4 kept in full (~49 kernels, small enough) +# - Keeps all cluster/layout/schedule variants per tile so the profiler +# can find the actual peak; runtime --kernels filtering in +# cuda_gemm_flops_performance.py further narrows to ~36/precision. +# On aarch64, each sub-group must stay under ~1000 objects to avoid +# R_AARCH64_PREL32 relocation overflow in per-family shared libraries. CUTLASS_KERNELS_SM100 := \ cutlass3x_sm100_tensorop_tf32gemm_f32_f32_f32_f32_f32_*,\ - cutlass3x_sm100_tensorop_gemm_f16_f16_f16_f16_f16_*,\ cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f16_f16_*,\ - cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f32_f32_*,\ cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16_*,\ - cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_f32_f32_*,\ - cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s32_s32_*,\ cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8_*,\ cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32_*,\ cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_* From 1cd982a58c85a83c74866ba7e78eae8c07b4c5bf Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 24 Apr 2026 06:15:28 +0000 Subject: [PATCH 17/30] Fix INT8/FP8 kernel patterns for Blackwell profiling INT8 and FP8 256x256 stream_k_2sm kernels (without epi_tma) fail at runtime on GB200/GB300, producing zero results and return code 32. This happens because INT8/FP8 use 128-byte K-tiles (vs 32 for TF32) which changes SMEM pressure and supported tile configurations. Fix: broaden INT8/FP8 runtime patterns from *256x256x*stream_k_2sm to *256x*stream_k_2sm* which matches: - 128x256, 256x128, 256x256 tiles (competitive for large GEMMs) - Both stream_k_2sm and stream_k_2sm_epi_tma scheduling - ~168 kernels each (failed kernels return in ~2 sec, not 10.5) TF32/BF16/FP16 keep 256x256-only (56 each) since their 32/64-byte K-tiles work well with 256x256 tiles. Also add trailing * to all patterns so stream_k_2sm matches both '_2sm' and '_2sm_epi_tma' variants consistently. Validated: test1.log shows TF32 (1.03 PFLOPS), BF16 (1.96 PFLOPS), FP16 (1.99 PFLOPS) all succeeded; INT8 failed with the old pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../cuda_gemm_flops_performance.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 4e34703fc..d865d67ff 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -55,17 +55,18 @@ def __init__(self, name, parameters=''): # FP8 (e4m3) on Hopper SM90: CUTLASS 3x WGMMA kernels (CUTLASS v3.9.2+). self.__kernel_map[9.0]['fp8_tc'] = 'cutlass3x_sm90_tensorop_gemm_e4m3_*' # Blackwell (SM100/SM103): CUTLASS v4.3.5 UMMA TensorOp kernels. - # Runtime --kernels patterns select only 256x256 tiles with stream_k - # scheduling and 2sm cooperative mode — the competitive subset for peak - # FLOPS at 16384x16384x16384. This keeps profiler runtime under 1 hour - # (~56 kernels/precision × 5 + 49 FP4 ≈ 329 total ≈ 58 min). - # The build includes all tile/cluster/layout variants as a superset. + # Runtime --kernels patterns select stream_k + 2sm kernels for peak FLOPS. + # TF32/FP16/BF16: 256x256 tiles only (best for 32/64-byte K-tiles). + # INT8/FP8: include 128x256 + 256x256 because their larger K-tile (128) + # changes optimal tile shape; 256x256 non-epi_tma may fail at runtime. + # FP4: all ~49 kernels (small enough). + # Trailing * after stream_k_2sm matches both _2sm and _2sm_epi_tma. self.__kernel_map[10.0] = { - 'tf32_tc': 'cutlass3x_sm100_tensorop_tf32gemm*256x256x*stream_k_2sm', - 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16*256x256x*stream_k_2sm', - 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f16_f16*256x256x*stream_k_2sm', - 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8*256x256x*stream_k_2sm', - 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32*256x256x*stream_k_2sm', + 'tf32_tc': 'cutlass3x_sm100_tensorop_tf32gemm*256x256x*stream_k_2sm*', + 'bf16_tc': 'cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16*256x256x*stream_k_2sm*', + 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f16_f16*256x256x*stream_k_2sm*', + 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8*256x*stream_k_2sm*', + 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32*256x*stream_k_2sm*', 'fp4_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_*', } self.__kernel_map[10.3] = dict(self.__kernel_map[10.0]) From 1128112ed0ab7f247be451c23e058daf27715a58 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 24 Apr 2026 18:13:23 +0000 Subject: [PATCH 18/30] Add /opt/superbench/lib to LD_LIBRARY_PATH in Dockerfile CUTLASS shared per-family libraries (libcutlass_gemm_sm100_*.so) are installed to /opt/superbench/lib by cmake -DCMAKE_INSTALL_LIBDIR, but the container's LD_LIBRARY_PATH did not include this path. This caused cutlass_profiler to fail at runtime with: libcutlass.so: cannot open shared object file: No such file or directory INT8, FP8, and FP4 precisions silently failed (return code 32) while TF32/BF16/FP16 appeared to work from a fallback static-linked subset. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/cuda13.0.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile/cuda13.0.dockerfile b/dockerfile/cuda13.0.dockerfile index 25fc7f9ed..7b7d0a728 100644 --- a/dockerfile/cuda13.0.dockerfile +++ b/dockerfile/cuda13.0.dockerfile @@ -134,7 +134,7 @@ RUN cd /tmp && \ make install ENV PATH="${PATH}" \ - LD_LIBRARY_PATH="/usr/local/lib:/usr/local/mpi/lib:${LD_LIBRARY_PATH}" \ + LD_LIBRARY_PATH="/usr/local/lib:/usr/local/mpi/lib:/opt/superbench/lib:${LD_LIBRARY_PATH}" \ SB_HOME=/opt/superbench \ SB_MICRO_PATH=/opt/superbench \ ANSIBLE_DEPRECATION_WARNINGS=FALSE \ From a909e8ee551658edd5c7b11e28dbc95d7b607814 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 24 Apr 2026 18:39:50 +0000 Subject: [PATCH 19/30] Fix INT8 handling: skip on SM103a (GB300), keep on SM100a (GB200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SM103a (GB300 Blackwell Ultra) does NOT support INT8 UMMA — the tcgen05.mma.kind::i8 instruction was removed in favor of doubled FP4/NVFP4 throughput. CuTe's config.hpp only defines CUTE_ARCH_TCGEN05_S8_MMA_ENABLED for SM100a/SM101a; SM103a is deliberately excluded. INT8 kernels compiled for SM103a contain a runtime trap (CUTE_INVALID_CONTROL_PATH) instead of real PTX. Previous sed patch removed the arch_family_cc gate entirely, which forced INT8 generation for all archs but produced broken SM103a cubins that fail at runtime with: 'Attempting to use SM100_MMA_S8_SS without CUTE_ARCH_TCGEN05_S8_MMA_ENABLED' Fix (two parts): 1. cutlass.mk: Change sed patch to remove only '103a' from the gate (not the entire gate). This preserves INT8 generation for SM100a (GB200) while the gate still blocks on '100f' and '101f' family binaries as CUTLASS intended. 2. cuda_gemm_flops_performance.py: Exclude 'int8_tc' from the SM10.3 kernel map so the profiler never attempts INT8 on GB300. This is the primary safety net — the SM103a cubin trap is a backup. Result: INT8 works on GB200 (SM100a), cleanly skipped on GB300 (SM103a). Verified by GPT-5.4 and Claude Opus 4.7 code review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../cuda_gemm_flops_performance.py | 5 +++- third_party/cutlass.mk | 23 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index d865d67ff..b3a2e3528 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -69,7 +69,10 @@ def __init__(self, name, parameters=''): 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32*256x*stream_k_2sm*', 'fp4_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_*', } - self.__kernel_map[10.3] = dict(self.__kernel_map[10.0]) + # SM103a (GB300 "Blackwell Ultra") lacks INT8 UMMA (tcgen05.mma.kind::i8). + # CuTe's config.hpp only defines CUTE_ARCH_TCGEN05_S8_MMA_ENABLED for + # SM100a/SM101a. INT8 kernels compiled for SM103a hit a runtime trap. + self.__kernel_map[10.3] = {k: v for k, v in self.__kernel_map[10.0].items() if k != 'int8_tc'} self.__parse_logline = [ # SM70/SM80 kernels (legacy 2x naming: cutlass_tensorop_*) 'gemm,cutlass_simt_dgemm_128x128_8x2', 'gemm,cutlass_simt_sgemm_128x128_8x2', diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 9d78ee5a7..db7025b5d 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -85,18 +85,23 @@ ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) # Arch tokens must use the "a" suffix; bare "100"/"103" do not trigger # Blackwell code generation in CUTLASS v4.3.5's generator.py. # - # CUTLASS gates int8 GEMM generation when 103a is in the arch list - # (arch_family_cc pruning heuristic). We patch that gate out because: - # 1. SM103 hardware fully supports tcgen05.mma.kind::i8 (0.165 POPS dense). - # 2. Generated int8 kernels use CC range [100, 110] (via ThorSMRenumbering), - # so CUTLASS runtime dispatches them on both SM100 and SM103. - # The gate is a dead-kernel pruning optimization for family-binary builds, - # not a hardware limitation. The sed patch only affects the two int8 gates - # in GenerateSM100(); no other code paths use arch_family_cc. + # SM103a (GB300 "Blackwell Ultra") does NOT support INT8 UMMA + # (tcgen05.mma.kind::i8) — CuTe's config.hpp only defines + # CUTE_ARCH_TCGEN05_S8_MMA_ENABLED for SM100a/SM101a. + # However, CUTLASS's generator.py gates INT8 generation when ANY + # of ['100f','101f','103a'] is in the arch list. Since we build + # with "100a;103a", the gate fires and skips INT8 for ALL archs + # — including SM100a (GB200) which DOES support INT8. + # Fix: remove only '103a' from the gate so INT8 is generated for + # SM100a. The SM103a cubin will compile INT8 with a runtime trap + # (CUTE_INVALID_CONTROL_PATH) but the SM100a cubin will work. + # On a GB300 the profiler will load the SM103a cubin and correctly + # report the kernel as "failed"; cuda_gemm_flops_performance.py + # excludes int8_tc from the SM10.3 kernel map so it is never run. $(eval CUTLASS_TAG := v4.3.5) $(eval CUTLASS_ARCHS := "100a;103a") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) - $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = []/" cutlass/python/cutlass_library/generator.py) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py) else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) # ----------------------------------------------------------------------- From f2b370ad751455e1ae641f9919c9fe9924347eea Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Mon, 27 Apr 2026 21:43:51 +0000 Subject: [PATCH 20/30] Replace mixed FP4 with true NVFP4 (block-scaled) for GB300 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fp4_tc metric used cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_* which is FP8(e4m3) x FP4(e2m1) mixed-precision GEMM. This kernel runs on the FP8 datapath (tcgen05.mma.kind=f8f6f4) at FP8 throughput regardless of operand width — narrowing one input to FP4 saves bandwidth but does NOT double the math throughput. Result: measured ~3.8 PFLOPS vs NVIDIA NVFP4 spec of 15 PFLOPS (25%). Both GPT-5.4 and Claude Opus 4.7 confirmed this was a wrong-kernel issue. Fix: switch to true NVFP4 via CUTLASS BlockScaledGemm operation kind. SM103a (GB300 Blackwell Ultra) has dedicated FP4 Ultra kernels: cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_*_ultra_2sm_* - ue4m3 = FP8 scale factor (NVFP4 spec) - vs16 = 16-element scale block (NVFP4 spec) - bstensorop = block-scaled tensor op - ultra_2sm = SM103-specific FP4 Ultra dual-CTA path Changes: 1. cutlass.mk: add bstensorop NVFP4 kernel patterns to build filter 2. cuda_gemm_flops_performance.py: - Replace 'fp4_tc' with 'nvfp4_tc' in SM10.3 kernel map - Use --operation=block_scaled_gemm (instead of gemm) for nvfp4_tc - Add parse_logline entry for block_scaled_gemm OperationKind 3. gemm_flops_performance_base.py: replace fp4_tc with nvfp4_tc precision 4. tests: replace test_flops_performance_cuda_fp4 with cuda_nvfp4 The mixed FP4 measurement is dropped entirely. cuBLASLt's fp4e2m1 benchmark already covers the production FP4 inference path. CLI verified: --operation=block_scaled_gemm works in cutlass_profiler. Kernel naming verified by inspecting CUTLASS v4.3.5 generator output. Validated by GPT-5.4 and Claude Opus 4.7 code review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../cuda_gemm_flops_performance.py | 25 +++++++++++++------ .../gemm_flops_performance_base.py | 4 +-- .../test_cuda_gemm_flops_performance.py | 22 ++++++++-------- third_party/cutlass.mk | 7 +++++- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index b3a2e3528..dd78b2e48 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -67,12 +67,18 @@ def __init__(self, name, parameters=''): 'fp16_tc': 'cutlass3x_sm100_tensorop_gemm_f16_f16_f32_f16_f16*256x256x*stream_k_2sm*', 'int8_tc': 'cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8*256x*stream_k_2sm*', 'fp8_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32*256x*stream_k_2sm*', - 'fp4_tc': 'cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_*', } - # SM103a (GB300 "Blackwell Ultra") lacks INT8 UMMA (tcgen05.mma.kind::i8). - # CuTe's config.hpp only defines CUTE_ARCH_TCGEN05_S8_MMA_ENABLED for - # SM100a/SM101a. INT8 kernels compiled for SM103a hit a runtime trap. + # SM103a (GB300 "Blackwell Ultra"): + # - Lacks INT8 UMMA (tcgen05.mma.kind::i8); CuTe's config.hpp only + # defines CUTE_ARCH_TCGEN05_S8_MMA_ENABLED for SM100a/SM101a. + # - Adds NVFP4 (block-scaled FP4) via the BlockScaledGemm operation. + # The FP4 Ultra path uses sm103-specific bstensorop kernels with + # ue4m3 scale factor and vs16 block size (NVFP4 spec). + # nvfp4_tc kernels are profiled with --operation=block_scaled_gemm + # (auto-detected from the kernel name prefix in _preprocess). self.__kernel_map[10.3] = {k: v for k, v in self.__kernel_map[10.0].items() if k != 'int8_tc'} + self.__kernel_map[10.3]['nvfp4_tc'] = \ + 'cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32*256x*ultra_2sm*' self.__parse_logline = [ # SM70/SM80 kernels (legacy 2x naming: cutlass_tensorop_*) 'gemm,cutlass_simt_dgemm_128x128_8x2', 'gemm,cutlass_simt_sgemm_128x128_8x2', @@ -87,8 +93,9 @@ def __init__(self, name, parameters=''): 'gemm,cutlass3x_sm100_tensorop_tf32gemm_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_', - # SM100 (Blackwell) FP4 UMMA kernels (NVFP4 / MXFP4: e4m3 × e2m1) - 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_', + # SM103 (Blackwell Ultra) NVFP4 block-scaled UMMA kernels + 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_', + 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_', ] def add_parser_arguments(self): @@ -123,7 +130,11 @@ def _preprocess(self): for p in self._precision_need_to_run: command = os.path.join(self._args.bin_dir, self._bin_name) command += (' --warmup-iterations=' + str(self._args.num_warmup)) - command += (' --operation=gemm') + # NVFP4 (and MXFP4) require the block_scaled_gemm operation kind + # in cutlass_profiler — they have separate kernel registries from + # the standard gemm operation. + operation = 'block_scaled_gemm' if p in ('nvfp4_tc', 'mxfp4_tc') else 'gemm' + command += (' --operation=' + operation) command += (' --n=' + str(self._args.n)) command += (' --k=' + str(self._args.k)) command += (' --m=' + str(self._args.m)) diff --git a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py index d6c2a03eb..f7a467bdc 100644 --- a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py +++ b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py @@ -21,7 +21,7 @@ def __init__(self, name, parameters=''): self._support_precisions = [ 'fp64', 'fp32', 'fp16', 'fp64_tc', 'tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc', 'int4_tc', 'fp8_tc', - 'fp4_tc' + 'nvfp4_tc' ] self._precision_need_to_run = list() self._metric_map = { @@ -35,7 +35,7 @@ def __init__(self, name, parameters=''): 'int8_tc': 'int8_tc_iops', 'int4_tc': 'int4_tc_iops', 'fp8_tc': 'fp8_tc_flops', - 'fp4_tc': 'fp4_tc_flops', + 'nvfp4_tc': 'nvfp4_tc_flops', 'fp32_xdlops': 'fp32_xdlops_flops', 'fp16_xdlops': 'fp16_xdlops_flops', 'bf16_xdlops': 'bf16_xdlops_flops', diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index a701c1c0c..d9cc641b5 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -194,30 +194,32 @@ def test_flops_performance_cuda_fp8(self): assert (benchmark.result['fp8_tc_flops'][1] == 5425400) @decorator.cuda_test - def test_flops_performance_cuda_fp4(self): - """Test gemm-flops benchmark FP4 (e4m3 x e2m1) kernel output parsing for SM100.""" + def test_flops_performance_cuda_nvfp4(self): + """Test gemm-flops benchmark NVFP4 (block-scaled FP4) kernel output parsing for SM103.""" benchmark_name = 'gemm-flops' (benchmark_class, predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) assert (benchmark_class) - benchmark = benchmark_class(benchmark_name, parameters='--precision fp4_tc') + benchmark = benchmark_class(benchmark_name, parameters='--precision nvfp4_tc') benchmark.add_parser_arguments() ret, benchmark._args, _ = benchmark.parse_args() assert ret from superbench.benchmarks.result import BenchmarkResult from superbench.benchmarks import BenchmarkType, ReturnCode benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) - benchmark._precision_need_to_run = ['fp4_tc'] + benchmark._precision_need_to_run = ['nvfp4_tc'] - # SM100 Blackwell UMMA FP4 kernel: cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_{acc}_{c}_{d}_{tile}_... - raw_output_sm100_fp4 = """ + # SM103 Blackwell Ultra NVFP4 block-scaled kernel: + # cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_{acc}_{c}_{d}_{tile}_..._ultra_2sm_* + # OperationKind is "block_scaled_gemm" (not "gemm"). + raw_output_sm103_nvfp4 = """ CSV Results: Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_64x128x128_0x0x1_0_tnt_align128_1sm,passed,success,universal,16384,16384,16384,1.05,8388600 -1,CUTLASS,gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_64x128x128_2x1x1_0_tnt_align128_stream_k_1sm,passed,success,universal,16384,16384,16384,1.02,8627400 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32_256x256x96_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_nopf_epi_nosmem,passed,success,universal,16384,16384,16384,0.55,15998700 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32_256x256x96_4x1x1_0_tnt_align32_o_vs16_ultra_2sm_tmapf_epi_nosmem,passed,success,universal,16384,16384,16384,0.53,16602100 """ - assert (benchmark._process_raw_result(0, raw_output_sm100_fp4)) + assert (benchmark._process_raw_result(0, raw_output_sm103_nvfp4)) - assert (benchmark.result['fp4_tc_flops'][0] == 8627400) + assert (benchmark.result['nvfp4_tc_flops'][0] == 16602100) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index db7025b5d..0e54e96c2 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -44,6 +44,10 @@ CUTLASS_KERNELS_VOLTA := \ # - Only large tiles (128x256, 256x128, 256x256) that are competitive at 16K³ # - Only the canonical output type per precision (FP32-accum preferred) # - FP4 kept in full (~49 kernels, small enough) +# - Block-scaled NVFP4 (true FP4 peak) added separately for SM103a (GB300) +# via the BlockScaledGemm operation kind. The FP4 Ultra path uses +# cutlass3x_sm103_bstensorop_gemm_ue4m3x*_ultra_* kernels (ue4m3 scale, +# vs16 = NVFP4 16-element block). # - Keeps all cluster/layout/schedule variants per tile so the profiler # can find the actual peak; runtime --kernels filtering in # cuda_gemm_flops_performance.py further narrows to ~36/precision. @@ -55,7 +59,8 @@ CUTLASS_KERNELS_SM100 := \ cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16_*,\ cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8_*,\ cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32_*,\ - cutlass3x_sm100_tensorop_gemm_e4m3_e2m1_f32_f32_f32_* + cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32_*ultra_2sm*,\ + cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_ue4m3xf4_f32_f32_f32_*ultra_2sm* # Strip spaces that Make inserts from the line-continuation backslashes. # Without this, cmake receives "cutlass_simt_dgemm..., cutlass_simt_sgemm..." From 2bb72e85c2413cbbdd7199c05a7a8f35d40dcb14 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 14 Oct 2026 19:56:52 +0000 Subject: [PATCH 21/30] Build: CUTLASS - move CUDA 13.4 (SM107) to its own top-level tier in cutlass.mk --- third_party/cutlass.mk | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 2a72f9ee0..3232b8f64 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -83,7 +83,17 @@ space := $(subst ,, ) .PHONY: cuda_cutlass cuda_cutlass: -ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) +ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) + # ----------------------------------------------------------------------- + # Blackwell GB200 (SM100a) + GB300 (SM103a) + SM107 — CUTLASS v4.3.5 + # ----------------------------------------------------------------------- + # SM107 runs the legacy SM80 kernels; see the 12.9 tier for the generator patch. + $(eval CUTLASS_TAG := v4.3.5) + $(eval CUTLASS_ARCHS := "100a;103a;107") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100)),$(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY))) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py) + +else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) # ----------------------------------------------------------------------- # Blackwell GB200 (SM100a) + GB300 (SM103a) — CUTLASS v4.3.5 # ----------------------------------------------------------------------- @@ -107,11 +117,6 @@ ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) $(eval CUTLASS_ARCHS := "100a;103a") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py) -ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) - # SM107 (CUDA 13.4+) uses the legacy SM80 kernels, compiled for plain sm_107. - $(eval CUTLASS_ARCHS := "100a;103a;107") - $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100)),$(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY))) -endif else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) # ----------------------------------------------------------------------- From 6876cc48392714487093c5dba7c1ec564beaaf02 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Wed, 14 Oct 2026 23:19:48 +0000 Subject: [PATCH 22/30] Fix NVFP4 kernel patterns to match CUTLASS v4.3.5 names (f32_void_f32) --- .../micro_benchmarks/cuda_gemm_flops_performance.py | 2 +- .../test_cuda_gemm_flops_performance.py | 12 +++++++++--- third_party/cutlass.mk | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 838bfca9a..fff37499f 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -78,7 +78,7 @@ def __init__(self, name, parameters=''): # (auto-detected from the kernel name prefix in _preprocess). self.__kernel_map[10.3] = {k: v for k, v in self.__kernel_map[10.0].items() if k != 'int8_tc'} self.__kernel_map[10.3]['nvfp4_tc'] = \ - 'cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32*256x*ultra_2sm*' + 'cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32*256x*ultra_2sm*' # SM107 (CUDA 13.4+) runs the legacy SM80 kernels; cutlass.mk builds them for sm_107. self.__kernel_map[10.7] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} self.__parse_logline = [ diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index bf9eb78db..23a5b2a6d 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -3,6 +3,7 @@ """Tests for gemm-flops benchmark.""" +import fnmatch import unittest from unittest import mock @@ -196,7 +197,7 @@ def test_flops_performance_cuda_fp8(self): @decorator.cuda_test def test_flops_performance_cuda_nvfp4(self): - """Test gemm-flops benchmark NVFP4 (block-scaled FP4) kernel output parsing for SM103.""" + """Test gemm-flops benchmark NVFP4 (block-scaled FP4) kernel selection and output parsing for SM103.""" benchmark_name = 'gemm-flops' (benchmark_class, predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) @@ -218,9 +219,14 @@ def test_flops_performance_cuda_nvfp4(self): CSV Results: Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32_256x256x96_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_nopf_epi_nosmem,passed,success,universal,16384,16384,16384,0.55,15998700 -1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32_256x256x96_4x1x1_0_tnt_align32_o_vs16_ultra_2sm_tmapf_epi_nosmem,passed,success,universal,16384,16384,16384,0.53,16602100 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x768_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_nopf_epi_nosmem,passed,success,universal,16384,16384,16384,0.55,15998700 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x768_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_tmapf_epi_nosmem,passed,success,universal,16384,16384,16384,0.53,16602100 """ + # The SM10.3 --kernels pattern must select these real CUTLASS v4.3.5 names (matched like '*pattern*'). + pattern = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.3]['nvfp4_tc'] + names = [line.split(',')[3] for line in raw_output_sm103_nvfp4.splitlines() if line.startswith('1,')] + assert (names and all(fnmatch.fnmatchcase(name, '*' + pattern + '*') for name in names)) + assert (benchmark._process_raw_result(0, raw_output_sm103_nvfp4)) assert (benchmark.result['nvfp4_tc_flops'][0] == 16602100) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 3232b8f64..5e0b55e34 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -47,7 +47,8 @@ CUTLASS_KERNELS_VOLTA := \ # - Block-scaled NVFP4 (true FP4 peak) added separately for SM103a (GB300) # via the BlockScaledGemm operation kind. The FP4 Ultra path uses # cutlass3x_sm103_bstensorop_gemm_ue4m3x*_ultra_* kernels (ue4m3 scale, -# vs16 = NVFP4 16-element block). +# vs16 = NVFP4 16-element block). They have no f32 C operand, so the +# f32-output variant is named f32_void_f32 (accumulator_C_D). # - Keeps all cluster/layout/schedule variants per tile so the profiler # can find the actual peak; runtime --kernels filtering in # cuda_gemm_flops_performance.py further narrows to ~36/precision. @@ -59,8 +60,8 @@ CUTLASS_KERNELS_SM100 := \ cutlass3x_sm100_tensorop_gemm_bf16_bf16_f32_bf16_bf16_*,\ cutlass3x_sm100_tensorop_gemm_s8_s8_s32_s8_s8_*,\ cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_f32_f32_f32_*,\ - cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_f32_f32_*ultra_2sm*,\ - cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_ue4m3xf4_f32_f32_f32_*ultra_2sm* + cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_*ultra_2sm*,\ + cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_ue4m3xf4_f32_void_f32_*ultra_2sm* # Strip spaces that Make inserts from the line-continuation backslashes. # Without this, cmake receives "cutlass_simt_dgemm..., cutlass_simt_sgemm..." From 8ed5aa6fd8c98ff496abf95cfa691de85eb4a69c Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 15 Oct 2026 17:01:29 +0000 Subject: [PATCH 23/30] Build: CUTLASS - upgrade CUDA 13.4 tier to v4.8.0 with a separate Rubin (SM107a) install CUTLASS v4.8.0 is the first release with SM107. When any 107 arch is in the build, its generator retargets the SM100 generators to SM107, so the SM100 kernels disappear from that build, and cutlass_profiler only runs kernels from its own libcutlass.so. The CUDA 13.4 tier now builds one v4.8.0 clone twice: - "100a;103a" -> $SB_MICRO_PATH/{bin,lib} (GB200/GB300, same kernel names as v4.3.5) - "107a" -> $SB_MICRO_PATH/cutlass_sm107/{bin,lib} (Rubin) The v4.8.0 INT8 gate is ['100f', '101f', '103a', '107f']; the patch drops '103a' as before and a grep fails the build if it no longer applies. gemm-flops on CC 10.7 no longer aliases the Ampere (SM80) kernels: - TF32/FP16/BF16: SM100 generators retargeted to Sm107 (stream-K 2SM 256x256) - FP8: native SM107 runtime-typed f8 kernels with B-reuse schedules, launched with --runtime_input_datatype_a/b=e4m3 - NVFP4: native SM107 block-scaled e2m1/ue4m3 vs16 kernels - INT8 is not offered: SM107a has no tcgen05 kind::i8 MMA (the generated kernel compiles without any tensor-core MMA) On CC 10.7 the profiler is taken from cutlass_sm107/bin and its lib folder is put first in LD_LIBRARY_PATH, since LD_LIBRARY_PATH outranks the profiler's RUNPATH and both installs ship a libcutlass.so. An explicit --bin_dir still wins. --- dockerfile/cuda13.4.dockerfile | 2 + .../cuda_gemm_flops_performance.py | 49 +++++-- .../test_cuda_gemm_flops_performance.py | 125 +++++++++++++++++- third_party/cutlass.mk | 87 ++++++++---- 4 files changed, 222 insertions(+), 41 deletions(-) diff --git a/dockerfile/cuda13.4.dockerfile b/dockerfile/cuda13.4.dockerfile index 62cadf01d..0b54e489a 100644 --- a/dockerfile/cuda13.4.dockerfile +++ b/dockerfile/cuda13.4.dockerfile @@ -64,6 +64,8 @@ FROM nvcr.io/nvidia/pytorch:26.09-py3 # - This machine is aarch64 (ARM). cpu_hpl, Intel MLC, AOCC and AMD BLIS auto-skip on aarch64. # - CUDA 13.4 builds the in-tree CUDA benchmarks, CUTLASS, NVBench, # cuBLASLt and NCCL tests for sm_107. +# - CUTLASS v4.8.0 is installed twice: GB200/GB300 into ${SB_MICRO_PATH}/{bin,lib} +# and Rubin (sm_107a) into ${SB_MICRO_PATH}/cutlass_sm107/{bin,lib}. # - streamOlympus is built with GCC 15 in the stream-olympus-builder stage above. # # Build (from repo root), e.g.: diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index fff37499f..641d94737 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -54,7 +54,7 @@ def __init__(self, name, parameters=''): self.__kernel_map[9.0] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} # FP8 (e4m3) on Hopper SM90: CUTLASS 3x WGMMA kernels (CUTLASS v3.9.2+). self.__kernel_map[9.0]['fp8_tc'] = 'cutlass3x_sm90_tensorop_gemm_e4m3_*' - # Blackwell (SM100/SM103): CUTLASS v4.3.5 UMMA TensorOp kernels. + # Blackwell (SM100/SM103): CUTLASS v4.3.5 (v4.8.0 with CUDA 13.4+) UMMA TensorOp kernels. # Runtime --kernels patterns select stream_k + 2sm kernels for peak FLOPS. # TF32/FP16/BF16: 256x256 tiles only (best for 32/64-byte K-tiles). # INT8/FP8: include 128x256 + 256x256 because their larger K-tile (128) @@ -79,25 +79,36 @@ def __init__(self, name, parameters=''): self.__kernel_map[10.3] = {k: v for k, v in self.__kernel_map[10.0].items() if k != 'int8_tc'} self.__kernel_map[10.3]['nvfp4_tc'] = \ 'cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32*256x*ultra_2sm*' - # SM107 (CUDA 13.4+) runs the legacy SM80 kernels; cutlass.mk builds them for sm_107. - self.__kernel_map[10.7] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} + # Rubin SM107a: CUTLASS v4.8.0 kernels from the separate cutlass_sm107 install (third_party/cutlass.mk). + # - TF32/FP16/BF16: SM100 generators retargeted to Sm107, selected like SM100. + # - FP8/NVFP4: native SM107 kernels (B-reuse schedules, no stream-K), N=256 2SM tiles. + # - No INT8: CuTe enables tcgen05 kind::i8 only for SM100a/SM101a/SM110. + self.__kernel_map[10.7] = { + 'tf32_tc': 'cutlass3x_sm107_tensorop_tf32gemm*256x256x*stream_k_2sm*', + 'bf16_tc': 'cutlass3x_sm107_tensorop_gemm_bf16_bf16_f32_bf16_bf16*256x256x*stream_k_2sm*', + 'fp16_tc': 'cutlass3x_sm107_tensorop_gemm_f16_f16_f32_f16_f16*256x256x*stream_k_2sm*', + 'fp8_tc': 'cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32*x256x128_*breuse_2sm*', + 'nvfp4_tc': + 'cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32*x256x256_*o_vs16_*breuse_2sm*', + } + # Compute capabilities whose CUTLASS build lives in its own SB_MICRO_PATH subfolder. + self.__cutlass_subdir = {10.7: 'cutlass_sm107'} + self.__capability = None + # ',' of CSV rows to parse: legacy SM70/SM80, SM90, SM100, SM103, SM107. self.__parse_logline = [ - # SM70/SM80 kernels (legacy 2x naming: cutlass_tensorop_*) 'gemm,cutlass_simt_dgemm_128x128_8x2', 'gemm,cutlass_simt_sgemm_128x128_8x2', 'gemm,cutlass_simt_hgemm_256x128_8x2', 'gemm,cutlass_tensorop_d884gemm_128x128_16x3', 'gemm,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3', 'gemm,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3', 'gemm,cutlass_tensorop_h16816gemm_256x128_32x3', 'gemm,cutlass_tensorop_h884gemm_256x128_32x2', 'gemm,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3', - 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', - # SM90 (Hopper) WGMMA kernels (3x naming: cutlass3x_sm90_tensorop_gemm_{dtype}_*) - 'gemm,cutlass3x_sm90_tensorop_gemm_e4m3_', - # SM100 (Blackwell) UMMA kernels + 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', 'gemm,cutlass3x_sm90_tensorop_gemm_e4m3_', 'gemm,cutlass3x_sm100_tensorop_tf32gemm_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_', - # SM103 (Blackwell Ultra) NVFP4 block-scaled UMMA kernels 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_', - 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_', + 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_', 'gemm,cutlass3x_sm107_tensorop_tf32gemm_', + 'gemm,cutlass3x_sm107_tensorop_gemm_f16_', 'gemm,cutlass3x_sm107_tensorop_gemm_bf16_', + 'gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_', 'block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_' ] def add_parser_arguments(self): @@ -123,6 +134,7 @@ def _preprocess(self): ) return False + self.__capability = capability self._support_precisions = list(self.__kernel_map[capability].keys()) # 'support_precisions' are precise only after getting capability, # and then using super.preprocess() to check if the precision in arguments are supported to run @@ -141,10 +153,27 @@ def _preprocess(self): command += (' --k=' + str(self._args.k)) command += (' --m=' + str(self._args.m)) command += (' --kernels=' + self.__kernel_map[capability][p]) + # Runtime-typed FP8 kernels ("f8" elements) take the A/B type at launch. + if '_f8_f8_' in self.__kernel_map[capability][p]: + command += ' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3' self._commands.append(command) return True + def _set_binary_path(self): + """Search cutlass_profiler in the per-architecture CUTLASS install unless --bin_dir is given. + + Return: + True if the binary exists. + """ + subdir = self.__cutlass_subdir.get(self.__capability) + if subdir and self._args.bin_dir is None and os.getenv('SB_MICRO_PATH'): + prefix = os.path.join(os.getenv('SB_MICRO_PATH'), subdir) + self._args.bin_dir = os.path.join(prefix, 'bin') + # LD_LIBRARY_PATH outranks RUNPATH, so put this build's libcutlass*.so ahead of SB_MICRO_PATH/lib. + os.environ['LD_LIBRARY_PATH'] = os.path.join(prefix, 'lib') + os.pathsep + os.getenv('LD_LIBRARY_PATH', '') + return super()._set_binary_path() + def _process_raw_result(self, cmd_idx, raw_output): """Function to parse raw results and save the summarized results. diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 23a5b2a6d..64ab24b97 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -4,6 +4,7 @@ """Tests for gemm-flops benchmark.""" import fnmatch +import os import unittest from unittest import mock @@ -20,7 +21,7 @@ def setUpClass(cls): """Hook method for setting up class fixture before running tests in the class.""" super().setUpClass() cls.createMockEnvs(cls) - cls.createMockFiles(cls, ['bin/cutlass_profiler']) + cls.createMockFiles(cls, ['bin/cutlass_profiler', 'cutlass_sm107/bin/cutlass_profiler']) @decorator.cuda_test def test_flops_performance_cuda(self): @@ -231,16 +232,126 @@ def test_flops_performance_cuda_nvfp4(self): assert (benchmark.result['nvfp4_tc_flops'][0] == 16602100) - def test_flops_performance_cuda_sm107(self): - """Test gemm-flops benchmark selects kernels for compute capability 10.7.""" + def test_flops_performance_cuda_sm107_kernels(self): + """Test gemm-flops benchmark selects native SM107 (Rubin) kernels and parses their output.""" benchmark_name = 'gemm-flops' (benchmark_class, predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) assert (benchmark_class) - benchmark = benchmark_class(benchmark_name, parameters='--precision fp32 fp16_tc') - assert (10.7 in benchmark._CudaGemmFlopsBenchmark__kernel_map) + precisions = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'fp8_tc', 'nvfp4_tc'] + benchmark = benchmark_class(benchmark_name, parameters='--precision ' + ' '.join(precisions)) + kernel_map = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.7] + assert (sorted(kernel_map) == sorted(precisions)) + # No legacy SM80 (Ampere) selectors on the Rubin performance path. + assert (all(pattern.startswith('cutlass3x_sm107_') for pattern in kernel_map.values())) + benchmark.add_parser_arguments() + ret, benchmark._args, _ = benchmark.parse_args() + assert ret + from superbench.benchmarks.result import BenchmarkResult + benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) + benchmark._precision_need_to_run = precisions + + # Kernel names from CUTLASS v4.8.0 generated for "107a"; FP8 and NVFP4 are native SM107 B-reuse kernels. + raw_output_tf32_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_tf32gemm_f32_f32_f32_f32_f32_256x256x32_0x0x1_0_ntn_align4_stream_k_2sm,passed,success,universal,16384,16384,16384,8.0,1100000 +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_tf32gemm_f32_f32_f32_f32_f32_256x256x32_4x4x1_0_tnn_align4_stream_k_2sm,passed,success,universal,16384,16384,16384,8.8,1000000 +""" + raw_output_bf16_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_bf16_bf16_f32_bf16_bf16_256x256x64_0x0x1_0_ntn_align8_stream_k_2sm,passed,success,universal,16384,16384,16384,4.4,2000000 +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_bf16_bf16_f32_bf16_bf16_256x256x64_4x4x1_0_tnn_align8_stream_k_2sm,passed,success,universal,16384,16384,16384,4.2,2100000 +""" + raw_output_fp16_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_f16_f16_f32_f16_f16_256x256x64_0x0x1_0_ntn_align8_stream_k_2sm,passed,success,universal,16384,16384,16384,4.2,2100000 +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_f16_f16_f32_f16_f16_256x256x64_4x4x1_0_tnn_align8_stream_k_2sm,passed,success,universal,16384,16384,16384,4.0,2200000 +""" + raw_output_fp8_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_256x256x128_0x0x1_0_ntn_align16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.2,4000000 +1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_512x256x128_4x4x1_0_tnn_align16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.0,4400000 +""" + raw_output_nvfp4_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,14000000 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,16000000 +""" + raw_outputs = [ + raw_output_tf32_tc, raw_output_bf16_tc, raw_output_fp16_tc, raw_output_fp8_tc, raw_output_nvfp4_tc + ] + for idx, raw_output in enumerate(raw_outputs): + # The --kernels pattern must select the real names (matched like '*pattern*'). + pattern = kernel_map[precisions[idx]] + names = [line.split(',')[3] for line in raw_output.splitlines() if line.startswith('1,')] + assert (names and all(fnmatch.fnmatchcase(name, '*' + pattern + '*') for name in names)) + assert (benchmark._process_raw_result(idx, raw_output)) + + assert (benchmark.result['tf32_tc_flops'][0] == 1100000) + assert (benchmark.result['bf16_tc_flops'][0] == 2100000) + assert (benchmark.result['fp16_tc_flops'][0] == 2200000) + assert (benchmark.result['fp8_tc_flops'][0] == 4400000) + assert (benchmark.result['nvfp4_tc_flops'][0] == 16000000) + + # Retargeted SM100-style FP8/NVFP4, 1SM, vs32 and MXFP4 (ue8m0) kernels are not selected. + unselected = """ +fp8_tc,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_256x256x128_0x0x1_0_ntn_align16_stream_k_2sm +fp8_tc,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_256x256x128_0x0x1_0_ntn_align16_breuse_1sm +nvfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_2sm +nvfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma +nvfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma +""" + for line in unselected.split(): + precision, name = line.split(',') + assert (not fnmatch.fnmatchcase(name, '*' + kernel_map[precision] + '*')) + + def test_flops_performance_cuda_sm107_commands(self): + """Test gemm-flops benchmark runs the cutlass_sm107 install on Rubin and skips unsupported precisions.""" + benchmark_name = 'gemm-flops' + (benchmark_class, + predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) + assert (benchmark_class) + + prefix = os.path.join(self._tmp_dir, 'cutlass_sm107') with mock.patch.object(dm.device_manager, 'get_device_compute_capability', return_value=10.7): - assert (benchmark._preprocess() is True) - assert (benchmark.return_code == ReturnCode.SUCCESS) + with mock.patch.dict(os.environ): + benchmark = benchmark_class( + benchmark_name, parameters='--precision tf32_tc fp8_tc nvfp4_tc int8_tc int4_tc' + ) + assert (benchmark._preprocess() is True) + assert (os.environ['LD_LIBRARY_PATH'].split(os.pathsep)[0] == os.path.join(prefix, 'lib')) + assert (benchmark.return_code == ReturnCode.SUCCESS) + # SM107 has no INT8/INT4 kernels, so they are skipped. + assert (benchmark._precision_need_to_run == ['tf32_tc', 'fp8_tc', 'nvfp4_tc']) + assert (benchmark._args.bin_dir == os.path.join(prefix, 'bin')) + kernel_map = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.7] + tf32_cmd, fp8_cmd, nvfp4_cmd = benchmark._commands + assert (tf32_cmd.startswith(os.path.join(prefix, 'bin', 'cutlass_profiler') + ' ')) + assert ('--operation=gemm ' in tf32_cmd and tf32_cmd.endswith(' --kernels=' + kernel_map['tf32_tc'])) + assert ('--operation=gemm ' in fp8_cmd) + assert (fp8_cmd.endswith(' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3')) + assert ('--operation=block_scaled_gemm ' in nvfp4_cmd and 'runtime_input_datatype' not in nvfp4_cmd) + + with mock.patch.dict(os.environ): + benchmark = benchmark_class(benchmark_name, parameters='--precision int8_tc') + assert (benchmark._preprocess() is False) + assert (benchmark.return_code == ReturnCode.NO_SUPPORTED_PRECISION) + + # An explicit --bin_dir takes precedence over the per-architecture install. + bin_dir = os.path.join(self._tmp_dir, 'bin') + with mock.patch.dict(os.environ): + benchmark = benchmark_class(benchmark_name, parameters='--precision fp16_tc --bin_dir ' + bin_dir) + assert (benchmark._preprocess() is True) + assert (benchmark._args.bin_dir == bin_dir) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 5e0b55e34..d0dfc16a4 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -15,6 +15,8 @@ # SM90/100+ (3x) : cutlass3x_sm{arch}_tensorop_{core_name}_{dtype}_* # Note: TF32 kernels use "tf32gemm" (intermediate type before "gemm"), # e.g. cutlass3x_sm100_tensorop_tf32gemm_f32_f32_* +# "f8"/"f4" element names mark runtime-typed kernels; the profiler takes the +# actual type from --runtime_input_datatype_a/b. # # --------------------------------------------------------------------------- # Shared kernel lists (reusable fragments) @@ -63,12 +65,49 @@ CUTLASS_KERNELS_SM100 := \ cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_*ultra_2sm*,\ cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_ue4m3xf4_f32_void_f32_*ultra_2sm* +# SM107 Rubin 3x UMMA GEMM kernels (CUTLASS v4.8.0, "107a" build only) +# - TF32/FP16/BF16: CUTLASS has no native SM107 generator; it retargets the +# SM100 generators to Sm107 when a 107 arch is built, so the names match +# the SM100 list with sm107. +# - FP8 and NVFP4: native SM107 kernels (Rubin MMA shapes with B-matrix +# reuse schedules). Only native names contain "breuse" (or "no_breuse"). +# The FP8 ones are runtime-typed (f8_f8). NVFP4 = e2m1 with ue4m3 scale +# and 16-element blocks (vs16). +# - No INT8: CuTe enables tcgen05 kind::i8 only for SM100a/SM101a/SM110. +CUTLASS_KERNELS_SM107 := \ + cutlass3x_sm107_tensorop_tf32gemm_f32_f32_f32_f32_f32_*,\ + cutlass3x_sm107_tensorop_gemm_f16_f16_f32_f16_f16_*,\ + cutlass3x_sm107_tensorop_gemm_bf16_bf16_f32_bf16_bf16_*,\ + cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_*breuse_*,\ + cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_*_o_vs16_*breuse_* + +# Install prefix of the Rubin build; cuda_gemm_flops_performance.py uses it for CC 10.7. +CUTLASS_SM107_PREFIX = $(SB_MICRO_PATH)/cutlass_sm107 + # Strip spaces that Make inserts from the line-continuation backslashes. # Without this, cmake receives "cutlass_simt_dgemm..., cutlass_simt_sgemm..." # (note the space after each comma) which breaks CUTLASS's kernel filter. _strip_spaces = $(subst $(space),,$1) space := $(subst ,, ) +# $(call cutlass_build,,,,) +# Configures, builds and installs ./cutlass into /{bin,lib}. +cutlass_build = cmake -DCMAKE_INSTALL_BINDIR=$(3)/bin \ + -DCMAKE_INSTALL_LIBDIR=$(3)/lib \ + -DCMAKE_BUILD_TYPE=Release \ + -DCUTLASS_NVCC_ARCHS=$(1) \ + -DCUTLASS_ENABLE_EXAMPLES=OFF \ + -DCUTLASS_ENABLE_TESTS=OFF \ + -DCUTLASS_BUILD_SHARED_LIBS=ON \ + -DCUTLASS_BUILD_STATIC_LIBS=OFF \ + -DCMAKE_CXX_FLAGS="-fno-asynchronous-unwind-tables -fno-unwind-tables" \ + -DCMAKE_CUDA_FLAGS="-Xcompiler=-fno-asynchronous-unwind-tables -Xcompiler=-fno-unwind-tables" \ + -S ./cutlass \ + -B $(4) \ + "-DCUTLASS_LIBRARY_KERNELS=$(2)" && \ + cmake --build $(4) -j $(NUM_MAKE_JOBS) --target install && \ + rm -rf $(4) + # --------------------------------------------------------------------------- # cuda_cutlass target # --------------------------------------------------------------------------- @@ -77,6 +116,8 @@ space := $(subst ,, ) # CUTLASS_ARCHS — semicolon-separated NVCC arch list # CUTLASS_KERNS — comma-separated kernel filter patterns # CUTLASS_PATCHES — optional post-clone fixups (sed commands, etc.) +# CUTLASS_SM107_KERNS — optional Rubin kernel filter; when set, a second +# "107a" build is installed into $(CUTLASS_SM107_PREFIX) # # After the version-specific block, a shared section clones, patches, # configures, builds, and installs. @@ -86,13 +127,23 @@ space := $(subst ,, ) cuda_cutlass: ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) # ----------------------------------------------------------------------- - # Blackwell GB200 (SM100a) + GB300 (SM103a) + SM107 — CUTLASS v4.3.5 + # Blackwell GB200/GB300 + Rubin (SM107a) — CUTLASS v4.8.0, two folders # ----------------------------------------------------------------------- - # SM107 runs the legacy SM80 kernels; see the 12.9 tier for the generator patch. - $(eval CUTLASS_TAG := v4.3.5) - $(eval CUTLASS_ARCHS := "100a;103a;107") - $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100)),$(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY))) - $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py) + # v4.8.0 is the first release with SM107. With any 107 arch in the list, + # it retargets the SM100 generators to SM107 (generator.py + # resolve_sm10x_arch_range), so the SM100 kernels disappear from that build. + # cutlass_profiler only runs kernels from its own libcutlass.so, so one + # clone is built twice into separate folders: + # - "100a;103a" -> $(SB_MICRO_PATH)/{bin,lib} (GB200, GB300) + # - "107a" -> $(CUTLASS_SM107_PREFIX)/{bin,lib} (Rubin) + # v4.8.0 extended the INT8 gate to ['100f', '101f', '103a', '107f']. + # Dropping '103a' keeps SM100a INT8 as in the 12.9 tier; the grep stops + # the build if the patch no longer applies. + $(eval CUTLASS_TAG := v4.8.0) + $(eval CUTLASS_ARCHS := "100a;103a") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a', '107f'\]/arch_family_cc = ['100f', '101f', '107f']/" cutlass/python/cutlass_library/generator.py && grep -q "arch_family_cc = \['100f', '101f', '107f'\]" cutlass/python/cutlass_library/generator.py) + $(eval CUTLASS_SM107_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM107))) else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) # ----------------------------------------------------------------------- @@ -152,24 +203,12 @@ endif # ----------------------------------------------------------------------- # Shared clone → patch → build → install pipeline # ----------------------------------------------------------------------- - # With the narrowed kernel filter (~3,900 objects, max ~614 per sub-group), - # shared per-family libraries stay under the R_AARCH64_PREL32 ±2 GB limit - # on aarch64. Unwind table suppression further reduces .eh_frame pressure. + # With the narrowed kernel filters (Blackwell ~3,800 objects, Rubin ~2,700; + # max ~840 per sub-group), shared per-family libraries stay under the + # R_AARCH64_PREL32 ±2 GB limit on aarch64. Unwind table suppression + # further reduces .eh_frame pressure. if [ -d cutlass ]; then rm -rf cutlass; fi git clone --branch $(CUTLASS_TAG) --depth 1 https://github.com/NVIDIA/cutlass.git $(CUTLASS_PATCHES) - cmake -DCMAKE_INSTALL_BINDIR=$(SB_MICRO_PATH)/bin \ - -DCMAKE_INSTALL_LIBDIR=$(SB_MICRO_PATH)/lib \ - -DCMAKE_BUILD_TYPE=Release \ - -DCUTLASS_NVCC_ARCHS=$(CUTLASS_ARCHS) \ - -DCUTLASS_ENABLE_EXAMPLES=OFF \ - -DCUTLASS_ENABLE_TESTS=OFF \ - -DCUTLASS_BUILD_SHARED_LIBS=ON \ - -DCUTLASS_BUILD_STATIC_LIBS=OFF \ - -DCMAKE_CXX_FLAGS="-fno-asynchronous-unwind-tables -fno-unwind-tables" \ - -DCMAKE_CUDA_FLAGS="-Xcompiler=-fno-asynchronous-unwind-tables -Xcompiler=-fno-unwind-tables" \ - -S ./cutlass \ - -B ./cutlass/build \ - "-DCUTLASS_LIBRARY_KERNELS=$(CUTLASS_KERNS)" - cmake --build ./cutlass/build -j $(NUM_MAKE_JOBS) --target install - rm -rf ./cutlass/build + $(call cutlass_build,$(CUTLASS_ARCHS),$(CUTLASS_KERNS),$(SB_MICRO_PATH),./cutlass/build) + $(if $(CUTLASS_SM107_KERNS),$(call cutlass_build,"107a",$(CUTLASS_SM107_KERNS),$(CUTLASS_SM107_PREFIX),./cutlass/build_sm107)) From c7e049cc6affa12363b257e4194eec7fe42ef47e Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 15 Oct 2026 17:33:00 +0000 Subject: [PATCH 24/30] Build: CUTLASS - fix CUDA < 11.8, H100 FP8 and CUDA 12.8 kernel builds - CUDA < 11.8 (cuda11.1.1 image): build CUTLASS v2.4.0, the commit pinned as the third_party/cutlass submodule, with the full legacy kernel list, as main did. v3.9.2 needs CUDA 11.4+ and CMake 3.19+, and the Volta-only list dropped every A100 tensor-core kernel. - H100 FP8: build the e4m3 x e4m3 -> f32 WGMMA kernels (66) for "90a" in the CUDA 12.0-12.7 and 12.8 builds. Plain "90" compiles them without any WGMMA instruction. CUTLASS v3.x names put the MMA shape before "gemm" (s64x256x32gemm), so the build filter, the 9.0 fp8_tc pattern and the parse prefix accept both v3.x and v4.x names. - CUDA 12.8: use v4.3.5 with "80;90a;100a". v3.9.2 SM100 names (s128x256x8tf32gemm) matched neither the SM100 filters nor the GB200 patterns, and plain "100" generated no SM100 kernels. CUDA 12.9, 13.0 and 13.4 build commands are unchanged. --- .../cuda_gemm_flops_performance.py | 6 +-- .../test_cuda_gemm_flops_performance.py | 9 ++-- third_party/cutlass.mk | 42 +++++++++++++------ 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 641d94737..05ff7f1ae 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -52,8 +52,8 @@ def __init__(self, name, parameters=''): self.__kernel_map[8.9] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'fp64' not in k} # Skip INT4 for Hopper due to no native CUDA/Tensor Cores self.__kernel_map[9.0] = {k: self.__kernel_map[8.0][k] for k in self.__kernel_map[8.0] if 'int4_tc' not in k} - # FP8 (e4m3) on Hopper SM90: CUTLASS 3x WGMMA kernels (CUTLASS v3.9.2+). - self.__kernel_map[9.0]['fp8_tc'] = 'cutlass3x_sm90_tensorop_gemm_e4m3_*' + # FP8 (e4m3) on Hopper SM90a: CUTLASS 3x WGMMA kernels; v3.x names put the MMA shape before "gemm". + self.__kernel_map[9.0]['fp8_tc'] = 'cutlass3x_sm90_tensorop_*gemm_e4m3_e4m3_f32_f32_f32_*' # Blackwell (SM100/SM103): CUTLASS v4.3.5 (v4.8.0 with CUDA 13.4+) UMMA TensorOp kernels. # Runtime --kernels patterns select stream_k + 2sm kernels for peak FLOPS. # TF32/FP16/BF16: 256x256 tiles only (best for 32/64-byte K-tiles). @@ -101,7 +101,7 @@ def __init__(self, name, parameters=''): 'gemm,cutlass_tensorop_tf32_s1688gemm_tf32_256x128_16x3', 'gemm,cutlass_tensorop_bf16_s16816gemm_bf16_256x128_32x3', 'gemm,cutlass_tensorop_h16816gemm_256x128_32x3', 'gemm,cutlass_tensorop_h884gemm_256x128_32x2', 'gemm,cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3', - 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', 'gemm,cutlass3x_sm90_tensorop_gemm_e4m3_', + 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', 'gemm,cutlass3x_sm90_tensorop_', 'gemm,cutlass3x_sm100_tensorop_tf32gemm_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_', diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 64ab24b97..f8d9f336f 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -174,14 +174,17 @@ def test_flops_performance_cuda_fp8(self): benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) benchmark._precision_need_to_run = ['fp8_tc', 'fp8_tc'] - # SM90 Hopper WGMMA 3x kernel: cutlass3x_sm90_tensorop_gemm_e4m3_{a}_{b}_{acc}_{c}_{d}_{tile}_... + # SM90 Hopper WGMMA 3x kernels from CUTLASS v3.9.2 (MMA shape before "gemm") and v4.3.5. raw_output_sm90_fp8 = """ CSV Results: Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,gemm,cutlass3x_sm90_tensorop_gemm_e4m3_e4m3_f32_bf16_bf16_128x128x64_2x1x1_0_tnn_align16_warpspecialized_cooperative_epi_tma,passed,success,universal,16384,16384,16384,3.85,2281500 -1,CUTLASS,gemm,cutlass3x_sm90_tensorop_gemm_e4m3_e4m3_f32_f16_f16_128x128x64_2x1x1_0_tnn_align16_warpspecialized_cooperative_epi_tma,passed,success,universal,16384,16384,16384,3.79,2317200 +1,CUTLASS,gemm,cutlass3x_sm90_tensorop_s64x256x32gemm_e4m3_e4m3_f32_f32_f32_128x256x128_2x1x1_0_tnn_align16_warpspecialized_cooperative_fp8_fastaccum_epi_nosmem,passed,success,universal,16384,16384,16384,3.79,2317200 +1,CUTLASS,gemm,cutlass3x_sm90_tensorop_gemm_e4m3_e4m3_f32_f32_f32_128x256x128_2x1x1_0_tnn_align16_warpspecialized_cooperative_fp8_fastaccum_epi_nosmem,passed,success,universal,16384,16384,16384,3.85,2281500 """ + pattern = benchmark._CudaGemmFlopsBenchmark__kernel_map[9.0]['fp8_tc'] + names = [line.split(',')[3] for line in raw_output_sm90_fp8.splitlines() if line.startswith('1,')] + assert (names and all(fnmatch.fnmatchcase(name, '*' + pattern + '*') for name in names)) # SM100 Blackwell UMMA 3x kernel: cutlass3x_sm100_tensorop_gemm_e4m3_{a}_{b}_{acc}_{c}_{d}_{tile}_... raw_output_sm100_fp8 = """ CSV Results: diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index d0dfc16a4..19186cda5 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -34,12 +34,10 @@ CUTLASS_KERNELS_LEGACY := \ cutlass_tensorop_s8_i16832gemm_s8_256x128_64x3_*,\ cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3_* -# SM70–80 Volta/Turing subset (no Ampere+ TensorOp) -CUTLASS_KERNELS_VOLTA := \ - cutlass_simt_dgemm_128x128_8x2_*,\ - cutlass_simt_sgemm_128x128_8x2_*,\ - cutlass_simt_hgemm_256x128_8x2_*,\ - cutlass_tensorop_h884gemm_256x128_32x2_* +# SM90 Hopper FP8 WGMMA kernels (e4m3 in, f32 out); they need the "90a" arch. +# CUTLASS v3.x names put the MMA shape before "gemm" (s64x256x32gemm), v4.x +# names do not, hence the "*" before "gemm". +CUTLASS_KERNELS_SM90 := cutlass3x_sm90_tensorop_*gemm_e4m3_e4m3_f32_f32_f32_* # SM100 Blackwell 3x UMMA GEMM kernels # Optimized for peak-FLOPS benchmarking on GB200/GB300: @@ -172,19 +170,35 @@ else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) # ----------------------------------------------------------------------- - # Hopper SM90 + Blackwell SM100 — CUTLASS v3.9.2 + # Ampere SM80 + Hopper SM90a + Blackwell SM100a — CUTLASS v4.3.5 # ----------------------------------------------------------------------- # SM90 non-FP8 precisions use legacy SM80 kernel names (SIMT + TensorOp) # which are backward-compatible on Hopper. SM90 FP8 and SM100 use 3x naming. + # v4.3.5 gives the same SM100 names as the 12.9 tier; v3.9.2 puts the MMA + # shape before "gemm" (s128x256x8tf32gemm), which the SM100 filters and + # gemm-flops patterns do not match. The "a" archs are required: plain "90" + # builds the WGMMA kernels as stubs and plain "100" generates no SM100 + # kernels. Without 103a the INT8 gate does not fire, so no patch is needed. + $(eval CUTLASS_TAG := v4.3.5) + $(eval CUTLASS_ARCHS := "80;90a;100a") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY)),$(CUTLASS_KERNELS_SM90),$(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) + $(eval CUTLASS_PATCHES := @true) + +else ifeq ($(shell echo $(CUDA_VER)">=12.0" | bc -l), 1) + # ----------------------------------------------------------------------- + # Volta through Hopper (SM70–SM90a) — CUTLASS v3.9.2 + # ----------------------------------------------------------------------- + # "90a" is needed for the Hopper FP8 WGMMA kernels (plain "90" builds stubs). $(eval CUTLASS_TAG := v3.9.2) - $(eval CUTLASS_ARCHS := "80;90;100") - $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY)),cutlass3x_sm90_tensorop_gemm_e4m3_*,$(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) + $(eval CUTLASS_ARCHS := "70;75;80;86;89;90a") + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY)),$(CUTLASS_KERNELS_SM90)) $(eval CUTLASS_PATCHES := @true) else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) # ----------------------------------------------------------------------- - # Volta through Ada (SM70–SM90) + # Volta through Ada (SM70–SM90) — CUTLASS v3.9.2 # ----------------------------------------------------------------------- + # CUDA 11.8 has no sm_90a, so there are no Hopper FP8 kernels here. $(eval CUTLASS_TAG := v3.9.2) $(eval CUTLASS_ARCHS := "70;75;80;86;89;90") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY))) @@ -192,11 +206,13 @@ else ifeq ($(shell echo $(CUDA_VER)">=11.8" | bc -l), 1) else # ----------------------------------------------------------------------- - # Volta/Turing subset (SM70–SM86) + # Volta through Ampere (SM70–SM86) — CUTLASS v2.4.0 # ----------------------------------------------------------------------- - $(eval CUTLASS_TAG := v3.9.2) + # v2.4.0 is the third_party/cutlass submodule commit; CUTLASS 3.x needs + # CUDA 11.4+ and CMake 3.19+. + $(eval CUTLASS_TAG := v2.4.0) $(eval CUTLASS_ARCHS := "70;75;80;86") - $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_VOLTA))) + $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_LEGACY))) $(eval CUTLASS_PATCHES := @true) endif From e1fba215929e37b8954341dcf146c14539254b3b Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 15 Oct 2026 18:23:29 +0000 Subject: [PATCH 25/30] Build: CUTLASS - generate GB300 NVFP4 Ultra kernels with CUDA 12.9 CUTLASS v4.3.5 only runs GenerateSM103_TensorOp_fp4_ultra_UMMA_gemm_with_block_scaled for CUDA 13.0+, so the cuda12.9 image had no kernels for GB300 nvfp4_tc. CUTLASS enables SM103 from CUDA 12.9 (arch/config.h) and the Ultra MMA has a CUDA 12.9 PTX form; all six Ultra schedule variants compile with CUDA 12.9.41 to the same UTCOMMA.2CTA.BLOCK16 instructions as with CUDA 13.4. The 12.9 tier now lowers only that generator's gate to 12.9 (sed limited to the function) and a grep fails the build if the patch no longer applies. With CUDA 12.9 the generated kernel list is identical to CUDA 13.0 (3,832 kernels, GB300 nvfp4_tc selects 72). Other tiers are unchanged. --- third_party/cutlass.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 19186cda5..f9dbcc56c 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -88,6 +88,11 @@ CUTLASS_SM107_PREFIX = $(SB_MICRO_PATH)/cutlass_sm107 _strip_spaces = $(subst $(space),,$1) space := $(subst ,, ) +# CUTLASS v4.3.5 generates the GB300 (SM103) FP4 Ultra kernels only for CUDA 13.0+, +# but CUTLASS enables SM103 from CUDA 12.9 and they compile to real UTCOMMA kernels +# with it. Lower only that generator's gate; the grep fails if it no longer applies. +CUTLASS_SM103_ULTRA_PATCH = sed -i "/^def GenerateSM103_TensorOp_fp4_ultra_UMMA_gemm_with_block_scaled/,/return/s/(cuda_version, 13, 0)/(cuda_version, 12, 9)/" cutlass/python/cutlass_library/generator.py && grep -A3 "^def GenerateSM103_TensorOp_fp4_ultra_UMMA_gemm_with_block_scaled" cutlass/python/cutlass_library/generator.py | grep -q "(cuda_version, 12, 9)" + # $(call cutlass_build,,,,) # Configures, builds and installs ./cutlass into /{bin,lib}. cutlass_build = cmake -DCMAKE_INSTALL_BINDIR=$(3)/bin \ @@ -163,10 +168,11 @@ else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) # On a GB300 the profiler will load the SM103a cubin and correctly # report the kernel as "failed"; cuda_gemm_flops_performance.py # excludes int8_tc from the SM10.3 kernel map so it is never run. + # CUTLASS_SM103_ULTRA_PATCH lets CUDA 12.9 generate the GB300 NVFP4 kernels. $(eval CUTLASS_TAG := v4.3.5) $(eval CUTLASS_ARCHS := "100a;103a") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) - $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py && $(CUTLASS_SM103_ULTRA_PATCH)) else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) # ----------------------------------------------------------------------- From a15dcc2370e271083e3cd926e2057c414cb282a5 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Thu, 15 Oct 2026 18:53:32 +0000 Subject: [PATCH 26/30] Benchmarks: Micro benchmark - add MXFP8, MXFP4 and UE5M3 NVFP4 to gemm-flops on Rubin New gemm-flops precisions for CC 10.7, using CUTLASS v4.8.0's native SM107 block-scaled kernels (B-reuse schedules, N=256 2SM tiles): - nvfp4_ue5m3_tc: NVFP4 (e2m1) with the new UE5M3 scale type, 16-element blocks - mxfp8_tc: MXFP8 (runtime-typed f8 run as e4m3, UE8M0 scales, 32-element blocks) - mxfp4_tc: MXFP4 (e2m1, UE8M0 scales, 32-element blocks) The profiler operation now follows the kernel family (bstensorop -> block_scaled_gemm), and every runtime-typed FP8 family (gemm_f8_f8, ue8m0xf8) gets --runtime_input_datatype_a/b=e4m3. SM107 block-scaled rows are parsed by one prefix. The Rubin build adds the native 2SM kernels of these formats (672 kernels, 3,360 total; largest library group 689 files). Docs list the FP8/FP4 metrics. --- .../benchmarks/micro-benchmarks.md | 35 +++++++----- .../cuda_gemm_flops_performance.py | 24 +++++--- .../gemm_flops_performance_base.py | 5 +- .../test_cuda_gemm_flops_performance.py | 55 +++++++++++++++---- third_party/cutlass.mk | 9 ++- 5 files changed, 91 insertions(+), 37 deletions(-) diff --git a/docs/user-tutorial/benchmarks/micro-benchmarks.md b/docs/user-tutorial/benchmarks/micro-benchmarks.md index e8cda7eea..5f493278e 100644 --- a/docs/user-tutorial/benchmarks/micro-benchmarks.md +++ b/docs/user-tutorial/benchmarks/micro-benchmarks.md @@ -30,21 +30,26 @@ or AMD [rocblas-bench](https://github.com/ROCmSoftwarePlatform/rocBLAS/tree/deve #### Metrics -| Name | Unit | Description | -|------------------------------|----------------|---------------------------------------------------------| -| gemm-flops/fp64_flops | FLOPS (GFLOPS) | GEMM float64 peak FLOPS. | -| gemm-flops/fp32_flops | FLOPS (GFLOPS) | GEMM float32 peak FLOPS. | -| gemm-flops/fp16_flops | FLOPS (GFLOPS) | GEMM float16 peak FLOPS. | -| gemm-flops/fp64_tc_flops | FLOPS (GFLOPS) | GEMM float64 peak FLOPS with NVIDIA Tensor Core. | -| gemm-flops/tf32_tc_flops | FLOPS (GFLOPS) | GEMM tensor-float32 peak FLOPS with NVIDIA Tensor Core. | -| gemm-flops/fp16_tc_flops | FLOPS (GFLOPS) | GEMM float16 peak FLOPS with NVIDIA Tensor Core. | -| gemm-flops/bf16_tc_flops | FLOPS (GFLOPS) | GEMM bfloat16 peak FLOPS with NVIDIA Tensor Core. | -| gemm-flops/int8_tc_iops | IOPS (GIOPS) | GEMM int8 peak IOPS with NVIDIA Tensor Core. | -| gemm-flops/int4_tc_iops | IOPS (GIOPS) | GEMM int4 peak IOPS with NVIDIA Tensor Core. | -| gemm-flops/fp32_xdlops_flops | FLOPS (GFLOPS) | GEMM tensor-float32 peak FLOPS with AMD XDLOPS. | -| gemm-flops/fp16_xdlops_flops | FLOPS (GFLOPS) | GEMM float16 peak FLOPS with AMD XDLOPS. | -| gemm-flops/bf16_xdlops_flops | FLOPS (GFLOPS) | GEMM bfloat16 peak FLOPS with AMD XDLOPS. | -| gemm-flops/int8_xdlops_iops | IOPS (GIOPS) | GEMM int8 peak IOPS with AMD XDLOPS. | +| Name | Unit | Description | +|---------------------------------|----------------|----------------------------------------------------------------------------------| +| gemm-flops/fp64_flops | FLOPS (GFLOPS) | GEMM float64 peak FLOPS. | +| gemm-flops/fp32_flops | FLOPS (GFLOPS) | GEMM float32 peak FLOPS. | +| gemm-flops/fp16_flops | FLOPS (GFLOPS) | GEMM float16 peak FLOPS. | +| gemm-flops/fp64_tc_flops | FLOPS (GFLOPS) | GEMM float64 peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/tf32_tc_flops | FLOPS (GFLOPS) | GEMM tensor-float32 peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/fp16_tc_flops | FLOPS (GFLOPS) | GEMM float16 peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/bf16_tc_flops | FLOPS (GFLOPS) | GEMM bfloat16 peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/int8_tc_iops | IOPS (GIOPS) | GEMM int8 peak IOPS with NVIDIA Tensor Core. | +| gemm-flops/int4_tc_iops | IOPS (GIOPS) | GEMM int4 peak IOPS with NVIDIA Tensor Core. | +| gemm-flops/fp8_tc_flops | FLOPS (GFLOPS) | GEMM FP8 (E4M3) peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/nvfp4_tc_flops | FLOPS (GFLOPS) | GEMM NVFP4 (E2M1, UE4M3 scale per 16 values) peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/nvfp4_ue5m3_tc_flops | FLOPS (GFLOPS) | GEMM NVFP4 (E2M1, UE5M3 scale per 16 values) peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/mxfp8_tc_flops | FLOPS (GFLOPS) | GEMM MXFP8 (E4M3, E8M0 scale per 32 values) peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/mxfp4_tc_flops | FLOPS (GFLOPS) | GEMM MXFP4 (E2M1, E8M0 scale per 32 values) peak FLOPS with NVIDIA Tensor Core. | +| gemm-flops/fp32_xdlops_flops | FLOPS (GFLOPS) | GEMM tensor-float32 peak FLOPS with AMD XDLOPS. | +| gemm-flops/fp16_xdlops_flops | FLOPS (GFLOPS) | GEMM float16 peak FLOPS with AMD XDLOPS. | +| gemm-flops/bf16_xdlops_flops | FLOPS (GFLOPS) | GEMM bfloat16 peak FLOPS with AMD XDLOPS. | +| gemm-flops/int8_xdlops_iops | IOPS (GIOPS) | GEMM int8 peak IOPS with AMD XDLOPS. | ### `matmul` diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 05ff7f1ae..2a46446fe 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -4,6 +4,7 @@ """Module of the FLOPs performance benchmarks.""" import os +import re from superbench.common.utils import logger from superbench.common.utils import device_manager as dm @@ -81,7 +82,8 @@ def __init__(self, name, parameters=''): 'cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32*256x*ultra_2sm*' # Rubin SM107a: CUTLASS v4.8.0 kernels from the separate cutlass_sm107 install (third_party/cutlass.mk). # - TF32/FP16/BF16: SM100 generators retargeted to Sm107, selected like SM100. - # - FP8/NVFP4: native SM107 kernels (B-reuse schedules, no stream-K), N=256 2SM tiles. + # - FP8, NVFP4 (UE4M3 or UE5M3 scales, 16-element blocks) and MXFP8/MXFP4 (UE8M0 scales, 32-element + # blocks): native SM107 kernels (B-reuse schedules, no stream-K), N=256 2SM tiles. # - No INT8: CuTe enables tcgen05 kind::i8 only for SM100a/SM101a/SM110. self.__kernel_map[10.7] = { 'tf32_tc': 'cutlass3x_sm107_tensorop_tf32gemm*256x256x*stream_k_2sm*', @@ -90,6 +92,11 @@ def __init__(self, name, parameters=''): 'fp8_tc': 'cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32*x256x128_*breuse_2sm*', 'nvfp4_tc': 'cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32*x256x256_*o_vs16_*breuse_2sm*', + 'nvfp4_ue5m3_tc': + 'cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32*x256x256_*o_vs16_*breuse_2sm*', + 'mxfp8_tc': 'cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32*x256x128_*breuse_2sm*', + 'mxfp4_tc': + 'cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32*x256x256_*o_vs32_*breuse_2sm*', } # Compute capabilities whose CUTLASS build lives in its own SB_MICRO_PATH subfolder. self.__cutlass_subdir = {10.7: 'cutlass_sm107'} @@ -108,7 +115,7 @@ def __init__(self, name, parameters=''): 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_', 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_', 'gemm,cutlass3x_sm107_tensorop_tf32gemm_', 'gemm,cutlass3x_sm107_tensorop_gemm_f16_', 'gemm,cutlass3x_sm107_tensorop_gemm_bf16_', - 'gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_', 'block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_' + 'gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_', 'block_scaled_gemm,cutlass3x_sm107_bstensorop_' ] def add_parser_arguments(self): @@ -142,19 +149,18 @@ def _preprocess(self): return False for p in self._precision_need_to_run: + kernels = self.__kernel_map[capability][p] command = os.path.join(self._args.bin_dir, self._bin_name) command += (' --warmup-iterations=' + str(self._args.num_warmup)) - # NVFP4 (and MXFP4) require the block_scaled_gemm operation kind - # in cutlass_profiler — they have separate kernel registries from - # the standard gemm operation. - operation = 'block_scaled_gemm' if p in ('nvfp4_tc', 'mxfp4_tc') else 'gemm' + # Block-scaled kernels (bstensorop) are only listed under the block_scaled_gemm operation. + operation = 'block_scaled_gemm' if '_bstensorop_' in kernels else 'gemm' command += (' --operation=' + operation) command += (' --n=' + str(self._args.n)) command += (' --k=' + str(self._args.k)) command += (' --m=' + str(self._args.m)) - command += (' --kernels=' + self.__kernel_map[capability][p]) - # Runtime-typed FP8 kernels ("f8" elements) take the A/B type at launch. - if '_f8_f8_' in self.__kernel_map[capability][p]: + command += (' --kernels=' + kernels) + # Runtime-typed FP8 kernels ("f8" elements: gemm_f8_f8, ue8m0xf8) take the A/B type at launch. + if re.search(r'[_x]f8_', kernels): command += ' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3' self._commands.append(command) diff --git a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py index f7a467bdc..c0eb577d0 100644 --- a/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py +++ b/superbench/benchmarks/micro_benchmarks/gemm_flops_performance_base.py @@ -21,7 +21,7 @@ def __init__(self, name, parameters=''): self._support_precisions = [ 'fp64', 'fp32', 'fp16', 'fp64_tc', 'tf32_tc', 'bf16_tc', 'fp16_tc', 'int8_tc', 'int4_tc', 'fp8_tc', - 'nvfp4_tc' + 'nvfp4_tc', 'nvfp4_ue5m3_tc', 'mxfp8_tc', 'mxfp4_tc' ] self._precision_need_to_run = list() self._metric_map = { @@ -36,6 +36,9 @@ def __init__(self, name, parameters=''): 'int4_tc': 'int4_tc_iops', 'fp8_tc': 'fp8_tc_flops', 'nvfp4_tc': 'nvfp4_tc_flops', + 'nvfp4_ue5m3_tc': 'nvfp4_ue5m3_tc_flops', + 'mxfp8_tc': 'mxfp8_tc_flops', + 'mxfp4_tc': 'mxfp4_tc_flops', 'fp32_xdlops': 'fp32_xdlops_flops', 'fp16_xdlops': 'fp16_xdlops_flops', 'bf16_xdlops': 'bf16_xdlops_flops', diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index f8d9f336f..95fa735d6 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -242,7 +242,7 @@ def test_flops_performance_cuda_sm107_kernels(self): predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) assert (benchmark_class) - precisions = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'fp8_tc', 'nvfp4_tc'] + precisions = ['tf32_tc', 'bf16_tc', 'fp16_tc', 'fp8_tc', 'nvfp4_tc', 'nvfp4_ue5m3_tc', 'mxfp8_tc', 'mxfp4_tc'] benchmark = benchmark_class(benchmark_name, parameters='--precision ' + ' '.join(precisions)) kernel_map = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.7] assert (sorted(kernel_map) == sorted(precisions)) @@ -256,7 +256,7 @@ def test_flops_performance_cuda_sm107_kernels(self): benchmark._result = BenchmarkResult(benchmark_name, BenchmarkType.MICRO, ReturnCode.SUCCESS) benchmark._precision_need_to_run = precisions - # Kernel names from CUTLASS v4.8.0 generated for "107a"; FP8 and NVFP4 are native SM107 B-reuse kernels. + # Kernel names from CUTLASS v4.8.0 generated for "107a"; the FP8/FP4 ones are native SM107 B-reuse kernels. raw_output_tf32_tc = """ CSV Results: @@ -291,9 +291,31 @@ def test_flops_performance_cuda_sm107_kernels(self): Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs 1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,14000000 1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,16000000 +""" + raw_output_nvfp4_ue5m3_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,15000000 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,15500000 +""" + raw_output_mxfp8_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_256x256x128_0x0x1_0_tnn_align16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.2,4100000 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_512x256x128_4x4x1_0_tnn_align16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.0,4300000 +""" + raw_output_mxfp4_tc = """ +CSV Results: + +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,14500000 +1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs32_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,15800000 """ raw_outputs = [ - raw_output_tf32_tc, raw_output_bf16_tc, raw_output_fp16_tc, raw_output_fp8_tc, raw_output_nvfp4_tc + raw_output_tf32_tc, raw_output_bf16_tc, raw_output_fp16_tc, raw_output_fp8_tc, raw_output_nvfp4_tc, + raw_output_nvfp4_ue5m3_tc, raw_output_mxfp8_tc, raw_output_mxfp4_tc ] for idx, raw_output in enumerate(raw_outputs): # The --kernels pattern must select the real names (matched like '*pattern*'). @@ -307,14 +329,22 @@ def test_flops_performance_cuda_sm107_kernels(self): assert (benchmark.result['fp16_tc_flops'][0] == 2200000) assert (benchmark.result['fp8_tc_flops'][0] == 4400000) assert (benchmark.result['nvfp4_tc_flops'][0] == 16000000) + assert (benchmark.result['nvfp4_ue5m3_tc_flops'][0] == 15500000) + assert (benchmark.result['mxfp8_tc_flops'][0] == 4300000) + assert (benchmark.result['mxfp4_tc_flops'][0] == 15800000) - # Retargeted SM100-style FP8/NVFP4, 1SM, vs32 and MXFP4 (ue8m0) kernels are not selected. + # Retargeted SM100-style kernels, 1SM kernels and other scale types or block sizes are not selected. unselected = """ fp8_tc,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_256x256x128_0x0x1_0_ntn_align16_stream_k_2sm fp8_tc,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_256x256x128_0x0x1_0_ntn_align16_breuse_1sm nvfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_2sm nvfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma nvfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma +nvfp4_ue5m3_tc,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma +nvfp4_ue5m3_tc,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma +mxfp8_tc,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_256x256x128_0x0x1_0_tnn_align16_breuse_1sm +mxfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma +mxfp4_tc,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_2sm """ for line in unselected.split(): precision, name = line.split(',') @@ -331,21 +361,26 @@ def test_flops_performance_cuda_sm107_commands(self): with mock.patch.object(dm.device_manager, 'get_device_compute_capability', return_value=10.7): with mock.patch.dict(os.environ): benchmark = benchmark_class( - benchmark_name, parameters='--precision tf32_tc fp8_tc nvfp4_tc int8_tc int4_tc' + benchmark_name, + parameters='--precision tf32_tc fp8_tc nvfp4_tc nvfp4_ue5m3_tc mxfp8_tc mxfp4_tc int8_tc int4_tc' ) assert (benchmark._preprocess() is True) assert (os.environ['LD_LIBRARY_PATH'].split(os.pathsep)[0] == os.path.join(prefix, 'lib')) assert (benchmark.return_code == ReturnCode.SUCCESS) # SM107 has no INT8/INT4 kernels, so they are skipped. - assert (benchmark._precision_need_to_run == ['tf32_tc', 'fp8_tc', 'nvfp4_tc']) + expected = ['tf32_tc', 'fp8_tc', 'nvfp4_tc', 'nvfp4_ue5m3_tc', 'mxfp8_tc', 'mxfp4_tc'] + assert (benchmark._precision_need_to_run == expected) assert (benchmark._args.bin_dir == os.path.join(prefix, 'bin')) kernel_map = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.7] - tf32_cmd, fp8_cmd, nvfp4_cmd = benchmark._commands + tf32_cmd, fp8_cmd, nvfp4_cmd, nvfp4_ue5m3_cmd, mxfp8_cmd, mxfp4_cmd = benchmark._commands + runtime_e4m3 = ' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3' assert (tf32_cmd.startswith(os.path.join(prefix, 'bin', 'cutlass_profiler') + ' ')) assert ('--operation=gemm ' in tf32_cmd and tf32_cmd.endswith(' --kernels=' + kernel_map['tf32_tc'])) - assert ('--operation=gemm ' in fp8_cmd) - assert (fp8_cmd.endswith(' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3')) - assert ('--operation=block_scaled_gemm ' in nvfp4_cmd and 'runtime_input_datatype' not in nvfp4_cmd) + assert ('--operation=gemm ' in fp8_cmd and fp8_cmd.endswith(runtime_e4m3)) + for cmd in [nvfp4_cmd, nvfp4_ue5m3_cmd, mxfp4_cmd]: + assert ('--operation=block_scaled_gemm ' in cmd and 'runtime_input_datatype' not in cmd) + # MXFP8 kernels are block-scaled and runtime-typed. + assert ('--operation=block_scaled_gemm ' in mxfp8_cmd and mxfp8_cmd.endswith(runtime_e4m3)) with mock.patch.dict(os.environ): benchmark = benchmark_class(benchmark_name, parameters='--precision int8_tc') diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index f9dbcc56c..8210dc951 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -71,13 +71,18 @@ CUTLASS_KERNELS_SM100 := \ # reuse schedules). Only native names contain "breuse" (or "no_breuse"). # The FP8 ones are runtime-typed (f8_f8). NVFP4 = e2m1 with ue4m3 scale # and 16-element blocks (vs16). +# - NVFP4 with UE5M3 scales (vs16), MXFP4 (e2m1, ue8m0, vs32) and MXFP8 +# (runtime-typed f8, ue8m0): native 2SM kernels only, to bound build time. # - No INT8: CuTe enables tcgen05 kind::i8 only for SM100a/SM101a/SM110. CUTLASS_KERNELS_SM107 := \ cutlass3x_sm107_tensorop_tf32gemm_f32_f32_f32_f32_f32_*,\ cutlass3x_sm107_tensorop_gemm_f16_f16_f32_f16_f16_*,\ cutlass3x_sm107_tensorop_gemm_bf16_bf16_f32_bf16_bf16_*,\ cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_*breuse_*,\ - cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_*_o_vs16_*breuse_* + cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_*_o_vs16_*breuse_*,\ + cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_*_o_vs16_*breuse_2sm*,\ + cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_*_o_vs32_*breuse_2sm*,\ + cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_*breuse_2sm* # Install prefix of the Rubin build; cuda_gemm_flops_performance.py uses it for CC 10.7. CUTLASS_SM107_PREFIX = $(SB_MICRO_PATH)/cutlass_sm107 @@ -225,7 +230,7 @@ endif # ----------------------------------------------------------------------- # Shared clone → patch → build → install pipeline # ----------------------------------------------------------------------- - # With the narrowed kernel filters (Blackwell ~3,800 objects, Rubin ~2,700; + # With the narrowed kernel filters (Blackwell ~3,800 objects, Rubin ~3,400; # max ~840 per sub-group), shared per-family libraries stay under the # R_AARCH64_PREL32 ±2 GB limit on aarch64. Unwind table suppression # further reduces .eh_frame pressure. From 20ac8ff9421ac8394a518aac1fe73eba614f3672 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 24 Nov 2026 21:04:34 +0000 Subject: [PATCH 27/30] Benchmarks: Fix Rubin CUTLASS GEMM execution Parse actual block-scaled profiler CSV output and backport the CUTLASS 4.8.0 MXFP8 runtime datatype fix. Disable CPU reference verification during block-scaled throughput profiling and update regression fixtures and documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../benchmarks/micro-benchmarks.md | 10 +++- .../cuda_gemm_flops_performance.py | 12 +++-- .../test_cuda_gemm_flops_performance.py | 51 +++++++++++-------- third_party/cutlass.mk | 20 ++++++-- third_party/cutlass_v4.8.0_mxfp8.patch | 45 ++++++++++++++++ 5 files changed, 108 insertions(+), 30 deletions(-) create mode 100644 third_party/cutlass_v4.8.0_mxfp8.patch diff --git a/docs/user-tutorial/benchmarks/micro-benchmarks.md b/docs/user-tutorial/benchmarks/micro-benchmarks.md index 231c0e831..26e3152d6 100644 --- a/docs/user-tutorial/benchmarks/micro-benchmarks.md +++ b/docs/user-tutorial/benchmarks/micro-benchmarks.md @@ -25,9 +25,17 @@ which is defined as the time range from the beginning of the launch API call to #### Introduction Measure the GPU GEMM FLOPS for different float and int data types, with or without Tensor Core (XDLOPS), -performed by NVIDIA [cutlass](https://github.com/NVIDIA/cutlass/tree/ccb697bac77fcc898e9c897b2c90aa5b60ac72fb) +performed by NVIDIA [CUTLASS](https://github.com/NVIDIA/cutlass) or AMD [rocblas-bench](https://github.com/ROCmSoftwarePlatform/rocBLAS/tree/develop/clients/benchmarks). +Available precisions depend on the GPU architecture and the installed CUTLASS build. Vera Rubin (compute capability 10.7) +requires CUDA 13.4 or later and the repository-managed CUTLASS build, including its MXFP8 runtime datatype fix. +The benchmark automatically selects the dedicated `cutlass_sm107` profiler and its matching libraries on Rubin. + +Block-scaled modes (`nvfp4_tc`, `nvfp4_ue5m3_tc`, `mxfp8_tc`, and `mxfp4_tc`) disable CUTLASS verification during throughput +measurement to avoid running a CPU reference GEMM for every selected kernel at the default matrix size. +Run correctness checks separately with small matrices and `--verification-enabled=true` using the matching CUTLASS profiler. + #### Metrics | Name | Unit | Description | diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index 2a46446fe..e0f5077c0 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -102,6 +102,7 @@ def __init__(self, name, parameters=''): self.__cutlass_subdir = {10.7: 'cutlass_sm107'} self.__capability = None # ',' of CSV rows to parse: legacy SM70/SM80, SM90, SM100, SM103, SM107. + # Block-scaled kernels report OperationKind 'gemm' (substring matching also accepts 'block_scaled_gemm'). self.__parse_logline = [ 'gemm,cutlass_simt_dgemm_128x128_8x2', 'gemm,cutlass_simt_sgemm_128x128_8x2', 'gemm,cutlass_simt_hgemm_256x128_8x2', 'gemm,cutlass_tensorop_d884gemm_128x128_16x3', @@ -111,11 +112,10 @@ def __init__(self, name, parameters=''): 'gemm,cutlass_tensorop_s4_i16864gemm_s4_256x128_128x3', 'gemm,cutlass3x_sm90_tensorop_', 'gemm,cutlass3x_sm100_tensorop_tf32gemm_', 'gemm,cutlass3x_sm100_tensorop_gemm_f16_', 'gemm,cutlass3x_sm100_tensorop_gemm_bf16_', 'gemm,cutlass3x_sm100_tensorop_gemm_s8_', - 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_', - 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_', - 'block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_', 'gemm,cutlass3x_sm107_tensorop_tf32gemm_', + 'gemm,cutlass3x_sm100_tensorop_gemm_e4m3_e4m3_', 'gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_', + 'gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_', 'gemm,cutlass3x_sm107_tensorop_tf32gemm_', 'gemm,cutlass3x_sm107_tensorop_gemm_f16_', 'gemm,cutlass3x_sm107_tensorop_gemm_bf16_', - 'gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_', 'block_scaled_gemm,cutlass3x_sm107_bstensorop_' + 'gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_', 'gemm,cutlass3x_sm107_bstensorop_' ] def add_parser_arguments(self): @@ -162,6 +162,10 @@ def _preprocess(self): # Runtime-typed FP8 kernels ("f8" elements: gemm_f8_f8, ue8m0xf8) take the A/B type at launch. if re.search(r'[_x]f8_', kernels): command += ' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3' + # cutlass_profiler verifies block-scaled kernels only against a host (CPU) reference, which is impractically + # slow at the default problem size, so skip verification for these throughput runs. + if operation == 'block_scaled_gemm': + command += ' --verification-enabled=false' self._commands.append(command) return True diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 95fa735d6..520bbac61 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -56,7 +56,8 @@ def test_flops_performance_cuda(self): assert (benchmark._args.k == 512) assert (benchmark._args.m == 2048) assert (benchmark._args.precision == ['fp32', 'tf32_tc', 'fp16_tc', 'int8_tc']) - benchmark._CudaGemmFlopsBenchmark__precision_need_to_run = ['fp32', 'tf32_tc', 'fp16_tc', 'int8_tc'] + # Parse the outputs below as these precisions on any GPU architecture. + benchmark._precision_need_to_run = ['fp32', 'tf32_tc', 'fp16_tc', 'int8_tc'] # Check results and metrics. raw_output_fp32 = """ @@ -218,13 +219,13 @@ def test_flops_performance_cuda_nvfp4(self): # SM103 Blackwell Ultra NVFP4 block-scaled kernel: # cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_{acc}_{c}_{d}_{tile}_..._ultra_2sm_* - # OperationKind is "block_scaled_gemm" (not "gemm"). + # cutlass_profiler reports OperationKind "gemm" for them and prints large GFLOPs in exponent notation. raw_output_sm103_nvfp4 = """ CSV Results: -Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x768_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_nopf_epi_nosmem,passed,success,universal,16384,16384,16384,0.55,15998700 -1,CUTLASS,block_scaled_gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x768_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_tmapf_epi_nosmem,passed,success,universal,16384,16384,16384,0.53,16602100 +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,A,B,C,D,alpha,beta,split_k_mode,split_k_slices,batch_count,runtime_input_datatype_a,runtime_input_datatype_b,raster_order,swizzle_size,use_pdl,op_class,accum,cta_m,cta_n,cta_k,cluster_m,cluster_n,cluster_k,cluster_m_fallback,cluster_n_fallback,cluster_k_fallback,stages,warps_m,warps_n,warps_k,inst_m,inst_n,inst_k,min_cc,max_cc,Bytes,Flops,Flops/Byte,Runtime,GB/s,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x768_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_nopf_epi_nosmem,not_verified,success,universal,16384,16384,16384,fe2m1:row,fe2m1:column,void:row,f32:row,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,256,256,768,2,1,1,2,1,1,4,4,1,1,256,256,128,103,1024,301989888,8796629893120,29128,0.55,511.364,1.59939e+07 +1,CUTLASS,gemm,cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x768_2x1x1_0_tnt_align32_o_vs16_ultra_2sm_tmapf_epi_nosmem,not_verified,success,universal,16384,16384,16384,fe2m1:row,fe2m1:column,void:row,f32:row,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,256,256,768,2,1,1,2,1,1,4,4,1,1,256,256,128,103,1024,301989888,8796629893120,29128,0.52985,530.811,1.66021e+07 """ # The SM10.3 --kernels pattern must select these real CUTLASS v4.3.5 names (matched like '*pattern*'). pattern = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.3]['nvfp4_tc'] @@ -285,33 +286,34 @@ def test_flops_performance_cuda_sm107_kernels(self): 1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_256x256x128_0x0x1_0_ntn_align16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.2,4000000 1,CUTLASS,gemm,cutlass3x_sm107_tensorop_gemm_f8_f8_f32_f32_f32_512x256x128_4x4x1_0_tnn_align16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.0,4400000 """ + # Block-scaled outputs use the real cutlass_profiler CSV layout from Rubin: OperationKind is 'gemm'. raw_output_nvfp4_tc = """ CSV Results: -Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,14000000 -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,16000000 +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,A,B,C,D,alpha,beta,split_k_mode,split_k_slices,batch_count,runtime_input_datatype_a,runtime_input_datatype_b,raster_order,swizzle_size,use_pdl,op_class,accum,cta_m,cta_n,cta_k,cluster_m,cluster_n,cluster_k,cluster_m_fallback,cluster_n_fallback,cluster_k_fallback,stages,warps_m,warps_n,warps_k,inst_m,inst_n,inst_k,min_cc,max_cc,Bytes,Flops,Flops/Byte,Runtime,GB/s,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,fe2m1:row,fe2m1:column,void:column,f32:column,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,256,256,256,2,1,1,2,1,1,5,4,1,1,256,256,128,107,1024,294912,268959744,912,0.0057296,47.9367,46942.1 +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,fe2m1:row,fe2m1:column,void:column,f32:column,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,512,256,256,4,4,1,2,1,1,4,4,1,1,256,256,128,107,1024,294912,268959744,912,0.0061,45.0259,44091.8 """ raw_output_nvfp4_ue5m3_tc = """ CSV Results: -Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,15000000 -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,15500000 +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,A,B,C,D,alpha,beta,split_k_mode,split_k_slices,batch_count,runtime_input_datatype_a,runtime_input_datatype_b,raster_order,swizzle_size,use_pdl,op_class,accum,cta_m,cta_n,cta_k,cluster_m,cluster_n,cluster_k,cluster_m_fallback,cluster_n_fallback,cluster_k_fallback,stages,warps_m,warps_n,warps_k,inst_m,inst_n,inst_k,min_cc,max_cc,Bytes,Flops,Flops/Byte,Runtime,GB/s,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs16_no_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,fe2m1:row,fe2m1:column,void:column,f32:column,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,256,256,256,2,1,1,2,1,1,5,4,1,1,256,256,128,107,1024,294912,268959744,912,0.005736,47.8832,46889.8 +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue5m3xe2m1_ue5m3xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs16_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,fe2m1:row,fe2m1:column,void:column,f32:column,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,512,256,256,4,4,1,2,1,1,4,4,1,1,256,256,128,107,1024,294912,268959744,912,0.0062,44.2997,43380.6 """ raw_output_mxfp8_tc = """ CSV Results: -Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_256x256x128_0x0x1_0_tnn_align16_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.2,4100000 -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_512x256x128_4x4x1_0_tnn_align16_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,2.0,4300000 +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,A,B,C,D,alpha,beta,split_k_mode,split_k_slices,batch_count,runtime_input_datatype_a,runtime_input_datatype_b,raster_order,swizzle_size,use_pdl,op_class,accum,cta_m,cta_n,cta_k,cluster_m,cluster_n,cluster_k,cluster_m_fallback,cluster_n_fallback,cluster_k_fallback,stages,warps_m,warps_n,warps_k,inst_m,inst_n,inst_k,min_cc,max_cc,Bytes,Flops,Flops/Byte,Runtime,GB/s,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_256x256x128_0x0x1_0_tnn_align16_no_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,f8:row,f8:column,void:column,f32:column,1,0,serial,1,1,e4m3,e4m3,heuristic,1,false,invalid,f32,256,256,128,2,1,1,2,1,1,6,4,1,1,256,256,64,107,1024,540672,268959744,497,0.0071,70.9211,37881.7 +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xf8_ue8m0xf8_f32_void_f32_512x256x128_4x4x1_0_tnn_align16_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,f8:row,f8:column,void:column,f32:column,1,0,serial,1,1,e4m3,e4m3,heuristic,1,false,invalid,f32,512,256,128,4,4,1,2,1,1,5,4,1,1,256,256,64,107,1024,540672,268959744,497,0.0066,76.2939,40751.5 """ raw_output_mxfp4_tc = """ CSV Results: -Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,Runtime,GFLOPs -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.6,14500000 -1,CUTLASS,block_scaled_gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs32_breuse_2sm_epi_tma,passed,success,universal,16384,16384,16384,0.5,15800000 +Problem,Provider,OperationKind,Operation,Disposition,Status,gemm_kind,m,n,k,A,B,C,D,alpha,beta,split_k_mode,split_k_slices,batch_count,runtime_input_datatype_a,runtime_input_datatype_b,raster_order,swizzle_size,use_pdl,op_class,accum,cta_m,cta_n,cta_k,cluster_m,cluster_n,cluster_k,cluster_m_fallback,cluster_n_fallback,cluster_k_fallback,stages,warps_m,warps_n,warps_k,inst_m,inst_n,inst_k,min_cc,max_cc,Bytes,Flops,Flops/Byte,Runtime,GB/s,GFLOPs +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_256x256x256_0x0x1_0_tnn_align32_o_vs32_no_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,fe2m1:row,fe2m1:column,void:column,f32:column,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,256,256,256,2,1,1,2,1,1,5,4,1,1,256,256,128,107,1024,278528,268959744,965,0.00568032,45.6663,47349.4 +1,CUTLASS,gemm,cutlass3x_sm107_bstensorop_gemm_ue8m0xe2m1_ue8m0xe2m1_f32_void_f32_512x256x256_4x4x1_0_tnn_align32_o_vs32_breuse_2sm_epi_tma,not_verified,success,universal,512,512,512,fe2m1:row,fe2m1:column,void:column,f32:column,1,0,serial,1,1,invalid,invalid,heuristic,1,false,invalid,f32,512,256,256,4,4,1,2,1,1,4,4,1,1,256,256,128,107,1024,278528,268959744,965,0.006,43.2332,44826.6 """ raw_outputs = [ raw_output_tf32_tc, raw_output_bf16_tc, raw_output_fp16_tc, raw_output_fp8_tc, raw_output_nvfp4_tc, @@ -328,10 +330,10 @@ def test_flops_performance_cuda_sm107_kernels(self): assert (benchmark.result['bf16_tc_flops'][0] == 2100000) assert (benchmark.result['fp16_tc_flops'][0] == 2200000) assert (benchmark.result['fp8_tc_flops'][0] == 4400000) - assert (benchmark.result['nvfp4_tc_flops'][0] == 16000000) - assert (benchmark.result['nvfp4_ue5m3_tc_flops'][0] == 15500000) - assert (benchmark.result['mxfp8_tc_flops'][0] == 4300000) - assert (benchmark.result['mxfp4_tc_flops'][0] == 15800000) + assert (benchmark.result['nvfp4_tc_flops'][0] == 46942.1) + assert (benchmark.result['nvfp4_ue5m3_tc_flops'][0] == 46889.8) + assert (benchmark.result['mxfp8_tc_flops'][0] == 40751.5) + assert (benchmark.result['mxfp4_tc_flops'][0] == 47349.4) # Retargeted SM100-style kernels, 1SM kernels and other scale types or block sizes are not selected. unselected = """ @@ -374,13 +376,18 @@ def test_flops_performance_cuda_sm107_commands(self): kernel_map = benchmark._CudaGemmFlopsBenchmark__kernel_map[10.7] tf32_cmd, fp8_cmd, nvfp4_cmd, nvfp4_ue5m3_cmd, mxfp8_cmd, mxfp4_cmd = benchmark._commands runtime_e4m3 = ' --runtime_input_datatype_a=e4m3 --runtime_input_datatype_b=e4m3' + no_verification = ' --verification-enabled=false' assert (tf32_cmd.startswith(os.path.join(prefix, 'bin', 'cutlass_profiler') + ' ')) assert ('--operation=gemm ' in tf32_cmd and tf32_cmd.endswith(' --kernels=' + kernel_map['tf32_tc'])) assert ('--operation=gemm ' in fp8_cmd and fp8_cmd.endswith(runtime_e4m3)) + # Dense kernels keep the default verification; block-scaled ones skip the slow host reference check. + assert (all('--verification-enabled' not in cmd for cmd in [tf32_cmd, fp8_cmd])) for cmd in [nvfp4_cmd, nvfp4_ue5m3_cmd, mxfp4_cmd]: assert ('--operation=block_scaled_gemm ' in cmd and 'runtime_input_datatype' not in cmd) + assert (cmd.endswith(no_verification)) # MXFP8 kernels are block-scaled and runtime-typed. - assert ('--operation=block_scaled_gemm ' in mxfp8_cmd and mxfp8_cmd.endswith(runtime_e4m3)) + assert ('--operation=block_scaled_gemm ' in mxfp8_cmd) + assert (mxfp8_cmd.endswith(runtime_e4m3 + no_verification)) with mock.patch.dict(os.environ): benchmark = benchmark_class(benchmark_name, parameters='--precision int8_tc') diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 8210dc951..5af28620a 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -93,6 +93,19 @@ CUTLASS_SM107_PREFIX = $(SB_MICRO_PATH)/cutlass_sm107 _strip_spaces = $(subst $(space),,$1) space := $(subst ,, ) +CUTLASS_MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +# CUTLASS v4.8.0 generates SM107 MXFP8 (ue8m0xf8) as runtime-typed +# MXF8F6F4Format kernels, but BlockScaledGemmUniversal3xOperationBase's +# mapping() in tools/library/src/block_scaled_gemm_operation_3x.hpp omitted +# kE4M3/kE5M2 and fell into CUTE_GCC_UNREACHABLE (host SIGSEGV in +# can_implement()). Backport NVIDIA/cutlass commit 555a0474 to map +# kE5M2/kE4M3 and reject unsupported runtime datatypes with kErrorInvalidProblem. +CUTLASS_V480_MXFP8_PATCH = git -C cutlass apply --check $(CUTLASS_MK_DIR)cutlass_v4.8.0_mxfp8.patch && \ + git -C cutlass apply $(CUTLASS_MK_DIR)cutlass_v4.8.0_mxfp8.patch && \ + grep -q "MXF8F6F4Format::E4M3" cutlass/tools/library/src/block_scaled_gemm_operation_3x.hpp && \ + grep -q "is_supported(arguments->runtime_input_datatype_a)" cutlass/tools/library/src/block_scaled_gemm_operation_3x.hpp + # CUTLASS v4.3.5 generates the GB300 (SM103) FP4 Ultra kernels only for CUDA 13.0+, # but CUTLASS enables SM103 from CUDA 12.9 and they compile to real UTCOMMA kernels # with it. Lower only that generator's gate; the grep fails if it no longer applies. @@ -146,11 +159,12 @@ ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) # - "107a" -> $(CUTLASS_SM107_PREFIX)/{bin,lib} (Rubin) # v4.8.0 extended the INT8 gate to ['100f', '101f', '103a', '107f']. # Dropping '103a' keeps SM100a INT8 as in the 12.9 tier; the grep stops - # the build if the patch no longer applies. + # the build if the patch no longer applies. CUTLASS_V480_MXFP8_PATCH + # fixes the v4.8.0 runtime-typed MXFP8 (ue8m0xf8) SIGSEGV in can_implement(). $(eval CUTLASS_TAG := v4.8.0) $(eval CUTLASS_ARCHS := "100a;103a") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) - $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a', '107f'\]/arch_family_cc = ['100f', '101f', '107f']/" cutlass/python/cutlass_library/generator.py && grep -q "arch_family_cc = \['100f', '101f', '107f'\]" cutlass/python/cutlass_library/generator.py) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a', '107f'\]/arch_family_cc = ['100f', '101f', '107f']/" cutlass/python/cutlass_library/generator.py && grep -q "arch_family_cc = \['100f', '101f', '107f'\]" cutlass/python/cutlass_library/generator.py && $(CUTLASS_V480_MXFP8_PATCH)) $(eval CUTLASS_SM107_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM107))) else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) @@ -177,7 +191,7 @@ else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) $(eval CUTLASS_TAG := v4.3.5) $(eval CUTLASS_ARCHS := "100a;103a") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) - $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py && $(CUTLASS_SM103_ULTRA_PATCH)) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a'\]/arch_family_cc = ['100f', '101f']/" cutlass/python/cutlass_library/generator.py && grep -q "arch_family_cc = \['100f', '101f'\]" cutlass/python/cutlass_library/generator.py && $(CUTLASS_SM103_ULTRA_PATCH)) else ifeq ($(shell echo $(CUDA_VER)">=12.8" | bc -l), 1) # ----------------------------------------------------------------------- diff --git a/third_party/cutlass_v4.8.0_mxfp8.patch b/third_party/cutlass_v4.8.0_mxfp8.patch new file mode 100644 index 000000000..2b8b82041 --- /dev/null +++ b/third_party/cutlass_v4.8.0_mxfp8.patch @@ -0,0 +1,45 @@ +diff --git a/tools/library/src/block_scaled_gemm_operation_3x.hpp b/tools/library/src/block_scaled_gemm_operation_3x.hpp +index a155084..096a09a 100644 +--- a/tools/library/src/block_scaled_gemm_operation_3x.hpp ++++ b/tools/library/src/block_scaled_gemm_operation_3x.hpp +@@ -234,7 +234,11 @@ template + + auto mapping = [](RuntimeDatatype type) { + if constexpr (cute::is_same_v) { +- if (type == RuntimeDatatype::kE3M2) { ++ if (type == RuntimeDatatype::kE5M2) { ++ return cute::UMMA::MXF8F6F4Format::E5M2; ++ } else if (type == RuntimeDatatype::kE4M3) { ++ return cute::UMMA::MXF8F6F4Format::E4M3; ++ } else if (type == RuntimeDatatype::kE3M2) { + return cute::UMMA::MXF8F6F4Format::E3M2; + } else if (type == RuntimeDatatype::kE2M3) { + return cute::UMMA::MXF8F6F4Format::E2M3; +@@ -255,5 +259,27 @@ template + CUTE_GCC_UNREACHABLE; + }; + ++ auto is_supported = [](RuntimeDatatype type) { ++ if constexpr (cute::is_same_v) { ++ return type == RuntimeDatatype::kE5M2 || ++ type == RuntimeDatatype::kE4M3 || ++ type == RuntimeDatatype::kE3M2 || ++ type == RuntimeDatatype::kE2M3 || ++ type == RuntimeDatatype::kE2M1; ++ } ++ else if constexpr (cute::is_same_v) { ++ return type == RuntimeDatatype::kE2M1; ++ } ++ // BlockScaled kernels receive either MXF4Format or MXF8F6F4Format runtime datatype ++ CUTE_GCC_UNREACHABLE; ++ }; ++ ++ // Reject a runtime datatype the kernel cannot represent (including the kStatic default when the ++ // flag is not given) instead of reaching the unreachable path with an undefined format. ++ if (!is_supported(arguments->runtime_input_datatype_a) || ++ !is_supported(arguments->runtime_input_datatype_b)) { ++ return Status::kErrorInvalidProblem; ++ } ++ + operator_args.mainloop.runtime_data_type_a = mapping(arguments->runtime_input_datatype_a); + operator_args.mainloop.runtime_data_type_b = mapping(arguments->runtime_input_datatype_b); From 831965bc1bbfe12c20e2ad7a309f34fba57bdb9f Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 24 Nov 2026 21:34:49 +0000 Subject: [PATCH 28/30] Benchmarks: Upgrade Rubin CUTLASS build to 4.8.1 Upgrade the CUDA 13.4+ CUTLASS tier to v4.8.1 and rename the MXFP8 backport accordingly. Retain the backport because unpatched 4.8.1 still segfaults for E4M3/E5M2 on Rubin; the patched build passes all eight precision smoke tests and independent reference checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- dockerfile/cuda13.4.dockerfile | 2 +- third_party/cutlass.mk | 18 +++++++++--------- ..._mxfp8.patch => cutlass_v4.8.1_mxfp8.patch} | 0 3 files changed, 10 insertions(+), 10 deletions(-) rename third_party/{cutlass_v4.8.0_mxfp8.patch => cutlass_v4.8.1_mxfp8.patch} (100%) diff --git a/dockerfile/cuda13.4.dockerfile b/dockerfile/cuda13.4.dockerfile index 0b54e489a..e81e2d713 100644 --- a/dockerfile/cuda13.4.dockerfile +++ b/dockerfile/cuda13.4.dockerfile @@ -64,7 +64,7 @@ FROM nvcr.io/nvidia/pytorch:26.09-py3 # - This machine is aarch64 (ARM). cpu_hpl, Intel MLC, AOCC and AMD BLIS auto-skip on aarch64. # - CUDA 13.4 builds the in-tree CUDA benchmarks, CUTLASS, NVBench, # cuBLASLt and NCCL tests for sm_107. -# - CUTLASS v4.8.0 is installed twice: GB200/GB300 into ${SB_MICRO_PATH}/{bin,lib} +# - CUTLASS v4.8.1 is installed twice: GB200/GB300 into ${SB_MICRO_PATH}/{bin,lib} # and Rubin (sm_107a) into ${SB_MICRO_PATH}/cutlass_sm107/{bin,lib}. # - streamOlympus is built with GCC 15 in the stream-olympus-builder stage above. # diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 5af28620a..6e1a7e458 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -63,7 +63,7 @@ CUTLASS_KERNELS_SM100 := \ cutlass3x_sm103_bstensorop_gemm_ue4m3xe2m1_ue4m3xe2m1_f32_void_f32_*ultra_2sm*,\ cutlass3x_sm103_bstensorop_gemm_ue4m3xf4_ue4m3xf4_f32_void_f32_*ultra_2sm* -# SM107 Rubin 3x UMMA GEMM kernels (CUTLASS v4.8.0, "107a" build only) +# SM107 Rubin 3x UMMA GEMM kernels (CUTLASS v4.8.1, "107a" build only) # - TF32/FP16/BF16: CUTLASS has no native SM107 generator; it retargets the # SM100 generators to Sm107 when a 107 arch is built, so the names match # the SM100 list with sm107. @@ -95,14 +95,14 @@ space := $(subst ,, ) CUTLASS_MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -# CUTLASS v4.8.0 generates SM107 MXFP8 (ue8m0xf8) as runtime-typed +# CUTLASS v4.8.0 and v4.8.1 generate SM107 MXFP8 (ue8m0xf8) as runtime-typed # MXF8F6F4Format kernels, but BlockScaledGemmUniversal3xOperationBase's # mapping() in tools/library/src/block_scaled_gemm_operation_3x.hpp omitted # kE4M3/kE5M2 and fell into CUTE_GCC_UNREACHABLE (host SIGSEGV in # can_implement()). Backport NVIDIA/cutlass commit 555a0474 to map # kE5M2/kE4M3 and reject unsupported runtime datatypes with kErrorInvalidProblem. -CUTLASS_V480_MXFP8_PATCH = git -C cutlass apply --check $(CUTLASS_MK_DIR)cutlass_v4.8.0_mxfp8.patch && \ - git -C cutlass apply $(CUTLASS_MK_DIR)cutlass_v4.8.0_mxfp8.patch && \ +CUTLASS_V481_MXFP8_PATCH = git -C cutlass apply --check $(CUTLASS_MK_DIR)cutlass_v4.8.1_mxfp8.patch && \ + git -C cutlass apply $(CUTLASS_MK_DIR)cutlass_v4.8.1_mxfp8.patch && \ grep -q "MXF8F6F4Format::E4M3" cutlass/tools/library/src/block_scaled_gemm_operation_3x.hpp && \ grep -q "is_supported(arguments->runtime_input_datatype_a)" cutlass/tools/library/src/block_scaled_gemm_operation_3x.hpp @@ -148,7 +148,7 @@ cutlass_build = cmake -DCMAKE_INSTALL_BINDIR=$(3)/bin \ cuda_cutlass: ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) # ----------------------------------------------------------------------- - # Blackwell GB200/GB300 + Rubin (SM107a) — CUTLASS v4.8.0, two folders + # Blackwell GB200/GB300 + Rubin (SM107a) — CUTLASS v4.8.1, two folders # ----------------------------------------------------------------------- # v4.8.0 is the first release with SM107. With any 107 arch in the list, # it retargets the SM100 generators to SM107 (generator.py @@ -159,12 +159,12 @@ ifeq ($(shell echo $(CUDA_VER)">=13.4" | bc -l), 1) # - "107a" -> $(CUTLASS_SM107_PREFIX)/{bin,lib} (Rubin) # v4.8.0 extended the INT8 gate to ['100f', '101f', '103a', '107f']. # Dropping '103a' keeps SM100a INT8 as in the 12.9 tier; the grep stops - # the build if the patch no longer applies. CUTLASS_V480_MXFP8_PATCH - # fixes the v4.8.0 runtime-typed MXFP8 (ue8m0xf8) SIGSEGV in can_implement(). - $(eval CUTLASS_TAG := v4.8.0) + # the build if the patch no longer applies. CUTLASS_V481_MXFP8_PATCH + # fixes the v4.8.1 runtime-typed MXFP8 (ue8m0xf8) SIGSEGV in can_implement(). + $(eval CUTLASS_TAG := v4.8.1) $(eval CUTLASS_ARCHS := "100a;103a") $(eval CUTLASS_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM100))) - $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a', '107f'\]/arch_family_cc = ['100f', '101f', '107f']/" cutlass/python/cutlass_library/generator.py && grep -q "arch_family_cc = \['100f', '101f', '107f'\]" cutlass/python/cutlass_library/generator.py && $(CUTLASS_V480_MXFP8_PATCH)) + $(eval CUTLASS_PATCHES := sed -i "s/arch_family_cc = \['100f', '101f', '103a', '107f'\]/arch_family_cc = ['100f', '101f', '107f']/" cutlass/python/cutlass_library/generator.py && grep -q "arch_family_cc = \['100f', '101f', '107f'\]" cutlass/python/cutlass_library/generator.py && $(CUTLASS_V481_MXFP8_PATCH)) $(eval CUTLASS_SM107_KERNS := $(call _strip_spaces,$(CUTLASS_KERNELS_SM107))) else ifeq ($(shell echo $(CUDA_VER)">=12.9" | bc -l), 1) diff --git a/third_party/cutlass_v4.8.0_mxfp8.patch b/third_party/cutlass_v4.8.1_mxfp8.patch similarity index 100% rename from third_party/cutlass_v4.8.0_mxfp8.patch rename to third_party/cutlass_v4.8.1_mxfp8.patch From 684c0c935f7e0a7e0f942d897c356aac1cbbd74a Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 1 Dec 2026 18:16:03 +0000 Subject: [PATCH 29/30] Benchmarks: Address gemm-flops review comments - Select the kernel map and CUTLASS install from the capability of CUDA device 0, which honors CUDA_VISIBLE_DEVICES, queried in a child process. - Give the lib folder of the resolved cutlass_profiler install precedence for both automatic and explicit --bin_dir selection. - Install CUTLASS's generated_kernels.txt per prefix and skip precisions without installed kernels (e.g. Hopper FP8 with CUDA 11.8). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../benchmarks/micro-benchmarks.md | 2 + .../cuda_gemm_flops_performance.py | 62 ++++++++++++++++--- superbench/common/utils/device_manager.py | 60 ++++++++++++++++++ .../test_cuda_gemm_flops_performance.py | 50 ++++++++++++++- tests/common/test_device_manager.py | 16 +++++ third_party/cutlass.mk | 5 +- 6 files changed, 184 insertions(+), 11 deletions(-) diff --git a/docs/user-tutorial/benchmarks/micro-benchmarks.md b/docs/user-tutorial/benchmarks/micro-benchmarks.md index 26e3152d6..3ae610c99 100644 --- a/docs/user-tutorial/benchmarks/micro-benchmarks.md +++ b/docs/user-tutorial/benchmarks/micro-benchmarks.md @@ -31,6 +31,8 @@ or AMD [rocblas-bench](https://github.com/ROCmSoftwarePlatform/rocBLAS/tree/deve Available precisions depend on the GPU architecture and the installed CUTLASS build. Vera Rubin (compute capability 10.7) requires CUDA 13.4 or later and the repository-managed CUTLASS build, including its MXFP8 runtime datatype fix. The benchmark automatically selects the dedicated `cutlass_sm107` profiler and its matching libraries on Rubin. +Precisions without kernels in the installed CUTLASS kernel list (`share/cutlass/generated_kernels.txt` next to the +profiler's `bin` folder) are skipped with a warning. Block-scaled modes (`nvfp4_tc`, `nvfp4_ue5m3_tc`, `mxfp8_tc`, and `mxfp4_tc`) disable CUTLASS verification during throughput measurement to avoid running a CPU reference GEMM for every selected kernel at the default matrix size. diff --git a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py index e0f5077c0..d73fa1861 100644 --- a/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py +++ b/superbench/benchmarks/micro_benchmarks/cuda_gemm_flops_performance.py @@ -3,6 +3,7 @@ """Module of the FLOPs performance benchmarks.""" +import fnmatch import os import re @@ -101,6 +102,8 @@ def __init__(self, name, parameters=''): # Compute capabilities whose CUTLASS build lives in its own SB_MICRO_PATH subfolder. self.__cutlass_subdir = {10.7: 'cutlass_sm107'} self.__capability = None + # Install prefix of the selected cutlass_profiler, i.e. the parent of its real bin folder. + self.__install_prefix = None # ',' of CSV rows to parse: legacy SM70/SM80, SM90, SM100, SM103, SM107. # Block-scaled kernels report OperationKind 'gemm' (substring matching also accepts 'block_scaled_gemm'). self.__parse_logline = [ @@ -128,8 +131,8 @@ def _preprocess(self): Return: True if _preprocess() succeed. """ - # Reset kernels according to compute capability. - capability = dm.device_manager.get_device_compute_capability() + # Reset kernels according to the compute capability of the GPU visible to this process. + capability = dm.device_manager.get_visible_device_compute_capability() if capability not in self.__kernel_map: # After preprocess() self._result.return_code can be generated super()._preprocess() @@ -148,6 +151,9 @@ def _preprocess(self): if not super()._preprocess(): return False + if not self.__filter_installed_precisions(): + return False + for p in self._precision_need_to_run: kernels = self.__kernel_map[capability][p] command = os.path.join(self._args.bin_dir, self._bin_name) @@ -170,6 +176,40 @@ def _preprocess(self): return True + def __filter_installed_precisions(self): + """Skip precisions whose kernels are not in the installed CUTLASS kernel list. + + CUTLASS v3.x and later install the list of generated kernels to /share/cutlass/generated_kernels.txt + (third_party/cutlass.mk). Without that list, e.g. for CUTLASS v2.x, all precisions are kept. + + Return: + True if at least one precision remains to run. + """ + kernel_list = os.path.join(self.__install_prefix, 'share', 'cutlass', 'generated_kernels.txt') + if not os.path.isfile(kernel_list): + return True + with open(kernel_list) as f: + installed = [line.strip() for line in f if line.strip()] + + precisions = list() + for p in self._precision_need_to_run: + # cutlass_profiler matches --kernels patterns anywhere in the kernel name. + pattern = '*' + self.__kernel_map[self.__capability][p] + '*' + if any(fnmatch.fnmatchcase(name, pattern) for name in installed): + precisions.append(p) + else: + logger.warning( + 'No installed CUTLASS kernels - benchmark: {}, precision: {}, kernel list: {}.'.format( + self._name, p, kernel_list + ) + ) + self._precision_need_to_run = precisions + + if len(self._precision_need_to_run) == 0: + self._result.set_return_code(ReturnCode.NO_SUPPORTED_PRECISION) + return False + return True + def _set_binary_path(self): """Search cutlass_profiler in the per-architecture CUTLASS install unless --bin_dir is given. @@ -178,11 +218,19 @@ def _set_binary_path(self): """ subdir = self.__cutlass_subdir.get(self.__capability) if subdir and self._args.bin_dir is None and os.getenv('SB_MICRO_PATH'): - prefix = os.path.join(os.getenv('SB_MICRO_PATH'), subdir) - self._args.bin_dir = os.path.join(prefix, 'bin') - # LD_LIBRARY_PATH outranks RUNPATH, so put this build's libcutlass*.so ahead of SB_MICRO_PATH/lib. - os.environ['LD_LIBRARY_PATH'] = os.path.join(prefix, 'lib') + os.pathsep + os.getenv('LD_LIBRARY_PATH', '') - return super()._set_binary_path() + self._args.bin_dir = os.path.join(os.getenv('SB_MICRO_PATH'), subdir, 'bin') + if not super()._set_binary_path(): + return False + self._args.bin_dir = os.path.abspath(self._args.bin_dir) + self.__install_prefix = os.path.dirname( + os.path.dirname(os.path.realpath(os.path.join(self._args.bin_dir, self._bin_name))) + ) + # cutlass_profiler only runs kernels from its own build's libcutlass*.so, and LD_LIBRARY_PATH outranks RUNPATH, + # so put the lib folder of the selected install ahead of SB_MICRO_PATH/lib. + lib_dir = os.path.join(self.__install_prefix, 'lib') + if os.path.isdir(lib_dir): + os.environ['LD_LIBRARY_PATH'] = lib_dir + os.pathsep + os.getenv('LD_LIBRARY_PATH', '') + return True def _process_raw_result(self, cmd_idx, raw_output): """Function to parse raw results and save the summarized results. diff --git a/superbench/common/utils/device_manager.py b/superbench/common/utils/device_manager.py index cdcf66e9d..5ecf2052e 100644 --- a/superbench/common/utils/device_manager.py +++ b/superbench/common/utils/device_manager.py @@ -4,6 +4,8 @@ """Device Management Library Utility.""" import numbers +import subprocess +import sys from typing import Optional from superbench.common.utils import logger @@ -23,6 +25,31 @@ _AMDSMI_MICROWATTS_PER_WATT = 1_000_000 _AMDSMI_MICROWATTS_THRESHOLD = 100_000 +# Prints " " of CUDA device 0 using the driver API, which creates no CUDA context. +_CUDA_DEVICE_0_CAPABILITY_SCRIPT = """ +import ctypes +import sys + +cuda = ctypes.CDLL('libcuda.so.1') +cuda.cuInit.argtypes = [ctypes.c_uint] +cuda.cuDeviceGet.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.c_int] +cuda.cuDeviceGetAttribute.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.c_int, ctypes.c_int] +device, major, minor = ctypes.c_int(), ctypes.c_int(), ctypes.c_int() + + +def check(name, ret): + if ret != 0: + sys.exit('{} failed with CUresult {}'.format(name, ret)) + + +check('cuInit', cuda.cuInit(0)) +check('cuDeviceGet', cuda.cuDeviceGet(ctypes.byref(device), 0)) +# CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76 +check('cuDeviceGetAttribute', cuda.cuDeviceGetAttribute(ctypes.byref(major), 75, device)) +check('cuDeviceGetAttribute', cuda.cuDeviceGetAttribute(ctypes.byref(minor), 76, device)) +print(major.value, minor.value) +""" + def _amdsmi_power_to_watts(value): """Convert an amdsmi power value to integer watts. @@ -59,6 +86,14 @@ def get_device_compute_capability(self): """ return None + def get_visible_device_compute_capability(self): + """Get the compute capability of the first device visible to this process. + + Return: + cap (float): the compute capability of device, None means failed to get the data. + """ + return None + def get_device_utilization(self, idx): """Get the utilization of device. @@ -175,6 +210,31 @@ def get_device_compute_capability(self): return None return cap + def get_visible_device_compute_capability(self): + """Get the compute capability of CUDA device 0, which honors CUDA_VISIBLE_DEVICES unlike NVML indices. + + The CUDA driver is queried in a child process so that this process does not initialize CUDA. + + Return: + cap (float): the compute capability of device, None means failed to get the data. + """ + try: + output = subprocess.run([sys.executable, '-c', _CUDA_DEVICE_0_CAPABILITY_SCRIPT], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + timeout=60, + check=True).stdout.split() + major, minor = int(output[0]), int(output[1]) + except subprocess.CalledProcessError as err: + logger.warning('Get visible device compute capability failed: {}'.format(err.stderr.strip())) + return None + except Exception as err: + logger.warning('Get visible device compute capability failed: {}'.format(str(err))) + return None + # Same format as nvmlDeviceGetCudaComputeCapability() in py3nvml. + return major + 0.1 * minor + def get_device_utilization(self, idx): """Get the utilization of device. diff --git a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py index 520bbac61..c703d74f9 100644 --- a/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py +++ b/tests/benchmarks/micro_benchmarks/test_cuda_gemm_flops_performance.py @@ -5,6 +5,7 @@ import fnmatch import os +import tempfile import unittest from unittest import mock @@ -21,7 +22,9 @@ def setUpClass(cls): """Hook method for setting up class fixture before running tests in the class.""" super().setUpClass() cls.createMockEnvs(cls) - cls.createMockFiles(cls, ['bin/cutlass_profiler', 'cutlass_sm107/bin/cutlass_profiler']) + cls.createMockFiles( + cls, ['bin/cutlass_profiler', 'cutlass_sm107/bin/cutlass_profiler', 'cutlass_sm107/lib/libcutlass.so'] + ) @decorator.cuda_test def test_flops_performance_cuda(self): @@ -38,7 +41,8 @@ def test_flops_performance_cuda(self): ) ret = benchmark._preprocess() - if dm.device_manager.get_device_compute_capability() not in benchmark._CudaGemmFlopsBenchmark__kernel_map: + if dm.device_manager.get_visible_device_compute_capability( + ) not in benchmark._CudaGemmFlopsBenchmark__kernel_map: assert (ret is False) assert (benchmark.return_code == ReturnCode.MICROBENCHMARK_UNSUPPORTED_ARCHITECTURE) else: @@ -360,7 +364,7 @@ def test_flops_performance_cuda_sm107_commands(self): assert (benchmark_class) prefix = os.path.join(self._tmp_dir, 'cutlass_sm107') - with mock.patch.object(dm.device_manager, 'get_device_compute_capability', return_value=10.7): + with mock.patch.object(dm.device_manager, 'get_visible_device_compute_capability', return_value=10.7): with mock.patch.dict(os.environ): benchmark = benchmark_class( benchmark_name, @@ -394,9 +398,49 @@ def test_flops_performance_cuda_sm107_commands(self): assert (benchmark._preprocess() is False) assert (benchmark.return_code == ReturnCode.NO_SUPPORTED_PRECISION) + # An explicit --bin_dir of the Rubin install also gets its lib folder first in LD_LIBRARY_PATH. + with mock.patch.dict(os.environ): + benchmark = benchmark_class( + benchmark_name, parameters='--precision fp16_tc --bin_dir ' + os.path.join(prefix, 'bin') + ) + assert (benchmark._preprocess() is True) + assert (os.environ['LD_LIBRARY_PATH'].split(os.pathsep)[0] == os.path.join(prefix, 'lib')) + assert (benchmark._args.bin_dir == os.path.join(prefix, 'bin')) + # An explicit --bin_dir takes precedence over the per-architecture install. bin_dir = os.path.join(self._tmp_dir, 'bin') with mock.patch.dict(os.environ): benchmark = benchmark_class(benchmark_name, parameters='--precision fp16_tc --bin_dir ' + bin_dir) assert (benchmark._preprocess() is True) assert (benchmark._args.bin_dir == bin_dir) + + def test_flops_performance_cuda_installed_kernels(self): + """Test gemm-flops benchmark skips precisions without kernels in the installed CUTLASS kernel list.""" + benchmark_name = 'gemm-flops' + (benchmark_class, + predefine_params) = BenchmarkRegistry._BenchmarkRegistry__select_benchmark(benchmark_name, Platform.CUDA) + assert (benchmark_class) + + with tempfile.TemporaryDirectory() as prefix: + bin_dir = os.path.join(prefix, 'bin') + os.makedirs(bin_dir) + profiler = os.path.join(bin_dir, 'cutlass_profiler') + open(profiler, 'w').close() + os.chmod(profiler, 0o755) + # A legacy-only build (e.g. CUDA 11.8) has no Hopper FP8 kernels. + os.makedirs(os.path.join(prefix, 'share', 'cutlass')) + with open(os.path.join(prefix, 'share', 'cutlass', 'generated_kernels.txt'), 'w') as f: + f.write('cutlass_simt_sgemm_128x128_8x2_nn_align1\n') + f.write('cutlass_tensorop_h16816gemm_256x128_32x3_nn_align8\n') + + with mock.patch.object(dm.device_manager, 'get_visible_device_compute_capability', return_value=9.0): + with mock.patch.dict(os.environ): + benchmark = benchmark_class(benchmark_name, parameters='--bin_dir ' + bin_dir) + assert (benchmark._preprocess() is True) + assert (benchmark._precision_need_to_run == ['fp32', 'fp16_tc']) + assert (len(benchmark._commands) == 2) + + with mock.patch.dict(os.environ): + benchmark = benchmark_class(benchmark_name, parameters='--precision fp8_tc --bin_dir ' + bin_dir) + assert (benchmark._preprocess() is False) + assert (benchmark.return_code == ReturnCode.NO_SUPPORTED_PRECISION) diff --git a/tests/common/test_device_manager.py b/tests/common/test_device_manager.py index 96ef66363..aeb5fee7b 100644 --- a/tests/common/test_device_manager.py +++ b/tests/common/test_device_manager.py @@ -188,3 +188,19 @@ def test_amd_device_manager_lifecycle(): bad_rocml.amdsmi_shut_down.side_effect = RuntimeError('rocm gone') with mock.patch(f'{_DM_MODULE}.rocml', bad_rocml, create=True): manager2.__del__() # must not raise + + +def test_nvidia_get_visible_device_compute_capability(): + """The capability of CUDA device 0 comes from a child process; failures return None.""" + class _NvidiaManager(dm.NvidiaDeviceManager): + def __del__(self): + pass + + manager = _NvidiaManager.__new__(_NvidiaManager) + with mock.patch(f'{_DM_MODULE}.subprocess.run') as run: + run.return_value.stdout = '10 7\n' + assert manager.get_visible_device_compute_capability() == 10.7 + assert run.call_args[0][0][1:] == ['-c', dm._CUDA_DEVICE_0_CAPABILITY_SCRIPT] + + run.side_effect = dm.subprocess.CalledProcessError(1, 'python', stderr='cuDeviceGet failed with CUresult 100') + assert manager.get_visible_device_compute_capability() is None diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 6e1a7e458..2f98f4fc0 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -112,9 +112,12 @@ CUTLASS_V481_MXFP8_PATCH = git -C cutlass apply --check $(CUTLASS_MK_DIR)cutlass CUTLASS_SM103_ULTRA_PATCH = sed -i "/^def GenerateSM103_TensorOp_fp4_ultra_UMMA_gemm_with_block_scaled/,/return/s/(cuda_version, 13, 0)/(cuda_version, 12, 9)/" cutlass/python/cutlass_library/generator.py && grep -A3 "^def GenerateSM103_TensorOp_fp4_ultra_UMMA_gemm_with_block_scaled" cutlass/python/cutlass_library/generator.py | grep -q "(cuda_version, 12, 9)" # $(call cutlass_build,,,,) -# Configures, builds and installs ./cutlass into /{bin,lib}. +# Configures, builds and installs ./cutlass into /{bin,lib}. CUTLASS v3.x+ also installs the +# generated kernel list to /share/cutlass/generated_kernels.txt; cuda_gemm_flops_performance.py +# skips precisions that have no kernel in it. cutlass_build = cmake -DCMAKE_INSTALL_BINDIR=$(3)/bin \ -DCMAKE_INSTALL_LIBDIR=$(3)/lib \ + -DCMAKE_INSTALL_INFODIR=$(3)/share \ -DCMAKE_BUILD_TYPE=Release \ -DCUTLASS_NVCC_ARCHS=$(1) \ -DCUTLASS_ENABLE_EXAMPLES=OFF \ From f368a344e60cdf93e0d1fd3a3b7b104d90be1418 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Tue, 1 Dec 2026 20:29:54 +0000 Subject: [PATCH 30/30] Benchmarks: Verify CUTLASS tag commits and fix yapf format - Restore the expected-commit check after cloning CUTLASS (dropped when merging main's CUDA 13.5 tier); every tier's tag now maps to a pinned commit. - Reformat the subprocess.run call in device_manager.py as yapf 0.31.0 expects (Run code lint failure in cpu-unit-test and cuda-unit-test). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- superbench/common/utils/device_manager.py | 14 ++++++++------ third_party/cutlass.mk | 12 ++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/superbench/common/utils/device_manager.py b/superbench/common/utils/device_manager.py index 5ecf2052e..6061e4559 100644 --- a/superbench/common/utils/device_manager.py +++ b/superbench/common/utils/device_manager.py @@ -219,12 +219,14 @@ def get_visible_device_compute_capability(self): cap (float): the compute capability of device, None means failed to get the data. """ try: - output = subprocess.run([sys.executable, '-c', _CUDA_DEVICE_0_CAPABILITY_SCRIPT], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True, - timeout=60, - check=True).stdout.split() + output = subprocess.run( + [sys.executable, '-c', _CUDA_DEVICE_0_CAPABILITY_SCRIPT], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True, + timeout=60, + check=True + ).stdout.split() major, minor = int(output[0]), int(output[1]) except subprocess.CalledProcessError as err: logger.warning('Get visible device compute capability failed: {}'.format(err.stderr.strip())) diff --git a/third_party/cutlass.mk b/third_party/cutlass.mk index 2f98f4fc0..0bb4be3c2 100644 --- a/third_party/cutlass.mk +++ b/third_party/cutlass.mk @@ -136,7 +136,7 @@ cutlass_build = cmake -DCMAKE_INSTALL_BINDIR=$(3)/bin \ # cuda_cutlass target # --------------------------------------------------------------------------- # Each CUDA version tier selects: -# CUTLASS_TAG — git tag to clone +# CUTLASS_TAG — git tag to clone; must have an entry in CUTLASS_COMMIT_ # CUTLASS_ARCHS — semicolon-separated NVCC arch list # CUTLASS_KERNS — comma-separated kernel filter patterns # CUTLASS_PATCHES — optional post-clone fixups (sed commands, etc.) @@ -146,6 +146,12 @@ cutlass_build = cmake -DCMAKE_INSTALL_BINDIR=$(3)/bin \ # After the version-specific block, a shared section clones, patches, # configures, builds, and installs. +# Expected commit of each CUTLASS tag; the clone fails if a tag has moved. +CUTLASS_COMMIT_v2.4.0 := ccb697bac77fcc898e9c897b2c90aa5b60ac72fb +CUTLASS_COMMIT_v3.9.2 := ad7b2f5e84fcfa124cb02b91d5bd26d238c0459e +CUTLASS_COMMIT_v4.3.5 := 4faf1a1568cf1e4ad8ff71846a13e16f2a6a6f6b +CUTLASS_COMMIT_v4.8.1 := 2c85f497547eb441f0fe80bfb0fb2e6f9add1719 + .PHONY: cuda_cutlass cuda_cutlass: @@ -252,7 +258,9 @@ endif # R_AARCH64_PREL32 ±2 GB limit on aarch64. Unwind table suppression # further reduces .eh_frame pressure. if [ -d cutlass ]; then rm -rf cutlass; fi - git clone --branch $(CUTLASS_TAG) --depth 1 https://github.com/NVIDIA/cutlass.git + git clone --branch $(CUTLASS_TAG) --depth 1 https://github.com/NVIDIA/cutlass.git && \ + test -n "$(CUTLASS_COMMIT_$(CUTLASS_TAG))" && \ + test "$$(git -C cutlass rev-parse HEAD)" = "$(CUTLASS_COMMIT_$(CUTLASS_TAG))" $(CUTLASS_PATCHES) $(call cutlass_build,$(CUTLASS_ARCHS),$(CUTLASS_KERNS),$(SB_MICRO_PATH),./cutlass/build) $(if $(CUTLASS_SM107_KERNS),$(call cutlass_build,"107a",$(CUTLASS_SM107_KERNS),$(CUTLASS_SM107_PREFIX),./cutlass/build_sm107))