qianlihuang commited on
Commit
d0888d9
·
verified ·
1 Parent(s): 0c242a3

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +134 -0
  2. config.json +102 -0
  3. config.py +42 -0
  4. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-generation
5
+ base_model:
6
+ - Kwaipilot/KAT-Coder-V2.5-Dev
7
+ inference: false
8
+ tags:
9
+ - dflash2
10
+ - speculative-decoding
11
+ - draft-model
12
+ - moe
13
+ - code
14
+ - speculators
15
+ - vllm
16
+ ---
17
+
18
+ # KAT-Coder-V2.5-Dev-DFlash2-2.6B-A0.3B
19
+
20
+ A Mixture-of-Experts DFlash2 drafter for [`Kwaipilot/KAT-Coder-V2.5-Dev`](https://huggingface.co/Kwaipilot/KAT-Coder-V2.5-Dev).
21
+
22
+ Modern MoE target models are well suited to expert offloading on memory-constrained systems and large-scale expert parallelism at datacenter scale. Applying the same sparse structure to speculative drafters is therefore a natural direction. Strong precedents include [`DeepSeek-V3`](https://huggingface.co/deepseek-ai/DeepSeek-V3) MTP and [`DeepSeek-V4-Flash-0731`](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash-0731) DSpark.
23
+
24
+ This release explores the same direction with a DFlash2 drafter: approximately 2.6B total parameters with approximately 0.3B activated per token.
25
+
26
+ ## Results
27
+
28
+ | Setting | Value |
29
+ | --------------------- | ------------------------------------------------------------------- |
30
+ | Engine | vLLM |
31
+ | Hardware | NVIDIA H200, TP1 |
32
+ | Concurrency | 1 |
33
+ | Target | `Kwaipilot/KAT-Coder-V2.5-Dev` BF16 |
34
+ | Thinking sampling | `temperature=1.0`, `top_p=0.95`, `top_k=20`, `presence_penalty=1.5` |
35
+ | Thinking mode | `enable_thinking=true` |
36
+ | Non-thinking sampling | `temperature=0.7`, `top_p=0.8`, `top_k=20`, `presence_penalty=1.5` |
37
+ | Non-thinking mode | `enable_thinking=false` |
38
+ | Max new tokens | 4,096 |
39
+ | Context | native 262,144 |
40
+ | Draft tokens | 7 per verification step |
41
+
42
+ | Benchmark | Samples | Thinking AL | Non-thinking AL |
43
+ | -------------------------- | ------: | ----------: | --------------: |
44
+ | AA-LCR | 100 | *TBD* | *TBD* |
45
+ | AIME26 | 30 | *TBD* | *TBD* |
46
+ | GSM8K | 1,319 | *TBD* | *TBD* |
47
+ | HumanEval | 164 | *TBD* | *TBD* |
48
+ | LiveCodeBench | 1,055 | *TBD* | *TBD* |
49
+ | LongBench-v2 | 402 | *TBD* | *TBD* |
50
+ | MATH500 | 500 | *TBD* | *TBD* |
51
+ | MBPP | 257 | *TBD* | *TBD* |
52
+ | MT-Bench | 80 | *TBD* | *TBD* |
53
+ | SWE-bench Pro | 731 | *TBD* | *TBD* |
54
+ | SpeedBench / coding | 80 | *TBD* | *TBD* |
55
+ | SpeedBench / humanities | 80 | *TBD* | *TBD* |
56
+ | SpeedBench / math | 80 | *TBD* | *TBD* |
57
+ | SpeedBench / multilingual | 80 | *TBD* | *TBD* |
58
+ | SpeedBench / qa | 80 | *TBD* | *TBD* |
59
+ | SpeedBench / rag | 80 | *TBD* | *TBD* |
60
+ | SpeedBench / reasoning | 80 | *TBD* | *TBD* |
61
+ | SpeedBench / roleplay | 80 | *TBD* | *TBD* |
62
+ | SpeedBench / stem | 80 | *TBD* | *TBD* |
63
+ | SpeedBench / summarization | 80 | *TBD* | *TBD* |
64
+ | SpeedBench / writing | 80 | *TBD* | *TBD* |
65
+
66
+ Accepted length is calculated from the raw server counters:
67
+
68
+ ```text
69
+ accepted_length = 1 + accepted_tokens / draft_calls
70
+ ```
71
+
72
+ ## Architecture
73
+
74
+ | Setting | Value |
75
+ | --- | --- |
76
+ | Draft layers | 3 |
77
+ | Auxiliary hidden-state IDs | `[3, 12, 21, 30, 39]` |
78
+ | Hidden size | 2,048 |
79
+ | MoE FFN | 256 routed experts, top-8 routing |
80
+ | Routed expert intermediate | 512 |
81
+ | Shared expert | 1 expert, intermediate size 512 |
82
+ | Router | softmax, top-k normalization |
83
+ | Shared-expert gate | sigmoid |
84
+ | Attention | 32 Q heads / 4 KV heads |
85
+ | Head dimension | 128 |
86
+ | Attention window | sliding window 2,048 |
87
+ | Draft attention | non-causal inside the draft block |
88
+ | RoPE theta | 1e7 |
89
+ | Norm / activation | RMSNorm eps 1e-6 / SiLU |
90
+ | Dynamic convolution | kernel 2, group 16 |
91
+ | Candidate selector | rank 256, top-k 16 |
92
+ | Block | 7 draft tokens, `sample_from_anchor=true` |
93
+ | Draft vocabulary | 248,320 |
94
+ | Parameters | 2,638,551,808 total / 298,130,176 activated per token |
95
+
96
+ ## Example: Run with vLLM
97
+
98
+ This is a drafter checkpoint, not a standalone language model. Pair it with KAT-Coder or a compatible quantized version:
99
+
100
+ ```bash
101
+ vllm serve Kwaipilot/KAT-Coder-V2.5-Dev \
102
+ --tensor-parallel-size 1 \
103
+ --reasoning-parser qwen3 \
104
+ --enable-auto-tool-choice \
105
+ --tool-call-parser qwen3_coder \
106
+ --language-model-only \
107
+ --speculative-config '{
108
+ "method": "dflash",
109
+ "model": "DaoCloud/KAT-Coder-V2.5-Dev-DFlash2-2.6B-A0.3B",
110
+ "num_speculative_tokens": 7
111
+ }'
112
+ ```
113
+
114
+ This checkpoint currently requires a vLLM build containing both [vLLM PR #54154](https://github.com/vllm-project/vllm/pull/54154), which adds the `sample_from_anchor=true` DFlash query layout, and [vLLM PR #54475](https://github.com/vllm-project/vllm/pull/54475), which adds MoE DFlash2.
115
+
116
+ ## Checkpoint
117
+
118
+ The BF16 checkpoint contains 63 tensors and 2,638,551,808 parameters.
119
+
120
+ | File | SHA256 |
121
+ | --- | --- |
122
+ | `model.safetensors` | _TBD_ |
123
+
124
+ ## Future work
125
+
126
+ - Adaptive verification: explore confidence-head-driven adaptive draft budgets for high-concurrency serving.
127
+
128
+ ## Acknowledgements
129
+
130
+ This work builds on [`Kwaipilot/KAT-Coder-V2.5-Dev`](https://huggingface.co/Kwaipilot/KAT-Coder-V2.5-Dev), [`vllm-project/speculators`](https://github.com/vllm-project/speculators), and [`vllm-project/vllm`](https://github.com/vllm-project/vllm).
131
+
132
+ ## License
133
+
134
+ Apache-2.0.
config.json ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlash2DraftModel"
4
+ ],
5
+
6
+ "aux_hidden_state_layer_ids": [
7
+ 3,
8
+ 12,
9
+ 21,
10
+ 30,
11
+ 39
12
+ ],
13
+
14
+ "block_size": 7,
15
+ "sample_from_anchor": true,
16
+
17
+ "draft_vocab_size": 248320,
18
+ "mask_token_id": 248077,
19
+
20
+ "conv_kernel_size": 2,
21
+ "conv_group_size": 16,
22
+
23
+ "selector_rank": 256,
24
+ "selector_top_k": 16,
25
+
26
+ "draft_ffn_type": "moe",
27
+ "num_experts": 256,
28
+ "num_experts_per_tok": 8,
29
+ "moe_intermediate_size": 512,
30
+ "shared_expert_intermediate_size": 512,
31
+ "norm_topk_prob": true,
32
+
33
+ "sliding_window_non_causal": true,
34
+
35
+ "dtype": "bfloat16",
36
+ "tie_word_embeddings": false,
37
+
38
+ "speculators_model_type": "dflash2",
39
+
40
+ "speculators_config": {
41
+ "algorithm": "dflash2",
42
+ "default_proposal_method": "greedy",
43
+ "proposal_methods": [
44
+ {
45
+ "accept_tolerance": 0.0,
46
+ "proposal_type": "greedy",
47
+ "speculative_tokens": 7,
48
+ "verifier_accept_k": 1
49
+ }
50
+ ],
51
+ "verifier": {
52
+ "architectures": [
53
+ "Qwen3_5MoeForConditionalGeneration"
54
+ ],
55
+ "name_or_path": "Kwaipilot/KAT-Coder-V2.5-Dev"
56
+ }
57
+ },
58
+
59
+ "transformer_layer_config": {
60
+ "model_type": "qwen3",
61
+
62
+ "vocab_size": 248320,
63
+ "hidden_size": 2048,
64
+ "intermediate_size": 512,
65
+ "num_hidden_layers": 3,
66
+
67
+ "num_attention_heads": 32,
68
+ "num_key_value_heads": 4,
69
+ "head_dim": 128,
70
+
71
+ "hidden_act": "silu",
72
+ "rms_norm_eps": 1e-06,
73
+ "initializer_range": 0.02,
74
+
75
+ "attention_bias": false,
76
+ "attention_dropout": 0.0,
77
+
78
+ "use_sliding_window": true,
79
+ "sliding_window": 2048,
80
+ "max_window_layers": 0,
81
+
82
+ "layer_types": [
83
+ "sliding_attention",
84
+ "sliding_attention",
85
+ "sliding_attention"
86
+ ],
87
+
88
+ "max_position_embeddings": 262144,
89
+
90
+ "rope_parameters": {
91
+ "rope_theta": 10000000.0,
92
+ "rope_type": "default"
93
+ },
94
+
95
+ "use_cache": true,
96
+ "tie_word_embeddings": false,
97
+
98
+ "bos_token_id": null,
99
+ "eos_token_id": null,
100
+ "pad_token_id": null
101
+ }
102
+ }
config.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal
2
+
3
+ from pydantic import Field, model_validator
4
+
5
+ from speculators import SpeculatorModelConfig
6
+ from speculators.models.dflash.config import DFlashSpeculatorConfig
7
+
8
+
9
+ @SpeculatorModelConfig.register("dflash2")
10
+ class DFlash2SpeculatorConfig(DFlashSpeculatorConfig):
11
+ """DFlash2 draft-model configuration."""
12
+
13
+ speculators_model_type: Literal["dflash2"] = "dflash2" # type: ignore[assignment]
14
+
15
+ architectures: list[str] = Field(
16
+ default_factory=lambda: ["DFlash2DraftModel"],
17
+ )
18
+
19
+ sliding_window_non_causal: bool = True
20
+
21
+ conv_kernel_size: int = Field(default=2, ge=1)
22
+ conv_group_size: int = Field(default=16, ge=1)
23
+ selector_rank: int = Field(default=256, ge=1)
24
+ selector_top_k: int = Field(default=16, ge=1)
25
+
26
+ draft_ffn_type: Literal["dense", "moe"] = "dense"
27
+ num_experts: int = Field(default=256, ge=1)
28
+ num_experts_per_tok: int = Field(default=8, ge=1)
29
+ moe_intermediate_size: int = Field(default=512, ge=1)
30
+ shared_expert_intermediate_size: int = Field(default=512, ge=1)
31
+
32
+ @model_validator(mode="after")
33
+ def validate_moe_routing(self) -> "DFlash2SpeculatorConfig":
34
+ if (
35
+ self.draft_ffn_type == "moe"
36
+ and self.num_experts_per_tok > self.num_experts
37
+ ):
38
+ raise ValueError(
39
+ "num_experts_per_tok cannot exceed num_experts: "
40
+ f"{self.num_experts_per_tok} > {self.num_experts}."
41
+ )
42
+ return self
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8e96fdfa924405443b566be3a961eb087cd6991665040b05d7c3ec739d5469ee
3
+ size 5277110680