@@ -76,20 +76,31 @@ def select_2d_config(
7676
7777 # base prefill, for short cases
7878 if not all_decode :
79- num_stages_2d , num_warps = 1 , 2
79+ if head_size >= 512 and not arch .is_rdna :
80+ BLOCK_M = max (16 , triton .next_power_of_2 (num_queries_per_kv ))
81+ num_warps , num_stages_2d = 4 , 1
82+ elif head_size >= 256 and not arch .is_rdna :
83+ num_warps , num_stages_2d = 2 , 2
84+ TILE_SIZE = 32
85+ else :
86+ # large prefill config
87+ if max_seqlen_q >= 256 :
88+ BLOCK_M = 64 if arch .is_rdna else 128
89+ num_stages_2d , num_warps = 1 , 4
90+ else :
91+ num_stages_2d , num_warps = 1 , 2
92+
8093 # pure decode config
8194 else :
8295 # to not have masking when loading KV
8396 TILE_SIZE = min (64 , triton .next_power_of_2 (block_size ))
8497 if arch .is_rdna :
8598 num_stages_2d , num_warps = 1 , 4
8699 else :
87- num_stages_2d , num_warps = 3 , 2
88-
89- # large prefill config
90- if max_seqlen_q >= 256 :
91- BLOCK_M = 64 if arch .is_rdna else 128
92- num_stages_2d , num_warps = 1 , 4
100+ if head_size >= 512 :
101+ num_stages_2d , num_warps = 1 , 4
102+ else :
103+ num_stages_2d , num_warps = 3 , 2
93104
94105 BLOCK_Q = BLOCK_M // num_queries_per_kv
95106 num_stages_2d = min (max_num_stages_2d , num_stages_2d )
@@ -178,13 +189,18 @@ def select_3d_config(
178189 # attn_warps = max(attn_warps, 1)
179190 # attn_warps = min(attn_warps, 4)
180191 else :
192+ if head_size >= 512 and not get_arch ().is_rdna :
193+ attn_warps , attn_stages = 4 , 1
194+
181195 occ = waves_per_eu * 4 // attn_warps
182196 target_num_prgms = target_num_prgms * occ
183197
184198 TILE_SIZE = min (64 , triton .next_power_of_2 (block_size ))
185199
186200 MAX_SEGMENTS = min (128 , math .ceil (max_seqlen_k / TILE_SIZE ))
187201 MIN_SEGMENTS = min (8 , MAX_SEGMENTS )
202+ if head_size >= 512 and not get_arch ().is_rdna :
203+ MIN_SEGMENTS = min (16 , MAX_SEGMENTS )
188204 if num_segments == 0 :
189205 num_segments = math .ceil (target_num_prgms / num_2d_prgms )
190206 num_segments = min (num_segments , MAX_SEGMENTS )
0 commit comments