#1803·mlx-lm

mlx_lm.server: per-request chat_template_kwargs bypasses the prompt cache (0.31.3)

Author: jackhwarnerCreated Aug 29, 2026Updated Sep 22, 2026

On mlx-lm 0.31.3: if the server is launched WITHOUT --chat-template-args and requests carry chat_template_kwargs per request (e.g. {"enable_thinking": false}), prompt-cache reuse never happens — every request reports cached_tokens: 0 and pays full prefill (~23s for a ~10k-token shared prefix), even when the kwargs are identical on every request.

Launching the server WITH --chat-template-args '{"enable_thinking":false}' and sending the same requests (with or without the per-request kwargs) reuses the prefix normally (cached_tokens: 9939, ~400ms).

If this is intended cache-key behavior, a note in the server docs would save people a lot of silent 20-second prefills. Measured while building https://github.com/jackhwarner/modelbake; can provide exact request bodies.