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
{{ message }}
Repository navigation
perf(core): record 4k/16k/32k KV-cache sweeps to back the Turbo KV advisor recommendations #354
Follow-up to #327 (merged PR #343). The Turbo KV-cache advisor emits per-family and per-context KV-mode recommendations via mlxcel generate --recommend-quant (docs/turbo-kv-cache.md), but they remain advisory/opt-in because the supporting sweeps were never run. Two acceptance items in #327 are still unchecked: the 4k/16k/32k sweeps, and the documented quality guard.
Proposed Solution
Run scripts/bench_kv_cache.sh-style sweeps at contexts 4k/16k/32k for at least two dense and two MoE/VLM families.
Apply a quality guard: short deterministic outputs plus a longer logprob-trace comparison where available.
Validate and tune the advisor's per-family/context recommendations against the recorded data.
Where the data is confident, consider promoting a recommendation to a non-advisory per-family default.
Acceptance Criteria
Sweeps recorded at 4k/16k/32k for >=2 dense and >=2 MoE/VLM families.
Advisor recommendations validated and tuned against the recorded data.
Quality guard documented (short deterministic outputs plus longer logprob-trace comparison where available).
Constraint: preserve bf16 scales and biases for quantized models. No recommendation or sweep may reintroduce the bf16 -> f16 promotion that caused the #289 decode regression. The advisor stays advisory until each family has both throughput and quality coverage; only then is a non-advisory per-family default in scope. References: docs/turbo-kv-cache.md, scripts/bench_kv_cache.sh.
KV-cache sweep diagnosis (turbo4-asym was broken; fixed in #367)
Running the initial sweep surfaced a real bug rather than just data: the advisor's recommended Turbo mode, turbo4-asym, had catastrophically slow decode (0.13-0.24x fp16) because it was hardwired to a lossy sparse-V weighted-sum path. The #353MLX_MAX_OPS_PER_BUFFER gate was ruled out (turbo4-asym was equally slow at ops=40 and ops=1000). Fixed in #367 (exact rotated-codec-basis dequant-SDPA, ~0.40x fp16, about 3x faster and now exact instead of lossy).
Current M1 Ultra decode (qwen2.5-7b-4bit, after #367):
mode
4k
16k
fp16
98
70
int8
75 (0.76x)
48 (0.68x)
turbo4-asym
39 (0.40x)
30 (0.43x)
turbo4-delegated
78 (0.80x)
51 (0.73x)
Remaining work for this issue (deferred to a fresh session)
Clean re-sweep with the fixed turbo4-asym (and turbo4-delegated included) at 4k/16k/32k for at least 2 dense and 2 MoE/VLM families, recorded to benchmarks/turbo_kv/.
Re-tune the --recommend-quant advisor against the data. int8 and delegated are the fast cache options (0.68-0.80x); turbo4-asym is now exact and 3x faster but still ~0.40x, so it should be framed as a memory/exactness option, not a speed-competitive default. The medium/long recommendations need revising.
Quality guard doc (short deterministic outputs plus a longer logprob-trace comparison where available).
The partial sweep CSVs (qwen2.5-7b and qwen3-8b complete; qwen3-30b-a3b fp16/int8 only) in benchmarks/turbo_kv/ recorded the pre-#367 (broken) turbo data and should be regenerated. The deeper fused-kernel work to bring turbo4-asym itself to int8/delegated speed is tracked in #370.
Activity
inureyes commentedon Jun 19, 2026
KV-cache sweep diagnosis (turbo4-asym was broken; fixed in #367)
Running the initial sweep surfaced a real bug rather than just data: the advisor's recommended Turbo mode,
turbo4-asym, had catastrophically slow decode (0.13-0.24x fp16) because it was hardwired to a lossy sparse-V weighted-sum path. The #353MLX_MAX_OPS_PER_BUFFERgate was ruled out (turbo4-asym was equally slow at ops=40 and ops=1000). Fixed in #367 (exact rotated-codec-basis dequant-SDPA, ~0.40x fp16, about 3x faster and now exact instead of lossy).Current M1 Ultra decode (qwen2.5-7b-4bit, after #367):
Remaining work for this issue (deferred to a fresh session)
benchmarks/turbo_kv/.--recommend-quantadvisor against the data. int8 and delegated are the fast cache options (0.68-0.80x); turbo4-asym is now exact and 3x faster but still ~0.40x, so it should be framed as a memory/exactness option, not a speed-competitive default. The medium/long recommendations need revising.bench_kv_cache.shacceptance gates: the >= 0.95x fp16 targets for turbo4-asym are unrealistic and were never validated (per perf(core): extend the quant/KV-cache advisor to recommend Turbo KV modes per family and context #327).The partial sweep CSVs (qwen2.5-7b and qwen3-8b complete; qwen3-30b-a3b fp16/int8 only) in
benchmarks/turbo_kv/recorded the pre-#367 (broken) turbo data and should be regenerated. The deeper fused-kernel work to bring turbo4-asym itself to int8/delegated speed is tracked in #370.docs(cache): add ADR 0002 on Turbo KV split-dequant vs fused (sparse-…
fix(cache): align Turbo KV advisor, gates, and docs with measured swe…
fix(cache): align Turbo KV advisor, gates, and docs with measured swe…