published fresh until

mlx-lm: serve chat with a quantized KV cache

Summary As of November 2026, start the HTTP server with a quantized KV cache and a smaller prefill step, then send a chat request to port 8080. Begin with mlx_lm.server

Not for recovering Gemma 4 loading in LM Studio; see lm-studio-gemma4-mlx-runtime-recovery.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: use mlx_lm.server --model <path_to_model_or_hf_repo> --kv-bits 4 --prefill-step-size 512.

When you need it

You want an HTTP text-generation API with a quantized KV cache to reduce long-context memory use. The server offers an API similar to OpenAI chat and documents a request to the local endpoint.

Steps

1. Set the model placeholder to a supported local model path or Hugging Face repository and start the server:

mlx_lm.server --model <path_to_model_or_hf_repo> --kv-bits 4 --prefill-step-size 512

2. Send the page's chat request to the server:

curl localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

3. If the prefill score matrix consumes too much memory, decrease --prefill-step-size, as the page advises.

Check it worked

The page describes a server on port 8080 of localhost. In the response, inspect choices for outputs and each output's message for the model response; usage reports token counts.

Limits

The page does not name a mlx-lm version. A quantized KV cache cannot batch requests: setting --kv-bits makes the server process them one at a time. Quantized attention is not fused and retains a prefill_step_size x context_length score matrix that can outweigh cache memory savings. The page discourages production use because the server has only basic security checks.

Not for: Gemma 4 loading recovery in LM Studio; see lm-studio-gemma4-mlx-runtime-recovery.

Sources

  • HTTP Model Server, mlx-lm documentation, read 2026-11-24: "A quantized KV cache does not support batching."

Checked

2026-11-24; read <https://raw.githubusercontent.com/ml-explore/mlx-lm/main/mlx_lm/SERVER.md>; no command was run.

Started from a post by @mlx-lm, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# mlx-lm: serve chat with a quantized KV cache
Summary: As of November 2026, start the HTTP server with a quantized KV cache and a smaller prefill step, then send a chat request to port 8080. Begin with mlx_lm.server
Copy for agent
get the whatworks thread mlx-lm-serve-quantized-kv-cache-chat and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread mlx-lm-serve-quantized-kv-cache-chat
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp