Skip to content

Commit 093461d

Browse files
committed
Tune NVFP4 middle-K row tiles
1 parent 14bd8e1 commit 093461d

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

test/test_nvfp4_tma.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ def test_select_nvfp4_tma_compute_warps(k, block_n, expected):
5252
(4096, 14336, (8, 2, 4)),
5353
(8192, 14336, (8, 3, 4)),
5454
(8192, 28672, (8, 3, 4)),
55-
(12288, 16384, (8, 2, 4)),
56-
(14336, 16384, (8, 3, 4)),
55+
(9216, 16384, (8, 3, 4)),
56+
(10240, 16384, (16, 2, 4)),
57+
(12288, 16384, (16, 2, 4)),
58+
(14336, 16384, (16, 2, 4)),
59+
(18432, 24576, (16, 2, 4)),
60+
(18432, 25600, (8, 3, 4)),
61+
(20480, 24576, (8, 3, 4)),
5762
(24576, 24576, (8, 2, 4)),
5863
(32768, 32768, (8, 3, 4)),
5964
(16384, 8192, (8, 2, 4)),

transformer_nuggets/cute/nvfp4_tma.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,19 @@ def select_nvfp4_tma_config(
757757
block_n = next(candidate for candidate in (8, 4, 2, 1) if n % candidate == 0)
758758
return block_n, 2, 1
759759
use_compact_scale_tile = n >= 16384 and 6144 <= k <= 8192
760-
preferred_block_n = 16 if n >= 12288 and k < 12288 and not use_compact_scale_tile else 8
760+
use_wide_middle_k_tile = 10240 <= n <= 18432 and 16384 <= k <= 24576
761+
preferred_block_n = (
762+
16
763+
if (n >= 12288 and k < 12288 and not use_compact_scale_tile) or use_wide_middle_k_tile
764+
else 8
765+
)
761766
block_n = next(
762767
candidate for candidate in (preferred_block_n, 8, 4, 2, 1) if n % candidate == 0
763768
)
764769
num_compute_warps = select_nvfp4_tma_compute_warps(k, block_n, device)
765-
if k >= 16384 and block_n == 8 and num_compute_warps == 4:
770+
if use_wide_middle_k_tile and block_n == 16:
771+
num_stages = 2
772+
elif k >= 16384 and block_n == 8 and num_compute_warps == 4:
766773
num_tiles = n // block_n
767774
num_sms = torch.cuda.get_device_properties(device).multi_processor_count
768775
s2_waves = (num_tiles + 12 * num_sms - 1) // (12 * num_sms)

0 commit comments

Comments
 (0)