debug(mac): root-cause MLX batched-recall break — upstream mlx_lm gemma-4 batch>1 decode bug (RotatingKVCache ruled out) - #133
Merged
Conversation
…prompt preset (isolate RotatingKVCache rotation-under-batch) Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
…tation diagnostic Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
…or batched decode, sidestepping mlx_lm in-place buffer batch>1 bug Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
…ngKVCache/rotation + cache type; it's an upstream mlx_lm gemma-4 batch>1 decode bug (prefill correct, decode diverges, cache-independent) Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Investigated the Mac batched multi-tenant recall break (batched recall 0.125–0.25 vs serialized 1.0) along the requested
RotatingKVCache/ batched-attention-mask line, and root-caused it.Findings (Mac M4, via bridge)
SinkWindowKVCache(no in-place buffer assign)Conclusion: the break is cache-independent and prefill-correct — batched decode diverges only after the first token, with both mlx_lm's in-place cache and Kakeya's concat cache, even with no rotation. That localizes it to mlx_lm 0.31.3's gemma-4 batched (batch>1) decode forward (RoPE-offset / mask / shared-KV path) — an upstream MLX limitation, not a Kakeya cache or
RotatingKVCacherotation issue. CUDA (HF transformers batched decode) is unaffected — §3.5/§3.7 stay 8.04×/8.45×, recall 1.0.Status: recall-safe Mac multi-tenant = serialized (recall 1.0). Mac batched throughput needs an upstream mlx_lm gemma-4 batched-decode fix (or a custom batched gemma decode) — tracked as a follow-up.
Tools added (reusable for the follow-up)
--kakeya-cachemode (concat-based S5 cache) + per-row first-token diagnostic inmlx_batched_multitenant_bench.pymlx-batched-diag-short,mlx-batched-kakeya-cacheresults/research/k3_mlx_batched_{diag_short,kakeya_cache}_mac.json; ADR 0014 §3.7 root-cause noteTesting
pytest tests/inference_engine/bridge/test_manifest.py(24 passed)