r/LocalLLM • u/_Baylock_ • 9d ago
Question LM Studio and cache
Hi,
I juste received my Mac Studio M5 ultra 36/80 with 256GB of shared memory.
I installed LM Studio with Qwen3.8-Flash-next-4bit mlx and a context of 131072
I tested some prompts and it works as I expected (I like it a lot so far), except for one annoying thing:
I fed the prompt with a 100 pages PDF and asked 2 questions about it.
The first time, it took a few minutes to read the file, which is normal. But for the second question, it re-read it again. It doesn't seem to cache the content.
And the context wasn't exhausted.
Next, I tried to copy paste the 100 pages into the prompt form (no attachment this time): same results.
Is it a known issue?
Is it related to the model or to the inference engine?
Can you replicate this?
Is there a way to solve the issue somehow?
Thanks.
2
u/andrew-ooo 9d ago
Your own guess about hybrid models is the one I'd bet on. Prompt caching only works if the new request is a byte-identical extension of the old one. With a plain transformer the engine can reuse the KV cache up to the first differing token, so the PDF part survives even if something later changes. Flash-Next has linear-attention layers that keep a fixed-size recurrent state instead of per-token KV, and that state can't be partially rewound. Unless the engine saved a checkpoint at exactly the right spot, any divergence means recomputing from token zero.
And there is almost always a divergence between turns: LM Studio strips the model's thinking block out of the previous answer before sending the next request, so the history the model sees is no longer what it produced. With a transformer that costs you the last turn; with a recurrent-state model it costs you the whole 100 pages.
Two quick tests: 1) load a dense transformer (any Qwen dense MLX build) and repeat the experiment, the second question should come back in seconds; 2) ask both questions in one message. If both hold, it's the architecture plus the engine's checkpointing, not a bug in your setup. llama-server handles this better than the MLX engine right now, it keeps context checkpoints for SWA and recurrent layers (--ctx-checkpoints, default 8), so the usual follow-up question reuses most of the prefix.
1
u/Solembumm3 9d ago
Looks like you used Gemma 4.