Skip to content

kimi: recognise K3.1 and bound its all-visible attention - #2208

Merged
ashhart merged 4 commits into
mainfrom
lead/k31-config
Nov 5, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/k31-config

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

First step of #2192. Kimi K3.1 Pro's text_config.model_type is still kimi_linear, so main's K3 family took its config as K3 and ignored dsa_config, which would run full attention past the top-k with no warning. This makes K3.1 explicit:

  • dsa_config's geometry, cadence and exact 24-layer set are checked before anything else reads the config, and values the kernels don't take refuse.
  • K3.1 runs up to 2,047 total evaluated tokens, counting the prompt, cached positions and reply. A longer request fails with error.K31ContextLimit rather than truncating; the serving PR maps that to its plain message.
  • All five BF16 indexer tensors are specified, required in the shard index, fetched and prepared on the 24 MLA layers. They aren't used yet: about 0.36 GB of weights wait for the sparse index.
  • K3's own outputs are byte-identical against main on the synthetic check, on an M5 Ultra.

This is an inference, not a known fact about K3.1. Below the top-k, a Gated DSA layer should read like MLA over every position, as our GLM's does, and the 2,047 cap is chosen to be safe under any reading of index_skip_topk_offset and index_topk_freq. K3.1's release has no modelling code, so nothing confirms it yet.

Not run: no real weights, no K3.1 reference and no full-model run. The whole native build and complete host suite are CI's. K3 isn't served from main yet, so nobody can serve K3.1 from this alone; that's the next PR. Written from our own K3 and GLM families and the checkpoint's config and tensor list; no other engine's source was read.

Parse the supplied DSA declaration, validate its supported geometry, and refuse evaluated positions beyond 2047. The all-visible equivalence is an inference from our GLM DSA, not a known K3.1 reference result. Load and prepare all five indexer tensors without changing K3 kernels. Add real-config admission regressions and the synthetic K3.1 fixture path.

No real weights, no K3.1 reference, no full-model run. Host and synthetic device gates are queued separately under #2192.
@ashhart
ashhart merged commit a17d055 into main Nov 5, 2026
5 of 7 checks passed
@ashhart
ashhart deleted the lead/k31-config 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