Skip to content

Commit 72c7745

Browse files
samremescursoragent
andcommitted
Tune FlyDSL TopK long-row cap
Co-authored-by: Cursor <[email protected]>
1 parent 555569b commit 72c7745

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎aiter/ops/flydsl/topk_per_row_decode.py‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,16 +419,17 @@ def flydsl_top_k_per_row_decode(
419419
"FLYDSL_TOPK_AITER_PERSISTENT_TIERED_SHORT_MAX", 16384
420420
)
421421
# Per-bucket active-part caps over the fixed launch grid. The
422-
# optimum scales down with batch size: a single decode row wants
423-
# ~16 parts (more only adds barrier/global-histogram-merge cost),
424-
# while multi-row batches already fill the device so fewer parts
425-
# per row cut barrier/atomic contention. Measured sweep optima
426-
# (gfx942, 304 CU, K=512, mw=256000): rows=1 -> mid/long 16;
427-
# rows>=2 -> mid 8; rows>=8 -> long 8. ``long_cap`` is never
428-
# better at 32 than 16 at any measured row count, so 32 is
429-
# dropped as a default.
422+
# optimum scales down with batch size: a single long decode row
423+
# benefits from the full g32 active set, while multi-row batches
424+
# already fill the device so fewer parts per row cut barrier and
425+
# global-histogram merge cost.
430426
default_mid_cap = 16 if int(numRows) <= 1 else 8
431-
default_long_cap = 8 if int(numRows) >= 8 else 16
427+
if int(numRows) <= 1:
428+
default_long_cap = 32
429+
elif int(numRows) >= 8:
430+
default_long_cap = 8
431+
else:
432+
default_long_cap = 16
432433
tiered_mid_cap = _env_int(
433434
"FLYDSL_TOPK_AITER_PERSISTENT_TIERED_MID_CAP", default_mid_cap
434435
)

0 commit comments

Comments
 (0)