A long river barge loaded with stacked timber moves steadily down a wide calm river at dawn, its reflection on the smooth water

M5U 512GB x 4 Part 2: DeepSeek for Long-Context Agents, and Kimi K3.1 Pro Stops Crashing

DeepSeek V4.1 Flash on one M5 Ultra held 80 tok/s out to 189K tokens of context and topped my long-context quality test. Kimi K3.1 Pro on four machines now finishes long answers, after a fix for an upstream cache bug.

For coding agents that keep a big repo in context, DeepSeek V4.1 Flash on one 512 GB M5 Ultra Mac Studio was the best setup I tested. It wrote at about 80 tokens per second and held that speed out to 189K tokens of context. Follow-up turns started in about a second and a half. It is not perfectly tuned, though: on real review work its reasoning can run to the token limit without an answer.

Kimi K3.1 Pro, split across all four machines, now finishes long answers. Until this week it crashed partway through them, and the cause turned out to be a cache bug in upstream mlx-lm.

Line chart of generation speed in tokens per second against context size for DeepSeek on mlx-serve, DeepSeek on oMLX, ERNIE 5.5 Flash and GLM-5.3-Flash, one agent on one machine
Generation speed by context size, one agent, one machine per model.

Part 1 picked ERNIE 5.5 Flash for chat, based on short prompts. This time I tested what I want these machines for: agents that read a repo or a pile of logs and keep working on it.

The setups

A small harness acts like a coding agent. It hands the model 32K to 250K tokens of llama.cpp source and asks for an analysis and a patch, then runs three more turns that each add new files and reuse the server's cache.

DeepSeek on mlx-serve

The Lossless pack is 512 GB on disk and uses about 288 GiB of memory. It reads part of the model from the SSD while it generates, so keep it on the internal drive. I installed the CLI from the GitHub release tarball:

mlx-serve --model ~/models/DeepSeek-V4.1-Flash-1017-MLX-Serve-Lossless --serve \
  --host 127.0.0.1 --api-key-env MLXS_KEY --api-key-strict \
  --no-plugins --no-pld --prefix-cache-mem 60GB

The pack's own draft stages stay on. By default mlx-serve listens on all interfaces with no auth, so I bind it to localhost with a strict key.

A huge hand-drawn survey map unrolled along a very long oak table in a quiet archive reading room, brass weights on its corners and a reading lamp at one end
Long context: the whole map stays on the table between turns. Illustration.

Speed

Both DeepSeek setups held their speed as the context grew. GLM-5.3-Flash stayed near 50 tok/s. ERNIE fell from 62 to 44 by 239K.

Line chart of cold read time in seconds against context size for the four setups, one agent
Time to first token on a cold prompt.

DeepSeek on oMLX read 251K tokens in under a minute. ERNIE took about two and a half minutes for 239K. Follow-up turns, which are most of an agent's work, started in about 2 seconds on DeepSeek and 3 to 6 on the others.

Bar chart of total tokens per second with two and four agents at about 70K to 100K context for DeepSeek on mlx-serve, DeepSeek on oMLX, ERNIE, GLM-5.3-Flash and DeepSeek on two machines
Total throughput with two and four agents at about 70K to 100K of context each.

With four agents, DeepSeek on oMLX edged out mlx-serve, 87 tok/s in total against 78. DeepSeek split across two machines reached 91, but one run at about 150K per agent hung when a machine dropped out, so I stay on one.

Quality

I built two tests with planted problems and answer keys, and two model judges scored the answers blind: an incident hidden in about 90K tokens of logs, and a config audit of about 70K tokens where some settings are wrong and a few look wrong but are fine.

Bar chart of incident and config audit scores for DeepSeek on mlx-serve, DeepSeek on oMLX, GLM-5.3-Flash and ERNIE 5.5 Flash
Long-context quality scores, mean of two blind judges.

All four found the root cause of the incident. The config audit spread them out. The Lossless pack was the one setup to catch an nginx alias that serves the app's .env file, for 10 out of 10.

A beekeeper in a veil holds a honeycomb frame up to the evening sun to inspect it, a row of white hives in a meadow behind
Checking each frame, including the ones that look fine. Illustration.

Where DeepSeek fell over

The speed and the scores are real, but this setup is not tuned for real coding work yet. On open-ended review its reasoning runs until it hits the limit.

When I put the standalone server to work on a real job, reviewing a patch of about 70 lines, it reasoned through 16,000 tokens and stopped without writing an answer. A second try with a 24,000-token limit ended the same way after about four minutes. The reasoning was a long list of checks, none of which turned up a problem, and it did not stop to answer. Asking for lower reasoning effort in the request made no difference, because mlx-serve ignores that setting. The server has a --reasoning-budget flag that caps thinking tokens per request, and that is the next thing I will try.

The tests showed the same habit. Asked to find bugs planted in 95K tokens of code in one shot, both DeepSeek setups worked through it function by function until they ran out of 64K tokens, and GLM-5.3-Flash did too. Nine of ten attempts across the models did not answer. For now I give it a smaller scope, a token budget, or an agent loop that goes file by file.

Kimi K3.1 Pro on four machines

The 2-bit Kimi K3.1 Pro is 817 GB, so it takes at least two machines. On four, with each machine holding about 224 GB, it wrote at about 17 tok/s in my agent harness and read a 27K-token prompt in about 45 seconds.

Long answers were the problem. On two machines and on four, Kimi died about 4,000 to 4,400 tokens into an answer with [metal::malloc] Resource limit (499000) exceeded. That limit counts live Metal buffers, not memory, and memory was fine.

The cause is a known upstream mlx-lm bug (#1845, #2113). Most of Kimi's layers are linear-attention layers, and each one keeps a small position counter in its cache. The server updates that counter on each token as a lazy MLX operation, but it evaluates just the first such layer's counter. On the others the updates pile up as an unevaluated chain, one buffer per layer per token, until Metal runs out. A model-free test sized to Kimi's leak rate crashed at about the same point, step 4,494.

The fix that worked keeps the counter as a plain Python integer, the approach suggested in #1845, so decoding no longer grows the graph. I also applied the open PR #2023, which clears the leftover padding behind the bug and lets those layers use their compiled one-step decode path. With both in place, a test that forced a 6,000-token answer ran straight through.

Bar charts of Kimi K3.1 Pro 2-bit generation speed and 27K-token prompt reading speed on four machines after the leak fix, with command-buffer settings and a larger prefill step
Kimi tuning on four machines, same 2,500-token answer and 27K-token prompt each time.

Two settings helped after that. Larger Metal command buffers added a few percent to writing speed, and a prefill step of 4096 tokens made prompt reading about a fifth faster. Three machines were slower than four. This is the launch I use now:

mlx.launch --hostfile hostfile.json --backend jaccl \
  --env MLX_METAL_FAST_SYNCH=1 \
  --env MLX_MAX_OPS_PER_BUFFER=1000 --env MLX_MAX_MB_PER_BUFFER=400 \
  -- mlx_lm.server --model Kimi-K3.1-Pro-2bit-UVMAX --trust-remote-code \
  --prompt-cache-bytes 60GB --prompt-cache-size 4 --prefill-step-size 4096

Kimi now writes at about 19 tok/s and reads a 27K-token prompt at about 730 tok/s. That is still about a quarter of DeepSeek's writing speed on one machine, and a long prompt takes minutes to read. I have not rerun the quality tests on Kimi since the fix.

A large white observatory dome on a high desert ridge at dusk, its shutter opening to reveal a big telescope as the first stars appear
Kimi is running. Making it fast is the next job. Illustration.

Caveats

These are dev builds and a Preview model, two scored tests with model judges, one codebase plus logs and configs I built, and speed runs with answers up to 2,048 tokens. The two DeepSeek setups differ in weights, server and reasoning settings, so this compares setups. The DeepSeek review failures come from a handful of real tasks, and I have not yet tested a reasoning budget. The Kimi fix is a local patch to mlx-lm, not a release.

Verdict

Next for Kimi are the quality tests, faster prompt reading, and a draft model for faster writing.

Sources

Fringe Tech Local LLMs

Comments

// Comments are reviewed before appearing. No spam. No noise.