Repository navigation
Closed
Labels
area:coremlxcel-core: MLX FFI, primitives, KV cache, layersarea:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:mediumMedium prioritystatus:doneCompletedtype:performancePerformance improvements
Milestone
Description
Summary
When a collected prefill batch contains one incompatible request, the scheduler currently falls the WHOLE window back to sequential prefill. Instead, split the window into compatible cohorts so eligible concurrent work still runs batched.
Source: idea.md "4. Batched Prefill Cohort Splitting" (P1, expected payoff medium, risk medium).
Current state
- Batched prefill is available only when the model opts in via
supports_batched_prefill(); the default is false (src/lib/mlxcel-core/src/generate.rs:467). - Qwen3 opts into batched prefill, maskless padded prefill, and paged decode (
src/models/qwen3.rs, around line 821). - In the scheduler, one incompatible request forces the whole collected batch back to sequential prefill: unsupported model, any VLM embeddings, any adopted prompt-cache prefix, or incompatible prompt lengths (
src/server/batch/scheduler.rs, around lines 3092 / 3110 / 3129 / 3146).
Proposal
- Instead of falling back the whole prefill window, split it into compatible cohorts:
- cold text requests eligible for padded batched prefill,
- adopted-prefix requests that need sequential offset-aware prefill,
- VLM or custom-embedding requests,
- equal-length-only models.
- Preserve request priority order at cohort boundaries so latency fairness does not regress.
- Expand batched-prefill support to additional dense families ONLY after cohort splitting is measured; otherwise support expansion is hidden by fallback behavior.
Validation
- Synthetic server queue with mixed cold prompts and prompt-cache hits.
- Measure prefill tok/s, time-to-first-token, and head-of-line blocking.
- Correctness tests for cache-offset handling when adopted-prefix rows are split away from cold rows.
- Suggested first experiment (idea.md): add queue-shape tracing for batched-prefill fallback reasons first. If most fallback windows mix cold and adopted-prefix requests, cohort splitting is worth implementing.
Acceptance criteria
- Mixed prefill windows are partitioned into cohorts; the cold-text cohort runs padded batched prefill even when other requests in the window are incompatible.
- Request priority order is preserved at cohort boundaries (no fairness regression).
- Cache-offset correctness verified when adopted-prefix rows are separated from cold rows.
- Prefill tok/s, TTFT, and head-of-line blocking measured on a mixed synthetic queue vs the current all-or-nothing fallback.
- INTEGRATION into the live scheduler prefill path.
Risk and priority
idea.md priority P1; risk medium. Batched prefill is a high-leverage server feature; the current all-or-nothing fallback can waste eligible concurrent work.
References
- idea.md "4. Batched Prefill Cohort Splitting" and "Suggested First Experiments" item 4.
- Code:
src/lib/mlxcel-core/src/generate.rs(supports_batched_prefill),src/models/qwen3.rs,src/server/batch/scheduler.rs(prefill fallback gates).
Metadata
Metadata
Assignees
Labels
area:coremlxcel-core: MLX FFI, primitives, KV cache, layersarea:inferenceGeneration, sampling, decoding (incl. speculative, DRY)priority:mediumMedium prioritystatus:doneCompletedtype:performancePerformance improvements
Activity
test(server): assert #332 cohort parity against all-cold-batched refe…
perf(server): split batched prefill into compatible cohorts (#346)
fix(server): reseed RNG per row at batched-prefill first-token sample (…
perf(server): split batched prefill into compatible cohorts (lablup#346)
fix(server): reseed RNG per row at batched-prefill first-token sample (…