ZixiQi commited on
Commit
cc87969
·
0 Parent(s):

Kimi-K3-DSpark: MLA-native DSpark draft model for Kimi-K3

Browse files
Files changed (4) hide show
  1. .gitattributes +35 -0
  2. README.md +76 -0
  3. config.json +54 -0
  4. model.safetensors +3 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: vllm
4
+ base_model: moonshotai/Kimi-K3
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - dspark
8
+ - speculative-decoding
9
+ - draft-model
10
+ - mla
11
+ - vllm
12
+ - torchspec
13
+ - kimi-k3
14
+ ---
15
+
16
+ ## Model Overview
17
+
18
+ **Inferact/Kimi-K3-DSpark** is an **MLA-native DSpark** draft model that accelerates inference of [Kimi-K3](https://huggingface.co/moonshotai/Kimi-K3) on **[vLLM](https://github.com/vllm-project/vllm)**, which serves it through its native `dspark` speculative method.
19
+
20
+ The draft is trained on **target hidden states extracted from vLLM itself** — the same engine that serves it — so it learns from exactly the distribution it will later draft against. [TorchSpec](https://github.com/lightseekorg/TorchSpec) provides the training loop, streaming those hidden states from live vLLM target inference into concurrent FSDP draft training.
21
+
22
+ **DSpark** = a block-diffusion backbone (5 dense layers that consume 5 target auxiliary hidden states and draft a block of 7 tokens in a single parallel pass), plus a low-rank sequential **Markov head** (`rank=256`) that supplies the intra-block token dependency the parallel backbone misses, plus a confidence head.
23
+
24
+ **Why MLA:** the draft mirrors Kimi-K3's own MLA attention, so draft and target share a single KV layout (a compact 576-element latent per token). The draft's pages unify with the target's cache, letting it reuse the same KV management and PD-disaggregated serving paths with no separate page format.
25
+
26
+ ---
27
+
28
+ ## Performance
29
+
30
+ Measured end-to-end against Kimi-K3 at `tensor-parallel-size=8` (2 × GB300), `num_speculative_tokens=7`. **Sampling matches the production serving setting (`temperature=1.0` / `top_p=0.95`), so acceptance reflects real serving conditions.**
31
+
32
+ | Category | Benchmark | n | Mean Accept Length | Per-pos Accept Rate |
33
+ |---|---|---:|---:|---|
34
+ | Dialogue | MT-Bench | 80 | 2.57 | 0.624, 0.376, 0.222, 0.141, 0.096, 0.067, 0.048 |
35
+ | Long-context | SPEED-Bench `throughput_16k` / low-entropy | 302 | 3.85 | 0.796, 0.609, 0.462, 0.353, 0.271, 0.208, 0.154 |
36
+ | Code | SPEED-Bench · coding | 61 | 4.41 | 0.843, 0.666, 0.536, 0.440, 0.371, 0.309, 0.249 |
37
+ | Multilingual | SPEED-Bench · multilingual | 47 | 2.85 | 0.650, 0.424, 0.280, 0.195, 0.139, 0.098, 0.066 |
38
+ | Writing | SPEED-Bench · writing | 76 | 2.40 | 0.603, 0.342, 0.191, 0.115, 0.072, 0.046, 0.030 |
39
+ | RAG | SPEED-Bench · rag | 55 | 2.30 | 0.591, 0.320, 0.167, 0.096, 0.061, 0.038, 0.025 |
40
+ | QA | SPEED-Bench · qa | 80 | 2.06 | 0.549, 0.272, 0.124, 0.059, 0.030, 0.016, 0.009 |
41
+
42
+ Acceptance tracks how predictable the output is: it is strongest on deterministic, structured text such as code, and weaker on high-entropy generation such as creative writing. Confidence-based scheduling — using the draft's confidence head to prune low-confidence drafted tokens before they are sent for verification — is planned future work aimed at lifting the harder categories.
43
+
44
+ **Benchmarks:** [MT-Bench](https://huggingface.co/datasets/philschmid/mt-bench) (80 dialogue prompts) and [NVIDIA SPEED-Bench](https://huggingface.co/datasets/nvidia/SPEED-Bench) — its `throughput_16k` low-entropy split (302 prompts at 10k-token input) plus five qualitative categories.
45
+
46
+ vLLM supports **block verification** (`rejection_sample_method=block`) and **probabilistic draft sampling** (`draft_sample_method=probabilistic`) — verifying the drafted block as a unit, and sampling the draft from its own distribution rather than its argmax. Both are enabled in the numbers above and push acceptance higher at `temperature=1.0`.
47
+
48
+ ---
49
+
50
+ ## Training
51
+
52
+ **Data — all responses regenerated on-policy by Kimi-K3 itself**, so the draft learns the target's own reasoning traces and chat formatting. Prompts come from public datasets:
53
+
54
+ - [`lightseekorg/kimi-mtp-dataset`](https://huggingface.co/datasets/lightseekorg/kimi-mtp-dataset) — general instruction prompts
55
+ - [`nvidia/OpenCodeInstruct`](https://huggingface.co/datasets/nvidia/OpenCodeInstruct) — single-turn coding
56
+ - A nine-category prompt pool from the NVIDIA **Nemotron** SFT/RL collections and [`CohereLabs/aya_dataset`](https://huggingface.co/datasets/CohereLabs/aya_dataset), spanning chat, code, multilingual, RAG/QA, math, structured output and safety. Evaluation-set prompts are excluded.
57
+
58
+ **Method:** DSpark with `block_size=7`, `max_seq_length=16384`, trained on a combined CE + L1 distribution-distillation objective against the target's post-final-norm hidden state, bf16. The draft consumes Kimi-K3 auxiliary hidden states from target layers (2, 23, 47, 71, 89) of 93. Roughly **two epochs** in total, on GB300 nodes.
59
+
60
+ Draft architecture, block size, sequence length, and loss weights are YAML-configurable — see the [TorchSpec repo](https://github.com/lightseekorg/TorchSpec).
61
+
62
+ ---
63
+
64
+ ## Quick Start
65
+
66
+ ### Requirements
67
+
68
+ For serving Kimi-K3 itself — hardware, parallelism and engine flags — follow the official vLLM recipe: **[recipes.vllm.ai/moonshotai/Kimi-K3](https://recipes.vllm.ai/moonshotai/Kimi-K3)**.
69
+
70
+ ### Enable the draft
71
+
72
+ Add to your Kimi-K3 `vllm serve` command:
73
+
74
+ ```bash
75
+ --speculative-config '{"method": "dspark", "model": "Inferact/Kimi-K3-DSpark", "num_speculative_tokens": 7, "attention_backend": "FLASHINFER_MLA", "draft_sample_method": "probabilistic", "rejection_sample_method": "block"}'
76
+ ```
config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "K3DSparkModel"
4
+ ],
5
+ "model_type": "k3_dspark",
6
+ "hidden_size": 7168,
7
+ "intermediate_size": 14336,
8
+ "num_hidden_layers": 5,
9
+ "num_attention_heads": 64,
10
+ "num_key_value_heads": 64,
11
+ "q_lora_rank": 1536,
12
+ "kv_lora_rank": 512,
13
+ "qk_nope_head_dim": 128,
14
+ "qk_rope_head_dim": 64,
15
+ "v_head_dim": 128,
16
+ "mla_use_nope": false,
17
+ "mla_use_output_gate": false,
18
+ "vocab_size": 163840,
19
+ "rms_norm_eps": 1e-05,
20
+ "max_position_embeddings": 1048576,
21
+ "rope_theta": 50000.0,
22
+ "num_target_layers": 5,
23
+ "target_hidden_size": 7168,
24
+ "target_num_hidden_layers": 93,
25
+ "target_layer_ids": [
26
+ 2,
27
+ 23,
28
+ 47,
29
+ 71,
30
+ 89
31
+ ],
32
+ "mask_token_id": 163837,
33
+ "bos_token_id": 163584,
34
+ "eos_token_id": 163586,
35
+ "pad_token_id": 163839,
36
+ "markov_rank": 256,
37
+ "markov_head_type": "vanilla",
38
+ "enable_confidence_head": true,
39
+ "confidence_head_with_markov": true,
40
+ "tie_word_embeddings": false,
41
+ "draft_vocab_size": 163840,
42
+ "_torchspec_version": "0.1.0",
43
+ "torch_dtype": "bfloat16",
44
+ "rope_parameters": {
45
+ "rope_type": "yarn",
46
+ "factor": 32.0,
47
+ "original_max_position_embeddings": 32768,
48
+ "rope_theta": 50000.0,
49
+ "beta_fast": 32,
50
+ "beta_slow": 1,
51
+ "mscale": 1.0,
52
+ "mscale_all_dim": 1.0
53
+ }
54
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26e41e0e322f366247a8fc300ef9d62497d236549491939aef3440ad5b0f76ae
3
+ size 7124633450