Skip to content

Commit d783300

Browse files
Port gfx950 dispatch tuning (short_max + dead_block_trim + midbatch cap) onto Robin base
1 parent 5383b16 commit d783300

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎aiter/ops/flydsl/topk_per_row_decode.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,28 @@ def _default_kernel_config(
145145
max_active_parts = max(tiered_mid_cap_default, tiered_long_cap_default)
146146
blocks_per_row = max(2, min(blocks_per_row, max_active_parts))
147147

148+
# Mid-batch coordination cap (gfx950 only). Once the batch alone fills the device
149+
# (num_rows > 16), the co-resident budget over-provisions blocks_per_row; the measured
150+
# cooperation optimum in the multi-block regime is well below it. Cap blocks_per_row by
151+
# a small L-keyed step. Only reduces blocks_per_row (a min), so results stay valid.
152+
# (The rows>63 short-mid cap of 1 is omitted; it needs the kernel's single-workgroup
153+
# launch path.) Env FLYDSL_TOPK_TIERED_MIDBATCH_CAP overrides the matched cap (0 off).
154+
if arch == "gfx950" and max_model_len > tiered_short_max:
155+
mb_cap = None
156+
for mb_min_rows, mb_L_max, mb_cap_val in (
157+
(16, 131072, 4),
158+
(20, None, 6),
159+
(16, None, 8),
160+
):
161+
if num_rows > mb_min_rows and (mb_L_max is None or max_model_len <= mb_L_max):
162+
mb_cap = mb_cap_val
163+
break
164+
mb_env = _env_int("FLYDSL_TOPK_TIERED_MIDBATCH_CAP")
165+
if mb_env is not None and mb_cap is not None:
166+
mb_cap = mb_env
167+
if mb_cap:
168+
blocks_per_row = max(2, min(blocks_per_row, mb_cap))
169+
148170
return dict(
149171
blocks_per_row=blocks_per_row,
150172
bits_per_pass=bits_per_pass,

0 commit comments

Comments
 (0)