Skip to content

Commit 8526dcb

Browse files
committed
fix(attention): plan sparse prefill rows to a power-of-two max batch
Sparse prefill plans a row a query token, and past 4096 rows set the plan's max_batch_size to the row count. With aiter #7205 the FlyDSL planner compiles per max_batch_size, so every new prompt length compiled one (~0.25-0.4 s on its first TTFT). A power of two within the planner's LDS bound keeps it to one compile per bucket. MiniMax-M3 TP4 on MI455 with #7205: a new prompt length's TTFT 0.48 -> 0.10 s (9.6K tokens) once its bucket is warm.
1 parent a10e4b4 commit 8526dcb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎atom/model_ops/base_attention.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,12 @@ def _flydsl_prepare_explicit_plan(
567567
)
568568
# A refresh keeps the plan's max_batch_size, so set it at creation.
569569
if num_seqs > _FLYDSL_PLAN_MAX_BATCH:
570-
budget["max_batch_size"] = num_seqs
570+
# A power of two (within the planner's LDS bound), not the row
571+
# count: the planner compiles per max_batch_size (aiter #7205), and
572+
# sparse prefill plans a row a query token.
573+
budget["max_batch_size"] = max(
574+
num_seqs, min(1 << (num_seqs - 1).bit_length(), _flydsl_plan_max_batch())
575+
)
571576
plan = plan_pa_decode(
572577
lengths,
573578
num_kv_heads,

0 commit comments

Comments
 (0)