Skip to content

kimi: K3 and K3.1 through the native server on Metal - #2221

Merged
ashhart merged 2 commits into
mainfrom
lead/k31-serving
Nov 5, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/k31-serving

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Second step of #2192, on main now that #2208 has landed: K3 and K3.1 become reachable through the native HTTP server on Metal, on one machine.

What it adds

  • kimi_k3 and kimi_k31 are registered on Metal, with resident BF16 projections, stored MXFP4 experts, KDA and MLA slots, and shared verification scratch. The unchanged lane core handles scheduling, verification and sampling; no lane or scheduling code changes.
  • A native text path: chat rendering, masked special tokens, reasoning and tool calls, and K3's efforts including medium. All 15 prompt goldens rendered by the release's own encoder agree on segments and joined text. Token ids against the real tiktoken.model are still to run.
  • A request past K3.1's 2,047-token ceiling gets dsa_config.limit_message, and snapshot restore checks the ceiling before any copy.
  • Admission prices every expert before opening anything and refuses by budget. The complete 1.45 TB checkpoint doesn't run on one Mac through this path.
  • Capabilities refuse images, external draft heads, TP, learning, disk recall, structured-output enforcement and budgets it doesn't support.

Notice: kimi_prompt.zig and kimi_values.zig adapt the model's own encoding_k3.py at revision 6d0a0202, and the tokenizer integration follows tokenization_kimi.py, named in THIRD_PARTY_NOTICES.md. No other engine's source was read. The recipe states the licence's Model-as-a-Service condition.

Tested on a four-layer synthetic graph, on Metal: drafted equals plain, concurrent equals solo at two streams, resumed equals fresh at five prompt cuts, and cancellation leaves the next output equal. The full test suite, kernel contract and server goldens pass (322/335 equal with zero unexpected differences).

Not run: real weights, a K3.1 reference, the complete model, long-context K3.1, quality, speed, or any Mac other than the test machine.

Register kimi_k3 and kimi_k31 on Metal, with a native text path: chat
rendering, masked special tokens, reasoning and tool calls, and K3's
efforts including medium. A request past K3.1's 2,047-token ceiling gets
dsa_config.limit_message, and snapshot restore checks the ceiling before
any copy. Admission prices every expert before opening anything and
refuses by budget, so the complete 1.45 TB checkpoint does not run on one
Mac through this path. The reply loop moves from chat.zig to
chat_generation.zig, keeping main's clamp of the cached count.

kimi_prompt.zig and kimi_values.zig adapt the model's own encoding_k3.py
at revision 6d0a0202, named in THIRD_PARTY_NOTICES.md.

Tested on a four-layer synthetic graph on Metal, and all 15 prompt goldens
match the release encoder's token ids. No real weights, no model-forward
reference and no full-model run. No lane or lane-host scheduling change.
@ashhart
ashhart merged commit 17f83e5 into main Nov 5, 2026
0 of 7 checks passed
@ashhart
ashhart deleted the lead/k31-serving branch November 10, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant