You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before changing storage, measure the decode-time cost of gathering scattered physical blocks on MLX, and decide between two attention strategies:
(A) gather-then-SDPA: use take / concatenate to materialize a contiguous K/V per sequence from scattered blocks, then call the existing fused scaled_dot_product_attention. Small delta from the current paged_decode_attention_dense_compat.
(B) fused Metal paged-attention kernel: a custom kernel modeled on src/lib/mlx-cpp/turbo/sparse_v_sdpa.metal that reads scattered blocks directly with no gather copy.
This spike de-risks the whole epic by quantifying the (A) gather cost so we know whether and when (B) is worth building.
Tasks
Microbench per-step take(pool, block_ids) + reshape + fused SDPA vs the current contiguous-slice path, across context lengths (1k / 4k / 16k / 32k) and batch sizes, on Apple Silicon. Reuse the harness described in docs/bridge-overhead-microbench.md.
Record block-size sensitivity (16 / 32 / 64) on gather cost and on fragmentation.
Decide the global pool tensor layout (per-layer [num_blocks, block_size, n_kv_heads, head_dim] vs a head-split layout) based on take / slice_update performance.
Write an ADR under docs/ recommending (A) first and (B) as a later optimization, including the measured crossover context length where gather cost becomes material.
Acceptance criteria
Microbench numbers committed and reproducible.
ADR merged with a layout decision and a kernel-strategy decision the downstream phases can follow.
Activity
perf: page-gather decode microbench and paged-attention ADR (#145)
perf: page-gather decode microbench and paged-attention ADR (lablup#145)