AMAImedia fynnsu commited on
Commit
7174436
·
0 Parent(s):

Duplicate from RedHatAI/Kimi-K3-speculator.dspark

Browse files

Co-authored-by: Fynn Schmitt-Ulms <fynnsu@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +35 -0
  2. README.md +276 -0
  3. config.json +84 -0
  4. config.py +67 -0
  5. 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,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: speculators
3
+ base_model:
4
+ - moonshotai/Kimi-K3
5
+ license: apache-2.0
6
+ tags:
7
+ - speculative-decoding
8
+ - dspark
9
+ - speculators
10
+ ---
11
+ # RedHatAI/Kimi-K3-speculator.dspark
12
+ This is a DSpark speculator model for [moonshotai/Kimi-K3](https://huggingface.co/moonshotai/Kimi-K3).
13
+ ## Training Details
14
+ This model was trained using the [Speculators](https://github.com/vllm-project/speculators) library. Training compute for this model was generously provided by [Verda](https://verda.com/), a leading cloud platform for AI training and inference. Verda runs its own data centers and offers on-demand NVIDIA GPU clusters with NVLink and InfiniBand interconnect, backed by an in-house AI Lab that works directly with open-source projects on large-scale training and inference optimization.
15
+
16
+ Kimi-K3 does not fit on a single GB300 node, so training used a multi-node setup with hidden-state extraction and draft training on disjoint node groups, streaming hidden states between them through a [Mooncake](https://github.com/kvcache-ai/Mooncake) store. Two separate virtual environments are required:
17
+
18
+ - **Extraction:** vllm, [`hs_connectors`](https://github.com/vllm-project/speculators/tree/main/hs_connectors), and [`mooncake-transfer-engine`](https://github.com/kvcache-ai/Mooncake)
19
+ - **Training:** speculators, [`hs_connectors`](https://github.com/vllm-project/speculators/tree/main/hs_connectors), and [`mooncake-transfer-engine`](https://github.com/kvcache-ai/Mooncake)
20
+
21
+ <details>
22
+ <summary>Commands</summary>
23
+
24
+ ### Prepare data
25
+ ```bash
26
+ # In virtual environment with speculators installed
27
+ python scripts/prepare_data.py \
28
+ --model moonshotai/Kimi-K3 \
29
+ --trust-remote-code \
30
+ --data ./data.jsonl \
31
+ --output ./runs/kimi_k3_dspark/data \
32
+ --seq-length 8192 \
33
+ --num-preprocessing-workers 48 \
34
+ --minimum-valid-tokens 16
35
+ ```
36
+ ### Launch the Mooncake master
37
+ One per run, anywhere both node groups can reach.
38
+ ```bash
39
+ mooncake_master --rpc_port 50051 --metrics_port 9003 \
40
+ --rpc_thread_num 8 --enable_disk_eviction=false --logtostderr=true
41
+ ```
42
+ ### Launch extraction (both nodes of the TP8 pair)
43
+ `NODE_RANK=0` on the head node, `1` on the other; rank 1 runs `--headless`.
44
+ ```bash
45
+ # In (separate) virtual environment with vllm installed
46
+ vllm_venv/bin/python scripts/launch_vllm.py moonshotai/Kimi-K3 \
47
+ --hidden-states-backend mooncake \
48
+ --mooncake-master <host>:50051 \
49
+ --mooncake-metadata-server P2PHANDSHAKE \
50
+ --mooncake-protocol tcp \
51
+ --mooncake-global-segment-gib 32 \
52
+ --mooncake-local-buffer-gib 4 \
53
+ --mooncake-writer-threads 4 \
54
+ --target-layer-ids 24 48 72 88 92 \
55
+ --trust-remote-code \
56
+ -- \
57
+ --served-model-name moonshotai/Kimi-K3 \
58
+ --trust-remote-code \
59
+ --load-format fastsafetensors \
60
+ --moe-backend auto \
61
+ --all2all-backend flashinfer_nvlink_one_sided \
62
+ --enable-expert-parallel \
63
+ --gpu-memory-utilization 0.95 \
64
+ --compilation-config '{"pass_config":{"fuse_allreduce_rms":false}}' \
65
+ --tensor-parallel-size 8 \
66
+ --nnodes 2 \
67
+ --node-rank <0|1> \
68
+ --master-addr <head-fabric-ip> \
69
+ --port 8000 \
70
+ --max-model-len 8193 \
71
+ --max-num-seqs 64 \
72
+ --max-num-batched-tokens 32768 \
73
+ --kv-cache-dtype auto \
74
+ --attention-config '{"mla_prefill_backend":"TRTLLM_RAGGED","use_prefill_query_quantization":false}' \
75
+ --no-enable-prefix-caching \
76
+ --language-model-only
77
+ ```
78
+ ### Launch training
79
+ Must be run once the extractor reports healthy on `/health`.
80
+ ```bash
81
+ # In virtual environment with speculators installed
82
+ torchrun --standalone --nproc-per-node 4 \
83
+ scripts/train.py \
84
+ --verifier-name-or-path moonshotai/Kimi-K3 \
85
+ --trust-remote-code \
86
+ --draft-config k3_draft_layer_config.json \
87
+ --data-path ./runs/kimi_k3_dspark/data \
88
+ --save-path ./runs/kimi_k3_dspark/checkpoints \
89
+ --draft-vocab-size 163840 \
90
+ --mask-token-id 163837 \
91
+ --epochs 1 \
92
+ --checkpoint-freq 0.1 \
93
+ --total-seq-len 8192 \
94
+ --train-data-ratio 0.999 \
95
+ --speculator-type dspark \
96
+ --target-layer-ids 24 48 72 88 92 \
97
+ --block-size 8 \
98
+ --max-anchors 1024 \
99
+ --dflash-decay-gamma 4.0 \
100
+ --markov-rank 256 \
101
+ --markov-head-type vanilla \
102
+ --enable-confidence-head \
103
+ --confidence-head-with-markov \
104
+ --confidence-head-alpha 1.0 \
105
+ --loss-fn '{"ce":0.1,"tv":0.9}' \
106
+ --optimizer muon \
107
+ --lr 1e-4 \
108
+ --scheduler-type cosine \
109
+ --scheduler-warmup-ratio 0.03 \
110
+ --hidden-states-backend mooncake \
111
+ --mooncake-master <host>:50051 \
112
+ --mooncake-metadata-server P2PHANDSHAKE \
113
+ --mooncake-protocol tcp \
114
+ --mooncake-global-segment-gib 0 \
115
+ --mooncake-local-buffer-gib 4 \
116
+ --mooncake-writer-threads 4 \
117
+ --vllm-endpoint http://<head-fabric-ip>:8000/v1 \
118
+ --on-missing generate \
119
+ --on-generate delete \
120
+ --request-timeout 900 \
121
+ --max-retries 5 \
122
+ --generation-validation-retries 2 \
123
+ --max-consecutive-generation-failures 20 \
124
+ --num-workers 2 \
125
+ --prefetch-factor 2 \
126
+ --log-freq 20
127
+ ```
128
+ All four components can be run together on a 3-node Slurm allocation with `run.sbatch` from the example directory.
129
+ </details>
130
+
131
+ ## Model Specifications
132
+ | | |
133
+ |---|---|
134
+ | **Base Model** | moonshotai/Kimi-K3 |
135
+ | **Chat Template** | moonshotai/Kimi-K3 (use `/chat/completions` endpoint) |
136
+ | **Format** | Safetensors |
137
+ | **License** | Apache 2.0 |
138
+ | **Draft Layers** | 5 |
139
+ | **Target Layer IDs** | 24, 48, 72, 88, 92 |
140
+ | **Draft Vocab Size** | 163840 |
141
+ | **Training Sequence Length** | 8192 |
142
+ | **Validation Hardware** | NVIDIA B300 NVL72 (4 GPUs per node) |
143
+ ## Deployment
144
+ ```bash
145
+ # Deploy with speculative decoding on vLLM latest main
146
+ vllm serve moonshotai/Kimi-K3 --spec-method dspark --spec-model RedHatAI/Kimi-K3-speculator.dspark --spec-tokens 8 --trust-remote-code --gpu-memory-utilization 0.95 --tensor-parallel-size 8 --load-format fastsafetensors --no-enable-flashinfer-autotune --max-model-len 131072 --kv-cache-dtype fp8 --attention-config '{"use_prefill_query_quantization":true,"mla_prefill_backend":"flashinfer"}' --enable-auto-tool-choice --tool-call-parser kimi_k3 --reasoning-parser kimi_k3
147
+ ```
148
+ ## Acceptance Rates
149
+ Per-position token acceptance rates across datasets, at 8 draft tokens per step:
150
+ | Dataset | Pos 0 | Pos 1 | Pos 2 | Pos 3 | Pos 4 | Pos 5 | Pos 6 | Pos 7 | Acceptance Length |
151
+ |---------|-------|-------|-------|-------|-------|-------|-------|-------|-------------------|
152
+ | HumanEval | 81.3% | 67.3% | 56.9% | 48.6% | 42.2% | 37.3% | 33.0% | 29.4% | 4.96 |
153
+ | math_reasoning | 92.3% | 84.3% | 76.7% | 69.8% | 63.4% | 57.2% | 51.6% | 47.0% | 6.42 |
154
+ | qa | 72.9% | 51.2% | 35.2% | 24.3% | 17.0% | 12.0% | 8.6% | 6.2% | 3.28 |
155
+ | question | 70.6% | 48.4% | 33.1% | 23.2% | 16.6% | 12.3% | 9.3% | 7.2% | 3.21 |
156
+ | rag | 77.9% | 58.9% | 44.1% | 33.4% | 25.4% | 19.6% | 15.2% | 11.8% | 3.86 |
157
+ | summarization | 82.5% | 64.8% | 49.9% | 38.4% | 28.5% | 20.3% | 14.9% | 10.7% | 4.10 |
158
+ | tool_call | 71.5% | 50.2% | 35.6% | 25.4% | 18.6% | 13.8% | 10.4% | 7.9% | 3.33 |
159
+ | translation | 82.7% | 67.2% | 54.6% | 45.7% | 38.2% | 31.3% | 25.3% | 20.0% | 4.65 |
160
+ | writing | 69.4% | 46.8% | 32.1% | 22.3% | 16.0% | 11.8% | 8.9% | 7.0% | 3.14 |
161
+
162
+ ### Long-context acceptance
163
+ Acceptance rates on [LongBench](https://longbench2.github.io/) dataset by sub-domain and input context length, from 2K to 20K tokens.
164
+ <details>
165
+ <summary>Full breakdown</summary>
166
+
167
+ | Sub-domain | Context | Pos 0 | Pos 1 | Pos 2 | Pos 3 | Pos 4 | Pos 5 | Pos 6 | Pos 7 | Acceptance Length |
168
+ |---|---|---|---|---|---|---|---|---|---|---|
169
+ | Academic | 2,000 | 73.9% | 47.5% | 33.8% | 22.9% | 13.4% | 7.7% | 5.5% | 4.0% | 3.09 |
170
+ | Academic | 4,000 | 70.8% | 49.7% | 29.9% | 17.8% | 9.7% | 5.6% | 3.6% | 1.6% | 2.89 |
171
+ | Academic | 6,000 | 73.6% | 48.6% | 28.8% | 17.1% | 9.7% | 5.6% | 3.6% | 2.5% | 2.90 |
172
+ | Academic | 8,000 | 77.6% | 54.8% | 33.6% | 16.5% | 10.6% | 4.9% | 2.6% | 1.4% | 3.02 |
173
+ | Academic | 10,000 | 77.3% | 52.3% | 31.0% | 17.6% | 11.3% | 5.1% | 3.0% | 1.9% | 3.00 |
174
+ | Academic | 12,000 | 79.2% | 59.6% | 35.2% | 22.1% | 11.4% | 6.5% | 4.5% | 1.7% | 3.20 |
175
+ | Academic | 14,000 | 71.6% | 47.6% | 25.2% | 13.8% | 8.6% | 3.9% | 1.9% | 0.6% | 2.73 |
176
+ | Academic | 16,000 | 72.3% | 51.7% | 30.2% | 16.0% | 8.0% | 4.0% | 2.0% | 1.1% | 2.85 |
177
+ | Academic | 18,000 | 74.4% | 47.9% | 28.6% | 16.6% | 8.8% | 3.5% | 2.8% | 1.8% | 2.84 |
178
+ | Academic | 20,000 | 78.1% | 52.4% | 29.4% | 15.9% | 8.9% | 3.9% | 2.5% | 1.4% | 2.92 |
179
+ | Agent history QA | 2,000 | 76.4% | 59.2% | 46.0% | 31.9% | 21.0% | 14.1% | 11.2% | 7.2% | 3.67 |
180
+ | Agent history QA | 4,000 | 80.7% | 68.8% | 55.3% | 35.4% | 26.0% | 16.1% | 11.3% | 6.1% | 4.00 |
181
+ | Agent history QA | 6,000 | 80.0% | 69.3% | 54.8% | 38.3% | 32.4% | 24.5% | 19.3% | 11.7% | 4.30 |
182
+ | Agent history QA | 8,000 | 82.3% | 67.1% | 50.6% | 31.7% | 19.5% | 14.4% | 8.4% | 5.7% | 3.80 |
183
+ | Agent history QA | 10,000 | 79.7% | 64.9% | 48.7% | 33.5% | 24.1% | 15.8% | 13.0% | 8.2% | 3.88 |
184
+ | Agent history QA | 12,000 | 81.4% | 62.8% | 46.0% | 31.7% | 20.4% | 12.5% | 8.5% | 4.0% | 3.67 |
185
+ | Agent history QA | 12,000 | 77.1% | 60.0% | 42.7% | 26.7% | 17.3% | 9.9% | 7.2% | 4.5% | 3.45 |
186
+ | Agent history QA | 14,000 | 76.9% | 53.2% | 38.2% | 26.5% | 16.9% | 10.4% | 6.5% | 4.2% | 3.33 |
187
+ | Agent history QA | 16,000 | 74.5% | 54.0% | 34.3% | 20.2% | 12.9% | 7.5% | 4.6% | 2.7% | 3.11 |
188
+ | Agent history QA | 18,000 | 78.6% | 55.5% | 34.9% | 22.6% | 14.3% | 7.8% | 5.0% | 2.5% | 3.21 |
189
+ | Agent history QA | 20,000 | 75.9% | 57.4% | 36.0% | 23.6% | 14.7% | 9.6% | 6.3% | 3.8% | 3.27 |
190
+ | Code repo QA | 2,000 | 71.3% | 43.3% | 25.8% | 16.9% | 10.4% | 5.6% | 3.6% | 1.8% | 2.79 |
191
+ | Code repo QA | 4,000 | 74.8% | 43.4% | 25.4% | 15.8% | 9.1% | 3.0% | 1.5% | 0.9% | 2.74 |
192
+ | Code repo QA | 6,000 | 77.8% | 47.1% | 26.2% | 13.0% | 7.5% | 1.5% | 0.9% | 0.7% | 2.75 |
193
+ | Code repo QA | 8,000 | 74.5% | 45.6% | 26.9% | 15.3% | 7.9% | 3.6% | 2.0% | 1.1% | 2.77 |
194
+ | Code repo QA | 10,000 | 73.5% | 48.2% | 26.0% | 13.5% | 6.5% | 1.9% | 1.5% | 0.4% | 2.72 |
195
+ | Code repo QA | 12,000 | 79.5% | 51.0% | 31.0% | 16.9% | 9.0% | 4.6% | 1.3% | 0.3% | 2.94 |
196
+ | Code repo QA | 14,000 | 73.0% | 45.7% | 26.1% | 15.6% | 7.2% | 3.3% | 0.9% | 0.2% | 2.72 |
197
+ | Code repo QA | 16,000 | 73.5% | 45.6% | 26.1% | 17.1% | 8.6% | 4.6% | 2.0% | 0.4% | 2.78 |
198
+ | Code repo QA | 18,000 | 76.9% | 50.6% | 29.9% | 16.4% | 8.9% | 3.6% | 1.9% | 0.7% | 2.89 |
199
+ | Code repo QA | 20,000 | 76.1% | 45.2% | 24.4% | 12.7% | 6.5% | 2.9% | 0.7% | 0.2% | 2.69 |
200
+ | Detective | 2,000 | 74.5% | 51.4% | 31.5% | 21.4% | 13.2% | 6.7% | 3.6% | 1.4% | 3.04 |
201
+ | Detective | 4,000 | 79.7% | 57.7% | 38.0% | 23.0% | 14.4% | 7.8% | 3.0% | 1.0% | 3.25 |
202
+ | Detective | 6,000 | 80.1% | 57.0% | 37.6% | 21.6% | 12.4% | 5.7% | 2.2% | 1.2% | 3.18 |
203
+ | Detective | 8,000 | 80.5% | 56.0% | 35.6% | 19.0% | 9.1% | 5.0% | 1.7% | 1.0% | 3.08 |
204
+ | Detective | 10,000 | 74.7% | 51.0% | 31.8% | 18.3% | 11.1% | 5.8% | 3.5% | 2.6% | 2.99 |
205
+ | Detective | 12,000 | 77.8% | 52.9% | 30.7% | 16.0% | 8.0% | 3.4% | 1.6% | 1.1% | 2.92 |
206
+ | Detective | 14,000 | 76.3% | 53.2% | 32.8% | 17.3% | 9.6% | 4.4% | 3.0% | 1.2% | 2.98 |
207
+ | Detective | 16,000 | 73.9% | 52.2% | 30.8% | 14.7% | 6.2% | 4.5% | 2.7% | 1.1% | 2.86 |
208
+ | Detective | 18,000 | 76.2% | 48.2% | 28.1% | 18.1% | 11.1% | 4.5% | 3.2% | 0.5% | 2.90 |
209
+ | Detective | 20,000 | 77.4% | 54.8% | 30.8% | 15.6% | 9.3% | 6.1% | 3.0% | 2.6% | 3.00 |
210
+ | Event ordering | 2,000 | 75.6% | 48.8% | 32.8% | 20.9% | 13.3% | 7.4% | 3.4% | 1.5% | 3.04 |
211
+ | Event ordering | 4,000 | 76.2% | 53.1% | 34.8% | 21.4% | 10.0% | 5.0% | 2.9% | 1.4% | 3.05 |
212
+ | Event ordering | 6,000 | 77.4% | 48.6% | 28.6% | 14.3% | 7.0% | 3.7% | 0.7% | 0.2% | 2.80 |
213
+ | Event ordering | 8,000 | 78.9% | 54.6% | 33.3% | 20.4% | 10.0% | 5.6% | 2.7% | 1.5% | 3.07 |
214
+ | Event ordering | 10,000 | 76.5% | 51.4% | 30.4% | 18.0% | 9.0% | 4.6% | 3.0% | 0.9% | 2.94 |
215
+ | Event ordering | 12,000 | 77.9% | 56.5% | 36.3% | 20.6% | 12.4% | 6.0% | 3.0% | 1.2% | 3.14 |
216
+ | Event ordering | 14,000 | 73.6% | 52.1% | 31.9% | 18.5% | 9.0% | 4.4% | 2.1% | 0.9% | 2.93 |
217
+ | Event ordering | 16,000 | 72.3% | 51.8% | 31.8% | 17.3% | 7.9% | 4.1% | 2.0% | 1.4% | 2.89 |
218
+ | Event ordering | 18,000 | 75.8% | 55.7% | 34.4% | 16.8% | 10.7% | 5.7% | 2.1% | 1.2% | 3.02 |
219
+ | Event ordering | 20,000 | 74.9% | 50.2% | 32.9% | 16.7% | 8.4% | 4.1% | 2.5% | 1.4% | 2.91 |
220
+ | Financial | 2,000 | 82.1% | 62.4% | 39.6% | 27.7% | 18.4% | 11.3% | 6.9% | 4.1% | 3.52 |
221
+ | Financial | 4,000 | 80.3% | 59.1% | 40.9% | 26.0% | 14.4% | 8.4% | 5.2% | 3.1% | 3.38 |
222
+ | Financial | 6,000 | 81.1% | 60.0% | 36.0% | 22.1% | 12.9% | 6.7% | 2.2% | 2.0% | 3.23 |
223
+ | Financial | 8,000 | 80.5% | 59.7% | 40.5% | 26.3% | 15.3% | 9.3% | 6.0% | 3.0% | 3.41 |
224
+ | Financial | 10,000 | 82.7% | 58.8% | 36.7% | 22.9% | 13.3% | 7.2% | 3.7% | 1.6% | 3.27 |
225
+ | Financial | 12,000 | 78.1% | 51.4% | 30.7% | 20.1% | 11.8% | 6.4% | 2.7% | 2.2% | 3.03 |
226
+ | Financial | 14,000 | 82.0% | 60.8% | 40.3% | 26.7% | 17.7% | 12.0% | 7.4% | 3.5% | 3.50 |
227
+ | Financial | 16,000 | 79.3% | 56.6% | 40.1% | 24.0% | 14.2% | 9.0% | 5.4% | 3.1% | 3.32 |
228
+ | Financial | 18,000 | 84.7% | 60.4% | 37.7% | 23.5% | 14.5% | 8.4% | 5.8% | 2.6% | 3.38 |
229
+ | Financial | 20,000 | 79.6% | 55.4% | 36.0% | 22.4% | 12.6% | 6.3% | 3.8% | 1.5% | 3.18 |
230
+ | Governmental | 2,000 | 78.2% | 59.1% | 45.0% | 28.2% | 21.2% | 14.1% | 8.8% | 6.8% | 3.61 |
231
+ | Governmental | 4,000 | 79.4% | 57.2% | 38.6% | 23.0% | 15.1% | 10.7% | 6.8% | 4.2% | 3.35 |
232
+ | Governmental | 6,000 | 80.5% | 62.1% | 39.5% | 24.5% | 16.3% | 9.6% | 5.1% | 3.2% | 3.41 |
233
+ | Governmental | 8,000 | 82.4% | 59.9% | 36.3% | 21.9% | 10.6% | 6.5% | 3.3% | 2.0% | 3.23 |
234
+ | Governmental | 10,000 | 81.5% | 57.9% | 39.9% | 26.2% | 15.9% | 10.1% | 5.8% | 2.1% | 3.39 |
235
+ | Governmental | 12,000 | 82.0% | 57.6% | 32.4% | 21.4% | 11.5% | 7.5% | 5.2% | 2.7% | 3.20 |
236
+ | Governmental | 14,000 | 81.6% | 53.7% | 30.5% | 18.9% | 11.2% | 6.4% | 2.6% | 1.4% | 3.06 |
237
+ | Governmental | 16,000 | 83.2% | 57.1% | 37.0% | 22.4% | 11.7% | 6.9% | 4.8% | 3.3% | 3.27 |
238
+ | Governmental | 18,000 | 83.0% | 59.7% | 35.9% | 22.8% | 12.4% | 7.3% | 3.0% | 1.3% | 3.26 |
239
+ | Governmental | 20,000 | 80.6% | 55.1% | 34.3% | 21.6% | 10.3% | 6.1% | 3.2% | 1.5% | 3.13 |
240
+ | Legal | 2,000 | 81.8% | 59.9% | 44.3% | 31.9% | 21.3% | 12.9% | 8.1% | 4.5% | 3.65 |
241
+ | Legal | 4,000 | 77.1% | 55.0% | 36.8% | 23.7% | 15.5% | 10.0% | 6.3% | 4.2% | 3.29 |
242
+ | Legal | 6,000 | 79.7% | 57.1% | 38.2% | 23.4% | 13.2% | 9.5% | 3.9% | 2.1% | 3.27 |
243
+ | Legal | 8,000 | 83.9% | 56.8% | 36.2% | 23.2% | 16.1% | 8.9% | 4.4% | 2.9% | 3.32 |
244
+ | Legal | 10,000 | 80.1% | 54.1% | 35.1% | 19.7% | 11.5% | 6.6% | 3.7% | 2.0% | 3.13 |
245
+ | Legal | 12,000 | 79.1% | 55.5% | 37.4% | 22.6% | 11.8% | 6.0% | 3.5% | 2.0% | 3.18 |
246
+ | Legal | 14,000 | 79.2% | 56.2% | 34.7% | 19.3% | 11.1% | 6.7% | 2.5% | 1.2% | 3.11 |
247
+ | Legal | 16,000 | 81.3% | 55.1% | 33.9% | 21.7% | 12.2% | 7.7% | 3.7% | 2.5% | 3.18 |
248
+ | Legal | 18,000 | 81.3% | 57.7% | 37.4% | 22.3% | 12.6% | 7.4% | 4.9% | 3.6% | 3.27 |
249
+ | Legal | 20,000 | 84.2% | 56.3% | 35.4% | 21.9% | 13.1% | 6.3% | 3.3% | 1.8% | 3.22 |
250
+ | Literary | 2,000 | 81.1% | 54.0% | 37.0% | 24.4% | 16.7% | 11.2% | 6.6% | 4.4% | 3.35 |
251
+ | Literary | 4,000 | 78.8% | 49.1% | 31.9% | 18.3% | 9.6% | 5.2% | 2.0% | 1.2% | 2.96 |
252
+ | Literary | 6,000 | 77.4% | 53.8% | 32.4% | 19.7% | 11.1% | 5.7% | 2.7% | 0.7% | 3.03 |
253
+ | Literary | 8,000 | 78.9% | 53.6% | 32.5% | 17.5% | 9.9% | 6.9% | 3.6% | 1.5% | 3.04 |
254
+ | Literary | 10,000 | 79.7% | 52.4% | 30.4% | 17.9% | 9.2% | 5.7% | 3.5% | 1.2% | 3.00 |
255
+ | Literary | 12,000 | 78.3% | 51.8% | 29.7% | 17.3% | 9.7% | 4.6% | 2.8% | 0.9% | 2.95 |
256
+ | Literary | 14,000 | 78.2% | 51.2% | 31.8% | 17.2% | 10.2% | 5.0% | 2.0% | 1.0% | 2.97 |
257
+ | Literary | 16,000 | 80.2% | 53.5% | 35.7% | 17.8% | 9.0% | 5.6% | 2.9% | 1.2% | 3.06 |
258
+ | Literary | 18,000 | 81.4% | 56.4% | 35.9% | 20.0% | 11.6% | 5.4% | 2.2% | 1.2% | 3.14 |
259
+ | Literary | 20,000 | 75.8% | 54.8% | 34.4% | 17.3% | 9.2% | 4.3% | 2.3% | 1.0% | 2.99 |
260
+ | Multi-news | 2,000 | 85.1% | 64.4% | 45.8% | 34.4% | 25.1% | 15.5% | 11.8% | 9.3% | 3.91 |
261
+ | Multi-news | 4,000 | 80.3% | 58.1% | 40.0% | 25.3% | 16.8% | 10.1% | 6.1% | 2.9% | 3.40 |
262
+ | Multi-news | 6,000 | 80.7% | 62.2% | 42.9% | 25.2% | 15.0% | 7.2% | 5.6% | 3.8% | 3.43 |
263
+ | Multi-news | 8,000 | 79.3% | 58.2% | 40.4% | 27.7% | 16.2% | 9.6% | 6.6% | 4.5% | 3.43 |
264
+ | Multi-news | 10,000 | 83.7% | 56.1% | 39.8% | 24.3% | 15.0% | 10.1% | 4.4% | 2.6% | 3.36 |
265
+ | Multi-news | 12,000 | 78.0% | 56.1% | 34.6% | 21.2% | 12.0% | 7.1% | 3.4% | 2.0% | 3.14 |
266
+ | Multi-news | 14,000 | 80.2% | 60.6% | 41.3% | 26.3% | 14.7% | 9.7% | 5.6% | 2.9% | 3.41 |
267
+ | Multi-news | 16,000 | 80.4% | 60.7% | 40.3% | 25.9% | 13.1% | 8.6% | 5.2% | 2.6% | 3.37 |
268
+ | Multi-news | 18,000 | 78.8% | 56.3% | 37.1% | 21.5% | 12.5% | 6.6% | 3.6% | 2.0% | 3.18 |
269
+ | Multi-news | 20,000 | 82.4% | 55.6% | 35.7% | 24.8% | 12.4% | 5.9% | 3.6% | 2.3% | 3.23 |
270
+
271
+ </details>
272
+
273
+ ## Performance Eval
274
+
275
+ ![speedup_math_reasoning_itl](https://cdn-uploads.huggingface.co/production/uploads/67f401f4bb5b52cdad90f9a7/FDDscE_EQwMvKVwVcj-wE.png)
276
+
config.json ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DSparkDraftModel"
4
+ ],
5
+ "auto_map": {
6
+ "": "config.DSparkSpeculatorConfig"
7
+ },
8
+ "aux_hidden_state_layer_ids": [
9
+ 24,
10
+ 48,
11
+ 72,
12
+ 88,
13
+ 92
14
+ ],
15
+ "block_size": 8,
16
+ "confidence_head_with_markov": true,
17
+ "draft_vocab_size": 163840,
18
+ "dtype": "bfloat16",
19
+ "enable_confidence_head": true,
20
+ "markov_head_type": "vanilla",
21
+ "markov_rank": 256,
22
+ "mask_token_id": 163837,
23
+ "sample_from_anchor": true,
24
+ "sliding_window_non_causal": false,
25
+ "speculators_config": {
26
+ "algorithm": "dspark",
27
+ "default_proposal_method": "greedy",
28
+ "proposal_methods": [
29
+ {
30
+ "accept_tolerance": 0.0,
31
+ "proposal_type": "greedy",
32
+ "speculative_tokens": 8,
33
+ "verifier_accept_k": 1
34
+ }
35
+ ],
36
+ "verifier": {
37
+ "architectures": [
38
+ "KimiK3ForConditionalGeneration"
39
+ ],
40
+ "name_or_path": "moonshotai/Kimi-K3"
41
+ }
42
+ },
43
+ "speculators_model_type": "dspark",
44
+ "speculators_version": "0.7.0.dev141",
45
+ "target_hidden_size": null,
46
+ "tie_word_embeddings": false,
47
+ "transformer_layer_config": {
48
+ "attention_bias": false,
49
+ "attention_dropout": 0.0,
50
+ "bos_token_id": 163584,
51
+ "eos_token_id": 163586,
52
+ "flex_attention_backend": "FLASH",
53
+ "head_dim": 64,
54
+ "hidden_act": "silu",
55
+ "hidden_size": 7168,
56
+ "initializer_range": 0.02,
57
+ "intermediate_size": 14336,
58
+ "layer_types": [
59
+ "sliding_attention",
60
+ "sliding_attention",
61
+ "sliding_attention",
62
+ "sliding_attention",
63
+ "sliding_attention"
64
+ ],
65
+ "max_position_embeddings": 1048576,
66
+ "max_window_layers": 28,
67
+ "model_type": "qwen3",
68
+ "num_attention_heads": 96,
69
+ "num_hidden_layers": 5,
70
+ "num_key_value_heads": 16,
71
+ "pad_token_id": 163839,
72
+ "rms_norm_eps": 1e-05,
73
+ "rope_parameters": {
74
+ "rope_theta": 10000.0,
75
+ "rope_type": "default"
76
+ },
77
+ "sliding_window": 2048,
78
+ "tie_word_embeddings": false,
79
+ "use_cache": true,
80
+ "use_sliding_window": true,
81
+ "vocab_size": 163840
82
+ },
83
+ "transformers_version": "5.14.1"
84
+ }
config.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from speculators import SpeculatorModelConfig
6
+ from speculators.models.dflash.config import DFlashSpeculatorConfig
7
+
8
+ __all__ = [
9
+ "DSparkSpeculatorConfig",
10
+ ]
11
+
12
+
13
+ @SpeculatorModelConfig.register("dspark")
14
+ class DSparkSpeculatorConfig(DFlashSpeculatorConfig):
15
+ """DFlash config plus a Markov logit-bias head and a confidence head.
16
+
17
+ The Markov head lets each draft position condition on previously sampled
18
+ tokens within the block; the confidence head predicts the per-position
19
+ acceptance probability. All DFlash fields are inherited unchanged.
20
+ """
21
+
22
+ speculators_model_type: Literal["dspark"] = "dspark" # type: ignore[assignment]
23
+ architectures: list[str] = Field(
24
+ default_factory=lambda: ["DSparkSpeculator"],
25
+ description="Model architectures that can load these weights",
26
+ )
27
+
28
+ sample_from_anchor: bool = Field(
29
+ default=True,
30
+ description=(
31
+ "Whether to sample from the anchor position. "
32
+ "False: anchor is the bonus token, only mask tokens predict "
33
+ "(block_size-1 speculative tokens). "
34
+ "True: sample from anchor and all mask positions "
35
+ "(block_size speculative tokens). "
36
+ "Default True matches DeepSeek/DeepSpec convention."
37
+ ),
38
+ )
39
+
40
+ # Sequential (Markov) head.
41
+ markov_rank: int = Field(
42
+ default=256,
43
+ description=(
44
+ "Low-rank dimension of the Markov logit-bias factorization B = W1 @ W2. "
45
+ "Set to 0 to disable the sequential head (pure DFlash drafting)."
46
+ ),
47
+ )
48
+ markov_head_type: Literal["vanilla", "gated", "rnn"] = Field(
49
+ default="vanilla",
50
+ description=(
51
+ "Sequential head variant: 'vanilla' (first-order Markov bias), 'gated' "
52
+ "(hidden-gated bias), or 'rnn' (recurrent state over the block)."
53
+ ),
54
+ )
55
+
56
+ # Confidence head.
57
+ enable_confidence_head: bool = Field(
58
+ default=True,
59
+ description="Whether to attach the per-position acceptance-probability head.",
60
+ )
61
+ confidence_head_with_markov: bool = Field(
62
+ default=True,
63
+ description=(
64
+ "Concatenate the Markov previous-token embedding with the backbone "
65
+ "hidden state as the confidence-head input."
66
+ ),
67
+ )
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0262abfd7418d2ecbc3a077790851c1af2f8879016b00e7decb9d43d7c1277b4
3
+ size 9489807826