Skip to content

Commit c06b8db

Browse files
committed
Update comments
1 parent 755df3b commit c06b8db

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

‎aiter/ops/flydsl/topk_per_row_decode.py‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
# the O(L) scan.
2929
_TIERED_MID_MAX = 65536
3030

31-
# Batch-aware short-vs-multi-block crossover per arch for
32-
# short_max = min(cap, base + num_rows*slope).
31+
# The short-vs-multi-block crossover is independent of K for the same reason,
32+
# but does depend on the rows: short_max = min(cap, base + num_rows*slope).
3333
# These params were found empirically on MI300X and MI355X
3434
_SHORT_MAX_PARAMS = {
3535
# arch: (base, slope, cap)
@@ -148,7 +148,10 @@ def _apply_deadlock_guard(
148148
max_model_len: int,
149149
) -> dict:
150150
"""Clamp the tiered config so the mid/long-tier inter-workgroup barrier cannot
151-
deadlock.
151+
deadlock. The possibility of deadlock requires both a wide batch (num_rows > ~80-90)
152+
and long rows (L > ~16-40K). Note: The HIP kernel also redirects to a
153+
single-workgroup tier for large batch-sizes, but doesn't explicitly call out the
154+
deadlock risk (see the should_use_mulblocks function).
152155
153156
The tiered kernels spin on a barrier over a non-cooperative launch, which gives
154157
no guarantee that a row's participating workgroups are all resident at the same
@@ -157,9 +160,6 @@ def _apply_deadlock_guard(
157160
workgroups exceeds the resident capacity. In this case, we cap the active
158161
workgroups or force the barrier-free short tier (single workgroup/row).
159162
160-
No-op unless rows can reach the barrier tiers (max_model_len > short_max)
161-
at a batch large enough to matter, so the common decode shape is untouched.
162-
163163
Example for MI300X:
164164
The deadlock guard is active around num_rows >= 87 with max_model_len > 32768
165165
CUs * Occupancy = 304 * 2 = 608
@@ -203,14 +203,8 @@ def _apply_deadlock_guard(
203203
kernel_config["tiered_mid_cap"] = min(mid_cap, max_safe_active_workgroups)
204204
kernel_config["tiered_long_cap"] = min(long_cap, max_safe_active_workgroups)
205205
else:
206-
# Even 2-way cooperation exceeds the envelope: route every row to the
207-
# barrier-free short tier. Requires bits_per_pass == 11 (the short tier);
208-
# target archs (gfx942/gfx950) satisfy this.
209206
kernel_config["tiered_short_max"] = max_model_len
210207

211-
# Keep the mid_max >= short_max validator happy when max_model_len exceeds
212-
# the default mid_max. The tiered kernel builder rejects short_max > mid_max
213-
# at compile time.
214208
kernel_config["tiered_mid_max"] = max(
215209
kernel_config["tiered_mid_max"], max_model_len
216210
)

0 commit comments

Comments
 (0)