Skip to content

perf(core): wire the pooled paged-attention decode entry point into the scheduler or retire it #710

Closed

Description

@inureyes

Problem / Background

  • PR perf(core): adaptive selector for the native paged-attention decode kernel #709 (issue perf(core): adaptive selector for the native paged-attention decode kernel #331) added an adaptive selector to paged_decode_attention_pooled in src/lib/mlxcel-core/src/layers.rs so the fused Metal paged-attention kernel dispatches only in its measured winning regime (docs/adr/0001-paged-attention-gather-vs-fused-kernel.md). The PR perf(core): adaptive selector for the native paged-attention decode kernel #709 review then established that paged_decode_attention_pooled has NO production caller: under the scheduler's paged backend, pool-backed model layers gate out of the native path (e.g. src/models/llama3.rs is_paged_backed() returning the native-kernel arm None) and route through the per-sequence update_and_fetch pool intercept, which gathers the visible window (CachePool gather_visible, src/lib/mlxcel-core/src/cache.rs around line 2669) and runs standard SDPA. Production models call paged_decode_attention_dense_compat / _fallback, never _pooled.
  • The selector, the fused kernel behind it, and the tri-state MLXCEL_PAGED_ATTENTION_NATIVE override are therefore exercised today only by examples/paged_attention_kernel_bench.rs, the unit/FFI tests, and external mlxcel-core API consumers. Inside mlxcel-server they are latent.

Current state (post PR #709, M1 Ultra bench)

  • The reachable native win regime is the single-slab batched island: B>=4 at context <=256 tokens (block_size 32 slabs hold 32 blocks), measured 1.34x-1.94x over gather. Everything else is B=1 (kernel loses, 0.81-0.92x) or multi-slab (kernel declines).
  • ADR 0001's adaptive-selector addendum records both the selector thresholds and the reachability caveat.

Proposed direction

Decide between two exits, with trace evidence:

  1. Wire in: add a scheduler/model decode arm that calls paged_decode_attention_pooled for pool-backed Fp16 layers, so the selector picks native on the single-slab batched island in real serving. Requires the batched-decode dispatch in each transformer family to thread batch/visible/slab inputs, and a real-model A/B (short-context batched decode, e.g. B=4/8 with prompts <=256 tokens) proving the island materializes end to end and nothing regresses elsewhere.
  2. Retire: if server traces show the single-slab island is negligible in production workloads (contexts under ~256 tokens at B>=4 are rare in chat serving), remove the pooled entry point (or explicitly mark it a library-only API) and record the decision in ADR 0001.

Either way the multi-slab kernel spike stays gated behind live-trace evidence, per issue #331 and the ADR.

Acceptance criteria

  • A decision (wire in vs retire/library-only) recorded in ADR 0001 with trace or A/B evidence. Decision: retire to a library-only API (occupancy derivation in ADR 0001, perf(core): wire the pooled paged-attention decode entry point into the scheduler or retire it #710 section).
  • If wired in: real-model batched short-context A/B numbers on Apple Silicon showing the island win end to end, plus no-regression checks at B=1 and long context.
  • If retired: the pooled entry point removed or documented as library-only, tests/bench adjusted accordingly. Documented as library-only (kept + tested; use_native_paged_kernel left in place as it is shared with the live dense_compat path).

References

Activity

  1. added
    status:backlog
    type:performance
    priority:low
    area:core
    area:inference
    on Jul 9, 2026
  2. added
    status:in-progress
    status:review
    status:done
    and removed
    status:backlog
    status:in-progress
    status:review
    on Jul 9, 2026
  3. added a commit that references this issue on Jul 30, 2026
    8b2329c
  4. self-assigned this
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:corearea:inferencepriority:lowstatus:donetype:performance

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions