Four brushed-aluminum computers side by side on a walnut workbench in a quiet barn workshop, tools on a pegboard behind, morning light from a tall window
A tribute to those triggered by sawdust and a tables edge.

Kimi K3.1 Pro Local at 30 to 56 tok/s: M5U 512GB x 4 Part 3

Kimi K3.1 Pro on its original weights went from 2.9 tok/s to about 30 with thinking on and up to 56 on answers, on four 512 GB M5 Ultra Mac Studios.

Four 512 GB M5 Ultra Mac Studios on a Thunderbolt 5 mesh, and for this part I ran Kimi K3.1 Pro on its original weights instead of the 2-bit build from Part 2. Stock mlx-lm wrote at 2.9 tokens per second on those weights. The same model now writes at about 30 to 34 tok/s with thinking on, and at 48 to 56 tok/s on code and math answers with thinking off. Sixteen streams at once total about 100 tok/s, and with about 93K tokens of context, follow-up turns start in about a second.

Those speeds use one change to the weights: the non-expert layers run in 8-bit, while the routed experts stay as shipped. The Quality section covers why I'm comfortable with that.

Bar chart of single-stream generation speed in tokens per second for Kimi K3.1 Pro original weights, from stock mlx-lm through each plain decode step to the DSpark draft model with thinking on and on code and math answers
One stream, short prompt: stock mlx-lm to now.

Part 1 measured that 2.9 tok/s, and Part 2 listed a draft model as the next job for Kimi. This part is that job.

The setup

The machines form a full mesh over Thunderbolt 5 RDMA and run 4-way tensor parallel on the JACCL backend, with MLX 0.32.5 and mlx-lm plus the open Kimi K3.1 pull request. ( If I had access to 2 additional machines for a total of 6 I think I could ink out 20% more tok/s )

The model is the checkpoint as Moonshot ships it: routed experts in native MXFP4, the rest in bf16, 1.56 TB in total. Stock loading wants the whole checkpoint on each machine's disk, and none had room, so the weights are sharded once ahead of time: about 400 GB per machine.

The draft model is DSpark, a 5-layer, 2.5B model that drafts in blocks of 7 and reads hidden states from 5 of Kimi's layers. I haven't found another port of this drafter to MLX. So if anyone is interested I could share this port.

This is the launch line, trimmed to the flags that matter, with DSPARK_FUSED_KDA=1, DSPARK_SPARSE_PREFILL_PAD=1, DSPARK_RADIX_T1=v1 and DSPARK_FUSED_INDEX_MIN_N=16384 set in the environment:

mlx.launch --backend jaccl --hostfile hosts.json -- batch_server.py \
  Kimi-K3.1-Pro-native-tp4 Kimi-K3.1-Pro-DSpark \
  --policy auto --max-batch 16 --cast-bf16 --shard-latent \
  --quant-nonexpert 8 --vp-head --tp-drafter --fused-indexer

The server is our own and serves an OpenAI-compatible API. The code is not published, so read the flags as a map of the sections below.

The bf16 cast

The largest single gain came from one cast. Native Kimi carries float32 activations. When a float32 input met a bf16 weight, MLX upcast the whole weight to float32 on each call. A large matrix-vector product ran at about 25 GB/s instead of 440.

Casting the inputs to bf16 took plain decoding from 3.7 to 10.9 tok/s, with quality inside the reference's own noise. The 2-bit build hid this, because quantized matmuls do not upcast their weights. I did not expect a dtype mismatch to be worth close to a factor of three.

Sharding and 8-bit layers

Loader fixes had already moved 2.9 to 3.7. After the cast, exact changes brought plain decoding to 14.4 tok/s: splitting the output head by vocabulary, and sharding the latent-MoE projections that stock mlx-lm replicates on each machine.

Quantizing the non-expert layers to 8-bit at load brought it to 18.7. This step is not exact, so it is checked under Quality. 6-bit and 4-bit were measurably worse, and I dropped them.

Draft and check

DSpark is speculative decoding. The small drafter proposes a block of tokens, and Kimi checks the block in one forward pass and keeps the part it agrees with. On code and math answers, each check yields about 5 to 5.7 tokens, which gives 48.5 tok/s on a code prompt and 56.1 on a math prompt. Prose answers draft less well and land near 27.

When draft tokens are rejected, the server rolls back Kimi's linear-attention (KDA) layers by recording their inputs and replaying the kept tokens. Verification uses gathered sparse attention, where each query reads its own top 2,048 keys instead of the whole cache.

A carpenter's hand marking a pencil line across a long oak board while the other hand holds a steel square against it, wood shavings on the bench
Mark a run of cuts, then check them against the square. Illustration.

With thinking on, which is the template default and what agents send, short prompts run at 30 to 34 tok/s across bench runs, because draft acceptance varies from run to run. The live server gave 40.6 on a first turn and 32.6 on a second.

Metal kernels

My assistant wrote Metal kernels for Kimi's own layers. The fused KDA layer is ported from the decode kernel in oMLX and mlx-serve (Apache-2.0 and MIT) and extended to batches. Others fuse the DSA indexer scores and do exact radix top-k selection.

A watchmaker's hands adjusting a tiny gear in an open mechanical watch movement with brass tweezers, a loupe and tools on a green mat under a warm lamp
Small parts, adjusted one at a time. Illustration.

Prompt reading (prefill) improved too. mlx-lm's fused sparse kernel needs a head count divisible by 16, and the 4-way split leaves 24 per machine, so long prompts took a slow path until the heads were padded. Prefill also ran the output head over all 4,096 rows of a chunk when it needs the last one.

Bar chart of milliseconds per draft check at 32K and 128K context, stock kernels against the custom Metal kernels
Time for one draft check, one stream.

Prefill at 32K went from 604 to 758 tok/s. At 128K, with the same draft acceptance, writing with thinking on went from 20.9 to 27.1 tok/s.

Several streams at once

Kimi's full-attention layers use no positional encoding, so a rejected draft token can stay in the cache as a masked hole. Each stream keeps its own acceptance, and one forward pass verifies all of them together. Draft width follows load: wide with one stream, plain batched decoding from about 7 streams up.

Bar chart of total tokens per second for 1, 2, 4, 8 and 16 concurrent streams of Kimi K3.1 Pro with thinking on, with the per-stream speed labeled on each bar
Total throughput by number of streams, thinking on.

With thinking on, two streams total 52 tok/s and sixteen total 104, about 6.5 each. Each extra stream pulls in new routed experts, and from about 8 streams up, reading them takes about half of each step.

A grand library reading room seen from a stone balcony, many readers at long tables each working under a green-shaded lamp
Many readers, one room, one set of shelves. Illustration.

Multi-turn at long context

Agents re-send the conversation without the earlier thinking text, so an exact-prefix cache missed on each turn. The server now saves a snapshot at the end of each prompt. The next turn's prompt starts with the previous prompt, so it picks up from there.

Bar chart of time to first token in seconds for turns 1, 2 and 3 at about 93K tokens of context
Time to first token over three turns at about 93K tokens of context.

In a test at about 93K tokens, the first turn waited 171 seconds for the cold read. Turns 2 and 3, each adding a little new text, started in 1.3 and 1.0 seconds, and wrote at 25 to 28 tok/s with thinking on.

Quality

I measured the 8-bit step against the pure native model on 16 prompts: code, math, sysadmin, prose, JSON and tool calls, and planning. Fed the same text, the 8-bit setup picked the same next token as the reference 96.97% of the time. The native model compared with itself, decode path against prefill path, agrees 96.95% of the time. So on this set the 8-bit layers sit inside the native model's own noise. The new kernels, checked against stock at 32K on two prompts, are within that noise too. Hopefully this holds true under real workloads.

Caveats

Thinking text drafts poorly. Kimi's thinking is terse and telegraphic ("I need craft response complete ... Should decide ..."), and the drafter gets about 2.5 tokens per check on it, against 4 to 5 on code and math answers. Prompt lookup drafts, a bf16 drafter and exact speculative sampling at temperature 1.0 did not help.

Cold prefill is slow: 128K tokens takes about 4.5 minutes. On paper a 1M-token context fits in memory, but I have run to 128K so far, and a cold read that long would take tens of minutes.

Single runs of 256 to 512 tokens carry roughly 10% noise either way in draft acceptance, so the single-stream figures are approximate.

Verdict

At the end of Part 2, Kimi wrote at about a quarter of DeepSeek's speed. On its original weights it is now quick enough for my agent work, though my target was 40 tok/s with thinking on and I'm not there yet. For scale, secondary sources quoting Artificial Analysis put Moonshot's own API at around 32 to 77 tok/s per stream: one stream here is in that range on answers and near its bottom edge with thinking on.

I did not expect a 1.56 TB model on desktop machines to start a follow-up turn at 93K tokens in about a second. Sixteen streams is more agents than I have work for today. We will see what tomorrow brings.

Where next

Next is fine-tuning the DSpark drafter on Kimi's own thinking text, which Moonshot's license permits. The training data is being generated through the live server now. The goal is to bring acceptance on thinking text closer to what answers get.

After that come faster prefill, where the MoE and attention layers take most of the time, and less batch overhead. Maybe two more machines as well: six splits the model's heads and experts evenly with room for single TB5 connections, if anyone wants to lend me a few more boxes :)

Sources

Fringe Tech Local LLMs

Comments

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