shaikat2007 bwshen-mi commited on
Commit
6fa56a5
·
0 Parent(s):

Duplicate from XiaomiMiMo/MiMo-V2.6-Pro-RL

Browse files

Co-authored-by: Bowen Shen <bwshen-mi@users.noreply.huggingface.co>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +39 -0
  2. MiMo_V2_6_technical_report.pdf +3 -0
  3. README.md +237 -0
  4. assets/architecture.png +3 -0
  5. audio_tokenizer/chat_template.jinja +120 -0
  6. audio_tokenizer/config.json +68 -0
  7. audio_tokenizer/generation_config.json +9 -0
  8. audio_tokenizer/model.safetensors +3 -0
  9. audio_tokenizer/tokenizer_config.json +267 -0
  10. chat_template.jinja +95 -0
  11. config.json +441 -0
  12. configuration_mimo_v2.py +247 -0
  13. dflash/config.json +56 -0
  14. dflash/dflash.py +379 -0
  15. dflash/dflash_draft_model.safetensors +3 -0
  16. dflash/mask_embedding.pt +3 -0
  17. dflash/model.safetensors.index.json +70 -0
  18. generation_config.json +9 -0
  19. merges.txt +0 -0
  20. model.safetensors.index.json +3 -0
  21. model_mtp.safetensors +3 -0
  22. model_pp0_ep0_shard0.safetensors +3 -0
  23. model_pp0_ep0_shard1.safetensors +3 -0
  24. model_pp0_ep100_shard0.safetensors +3 -0
  25. model_pp0_ep101_shard0.safetensors +3 -0
  26. model_pp0_ep102_shard0.safetensors +3 -0
  27. model_pp0_ep103_shard0.safetensors +3 -0
  28. model_pp0_ep104_shard0.safetensors +3 -0
  29. model_pp0_ep105_shard0.safetensors +3 -0
  30. model_pp0_ep106_shard0.safetensors +3 -0
  31. model_pp0_ep107_shard0.safetensors +3 -0
  32. model_pp0_ep108_shard0.safetensors +3 -0
  33. model_pp0_ep109_shard0.safetensors +3 -0
  34. model_pp0_ep10_shard0.safetensors +3 -0
  35. model_pp0_ep110_shard0.safetensors +3 -0
  36. model_pp0_ep111_shard0.safetensors +3 -0
  37. model_pp0_ep112_shard0.safetensors +3 -0
  38. model_pp0_ep113_shard0.safetensors +3 -0
  39. model_pp0_ep114_shard0.safetensors +3 -0
  40. model_pp0_ep115_shard0.safetensors +3 -0
  41. model_pp0_ep116_shard0.safetensors +3 -0
  42. model_pp0_ep117_shard0.safetensors +3 -0
  43. model_pp0_ep118_shard0.safetensors +3 -0
  44. model_pp0_ep119_shard0.safetensors +3 -0
  45. model_pp0_ep11_shard0.safetensors +3 -0
  46. model_pp0_ep120_shard0.safetensors +3 -0
  47. model_pp0_ep121_shard0.safetensors +3 -0
  48. model_pp0_ep122_shard0.safetensors +3 -0
  49. model_pp0_ep123_shard0.safetensors +3 -0
  50. model_pp0_ep124_shard0.safetensors +3 -0
.gitattributes ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
+ MiMo_V2_6_technical_report.pdf filter=lfs diff=lfs merge=lfs -text
37
+ model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
38
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
39
+ assets/architecture.png filter=lfs diff=lfs merge=lfs -text
MiMo_V2_6_technical_report.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb81e6e083801b3358f084ed6be953dc23b0d2e434690f4541d5eae03e01e7af
3
+ size 3046687
README.md ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ - zh
6
+ tags:
7
+ - text-generation
8
+ - multimodal
9
+ - vision-language
10
+ - audio
11
+ - agent
12
+ - video-understanding
13
+ - long-context
14
+ - mimo_v2
15
+ - transformers
16
+ library_name: transformers
17
+ ---
18
+
19
+ <br/><br/>
20
+
21
+ <div align="center">
22
+ <picture>
23
+ <source srcset="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/Xiaomi_MiMo_darkmode.png?raw=true" media="(prefers-color-scheme: dark)">
24
+ <img src="https://github.com/XiaomiMiMo/MiMo/raw/main/figures/Xiaomi_MiMo.png?raw=true" width="60%" alt="Xiaomi-MiMo" />
25
+ </picture>
26
+ </div>
27
+
28
+ <br/>
29
+
30
+ <div align="center" style="line-height: 1;">
31
+ |
32
+ <a href="https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Pro-RL" target="_blank">🤗 HuggingFace</a>
33
+ &nbsp;|
34
+ <a href="https://mimo.xiaomi.com/mimo-v2-6" target="_blank">📰 Blog </a>
35
+ &nbsp;|
36
+ <a href="https://platform.xiaomimimo.com" target="_blank">🎨 Xiaomi MiMo API Platform </a>
37
+ &nbsp;|
38
+ <a href="https://aistudio.xiaomimimo.com" target="_blank">🗨️ Xiaomi MiMo Studio </a>
39
+ &nbsp;|
40
+ <a href="https://mimo.xiaomimimo.com/desktop/" target="_blank">💻 Xiaomi MiMo Desktop </a>
41
+ &nbsp;|
42
+ </div>
43
+
44
+ <br/>
45
+
46
+ <div align="center" style="line-height: 1.2;">
47
+ <strong>Community</strong><br/>
48
+ <a href="https://huggingface.co/XiaomiMiMo/MiMo-V2.5-Pro/blob/main/assets/wechat.jpg" target="_blank">WeChat Group</a>
49
+ &nbsp;|&nbsp;
50
+ <a href="https://discord.gg/kKC2kNnQEX" target="_blank">Discord</a>
51
+ &nbsp;|&nbsp;
52
+ <a href="https://t.me/+3T-I0pekOVIyNDBl" target="_blank">Telegram</a>
53
+ &nbsp;|&nbsp;
54
+ <a href="https://www.reddit.com/r/XiaomiMiMo_Official/" target="_blank">Reddit</a>
55
+ </div>
56
+
57
+ <br/>
58
+
59
+ # MiMo-V2.6-Pro-RL
60
+
61
+ **Scaling Reinforcement Learning Toward Self-Improvement**
62
+
63
+ <p align="center">
64
+ <a href="https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Pro-RL/blob/main/MiMo_V2_6_technical_report.pdf"><b>Technical Report</b></a>
65
+ </p>
66
+
67
+ ## 1. Introduction
68
+
69
+ MiMo-V2.6-Pro-RL is the flagship checkpoint of the MiMo-V2.6 series. The series is built to **scale reinforcement learning toward self-improvement** — scaling RL compute, environment diversity, and grader compute together, so the model keeps expanding its capability frontier through exploration and feedback. Key features include:
70
+
71
+ - **Native Omnimodal + Long Horizon**: Text, image, video, and audio in one model; 1M tokens for long repositories, tool traces, and multi-session agent runs.
72
+ - **You Only RL Once**: One mixed RL run across coding, general agents, visual, and cybersecurity — not separate per-domain runs. Tasks and multiple harnesses are mixed in the same batch so capabilities reinforce each other and strategies transfer to harnesses never seen in training.
73
+ - **Scaling RL Compute**: Fully asynchronous Group Relative Policy Optimization (GRPO) on very large batches — 1,568 prompts × 16 rollouts per step, billions of tokens per update.
74
+ - **Groupwise Agentic Grading (Self-Improvement Loop)**: Binary pass/fail cannot rank passing solutions, so the reward signal itself is scaled. An agentic grader compares rollouts *within each group*: **Groupwise Reward Synthesis (GRS)** builds task-specific rubrics offline from contrasting rollouts and fuses rubric quality with test outcomes; **Groupwise Advantage Redistribution (GAR)** ranks passing trajectories online and moves advantage toward higher-quality solutions. Judged against the policy’s own samples, this closes a self-improvement loop and steers toward shorter paths and fewer tokens per task.
75
+ - **Aligned RL**: Cold start from self-correction — the model reflects on and rewrites its own misaligned turns into grounded next steps. Throughout RL, environment hardening, adversarial screening, and verifier cross-checks keep the loop honest against reward hacking.
76
+ - **Multi-Prefix Multi-Teacher On-Policy Distillation (MOPD2)**: After mixed RL, MOPD2 combines autonomous student rollouts with prefix-conditioned single-turn rollouts (Teacher-Prefix and SFT-Prefix), reusing histories from teacher trajectories and SFT demonstrations so decision points train without regenerating preceding turns — extending capabilities to hard-to-verify tasks.
77
+
78
+ ## Model Summary
79
+
80
+ - **Architecture**: Sparse MoE (Mixture of Experts), 1.02T total / 42B activated parameters
81
+ - **Context Length**: 1M tokens
82
+ - **Modalities**: Text, Image, Video, Audio
83
+ - **Vision Encoder**: 681M-param MiMo ViT (28 layers: 24 SWA + 4 Full)
84
+ - **Audio Encoder**: 308M AudioTokenizer + 127M audio patch encoder
85
+ - **Multi-Token Prediction (MTP)**: 5-layer speculative decoder
86
+
87
+ ![Figure 1: MiMo-V2.6 architecture — omni encoders, hybrid SWA backbone, and MTP blocks](assets/architecture.png)
88
+
89
+ *Figure 1. MiMo-V2.6 architecture.*
90
+
91
+ ## 2. Downloads
92
+
93
+ | Model | Download |
94
+ | --- | --- |
95
+ | **MiMo-V2.6-Pro-RL** | [🤗 HuggingFace](https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Pro-RL) · [🤖 ModelScope](https://www.modelscope.cn/models/XiaomiMiMo/MiMo-V2.6-Pro-RL) |
96
+ | **MiMo-V2.6-Flash-RL** | [🤗 HuggingFace](https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Flash-RL) · [🤖 ModelScope](https://www.modelscope.cn/models/XiaomiMiMo/MiMo-V2.6-Flash-RL) |
97
+
98
+ ## 3. Evaluation Results
99
+
100
+ | Benchmark | MiMo-V2.6 Pro | MiMo-V2.6 Flash | MiMo-V2.5 Pro | Claude Opus 5 | GPT-5.6 Sol | Claude Fable 5 |
101
+ | --- | --- | --- | --- | --- | --- | --- |
102
+ | **Code Agent** | | | | | | |
103
+ | DeepSWE v1.1 | 71.9 | 67.9 | 19.0 | 74.0 | 73.0 | 70.0 |
104
+ | ProgramBench | 26.5 | 26.0 | 12.5 | 37.0 | 25.0 | 33.0 |
105
+ | MiMo Code Bench | 63.2 | 61.2 | 40.4 | 68.6 | 59.3 | - |
106
+ | **General Agent** | | | | | | |
107
+ | AutomationBench v1.0.6 | 53.1 | 52.3 | 16.0 | 50.3 | 45.8 | 46.2 |
108
+ | Toolathlon-Verified | 76.9 | 73.6 | 49.1 | 80.6 | 74.9 | 77.9 |
109
+ | GDPval-AA 2.1 | 1673 | - | 1107 | 1708 | 1588 | 1595 |
110
+ | Agents’ Last Exam | 31.6 | 27.6 | 13.2 | 31.6 | 30.8 | 25.7 |
111
+ | Terminal Bench 4.0 | 34.9 | 28.8 | 1.5 | 49.0 | 39.9 | 42.4 |
112
+ | Terminal Bench 2.1 | 89.9 | 87.6 | 65.2 | 89.1 | 88.8 | 84.3 |
113
+ | OSWorld-Verified | 82.0 | 80.8 | - | 83.4 | 83.0 | 86.0 |
114
+ | JobBench | 62.0 | 61.2 | 25.0 | 65.7 | 45.4 | 57.4 |
115
+ | **Cybersecurity** | | | | | | |
116
+ | CyberGym | 94.0 | 95.1 | 40.0 | - | - | - |
117
+ | MiMo Cyber Bench | 80.2 | 77.2 | 0.0 | - | - | - |
118
+ | ExploitGym | 17.8 | 6.0 | 0.2 | 22.1 | 30.3 | 28.4 |
119
+ | ExploitBench | 47.9 | 25.3 | 16.6 | 70.0 | 78.5 | 78.0 |
120
+ | SEC Bench Pro | 66.3 | 47.5 | 17.7 | - | 79.1 | - |
121
+ | **Visual Agent** | | | | | | |
122
+ | MiMo VisualCoding | 72.3 | 71.5 | - | 70.0 | 73.4 | 69.1 |
123
+
124
+ ## 4. Model Architecture
125
+
126
+ ### LLM Backbone
127
+
128
+ | Component | MiMo-V2.6-Pro-RL |
129
+ | --- | --- |
130
+ | Layers (Total / SWA / GA) | 70 / 60 / 10 |
131
+ | Hidden Size | 6144 |
132
+ | SWA Heads (Q/KV) | 128 / 8 |
133
+ | GA Heads (Q/KV) | 128 / 8 |
134
+ | Head Dimensions (QK / V) | 192 / 128 |
135
+ | Sliding Window Size | 128 |
136
+ | Routed Experts (Total / Activated) | 384 / 8 |
137
+ | Max Context Length | 1M |
138
+ | MTP / Speculative Decoder | 5 SWA layers, window 1024 |
139
+
140
+ The first Transformer block uses global attention with a dense FFN. Remaining blocks interleave local SWA and GA; both use sparse MoE FFNs without shared experts.
141
+
142
+ ### Vision Encoder (MiMo ViT)
143
+
144
+ | Configuration | Value |
145
+ | --- | --- |
146
+ | Layers (Total / SWA / GA) | 28 / 24 / 4 |
147
+ | Hidden Size | 1280 |
148
+ | Attention Heads (Q / KV) | 32 / 8 |
149
+ | Head Dimension | 64 |
150
+ | Patch Size (T × H × W) | 2 × 16 × 16 |
151
+ | Sliding Window (Left / Right) | 64 / 64 |
152
+ | Spatial Merge Size | 2 × 2 |
153
+ | Parameters | 681M |
154
+
155
+ ### Audio Encoders
156
+
157
+ AudioTokenizer encoder: 24 layers (12 SWA / 12 GA), hidden 1024, 20 RVQ codebooks, 308M parameters. Audio patch encoder: 6 layers, 127M parameters; four frames per patch (25 Hz → 6.25 Hz).
158
+
159
+ ### Speculative Decoder
160
+
161
+ 5-layer SWA MTP drafter (DFlash-style). Predicts 7 subsequent tokens per forward pass for parallel verification.
162
+
163
+ ## 5. Deployment
164
+
165
+ For best performance, follow the [SGLang MiMo cookbook](https://docs.sglang.io/cookbook/autoregressive/Xiaomi/MiMo-V2.5). Docker image: `lmsysorg/sglang:latest`.
166
+
167
+ ### SGLang
168
+
169
+ ```bash
170
+ sglang serve \
171
+ --trust-remote-code \
172
+ --model-path XiaomiMiMo/MiMo-V2.6-Pro-RL \
173
+ --tp 16 \
174
+ --dp 2 \
175
+ --enable-dp-attention \
176
+ --mm-enable-dp-encoder \
177
+ --ep 16 \
178
+ --moe-a2a-backend deepep \
179
+ --moe-dense-tp-size 1 \
180
+ --mem-fraction-static 0.7 \
181
+ --max-running-requests 128 \
182
+ --chunked-prefill-size 32768 \
183
+ --page-size 64 \
184
+ --swa-full-tokens-ratio 0.3 \
185
+ --speculative-algorithm EAGLE \
186
+ --speculative-num-steps 3 \
187
+ --speculative-eagle-topk 1 \
188
+ --speculative-num-draft-tokens 4 \
189
+ --enable-multi-layer-eagle \
190
+ --reasoning-parser mimo \
191
+ --tool-call-parser mimo \
192
+ --host 0.0.0.0 \
193
+ --port 30000 \
194
+ --nnodes 2 \
195
+ --node-rank <node-rank> \
196
+ --dist-init-addr <node0-ip>:20000
197
+ ```
198
+
199
+ ### vLLM
200
+
201
+ Follow the [vLLM MiMo-V2.5 recipe](https://recipes.vllm.ai/XiaomiMiMo/MiMo-V2.5). Pre-built image: `docker pull vllm/vllm-openai:mimov25-cu129`.
202
+
203
+ ```bash
204
+ vllm serve XiaomiMiMo/MiMo-V2.6-Pro-RL \
205
+ --tensor-parallel-size 8 \
206
+ --trust-remote-code \
207
+ --gpu-memory-utilization 0.95 \
208
+ --max-model-len auto \
209
+ --reasoning-parser mimo \
210
+ --tool-call-parser mimo \
211
+ --enable-auto-tool-choice \
212
+ --generation-config vllm
213
+ ```
214
+
215
+ Recommended sampling: `temperature=1.0`, `top_p=0.95`.
216
+
217
+ Also available in AI Studio, MiMo Code, Xiaomi MiMo Desktop, Xiaomi MiMo Open Platform API, and OpenRouter.
218
+
219
+ ## Citation
220
+
221
+ ```bibtex
222
+ @misc{mimo2026v26pro,
223
+ title={MiMo-V2.6-Pro-RL},
224
+ author={{Xiaomi MiMo Team}},
225
+ year={2026},
226
+ howpublished={\url{https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Pro-RL}},
227
+ }
228
+ ```
229
+
230
+ ## Contact
231
+
232
+ For questions or feedback, reach us at [mimo@xiaomi.com](mailto:mimo@xiaomi.com) or join our community:
233
+
234
+ - [WeChat Group](https://work.weixin.qq.com/apph5/external_room/join/group_mng?plg_id=c417f99bd9014b5dd894daa8bfe19790&)
235
+ - [Discord](https://discord.gg/WX2R2uNp)
236
+ - [Telegram](https://t.me/+3T-I0pekOVIyNDBl)
237
+ - [Reddit](https://www.reddit.com/r/XiaomiMiMo_Official/)
assets/architecture.png ADDED

Git LFS Details

  • SHA256: d288768e1771fec19b39ed7dbac4adcbbd2e490384d4ad3c58d259b0c6c6bdcc
  • Pointer size: 131 Bytes
  • Size of remote file: 405 kB
audio_tokenizer/chat_template.jinja ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0].role == 'system' %}
4
+ {%- if messages[0].content is string %}
5
+ {{- messages[0].content }}
6
+ {%- else %}
7
+ {%- for content in messages[0].content %}
8
+ {%- if content.type == 'audio' %}
9
+ {{- ("<|sosp|>" + (content.meta | tojson) + "<|eosp|>") }}
10
+ {%- elif content.type == 'text' %}
11
+ {{- content.text }}
12
+ {%- endif %}
13
+ {%- endfor %}
14
+ {%- endif %}
15
+ {%- endif %}
16
+ {{- '\n\n' }}
17
+ {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
18
+ {%- for tool in tools %}
19
+ {{- "\n" }}
20
+ {{- tool | tojson }}
21
+ {%- endfor %}
22
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
23
+ {%- else %}
24
+ {%- if messages[0].role == 'system' %}
25
+ {{- '<|im_start|>system\n' }}
26
+ {%- if messages[0].content is string %}
27
+ {{- messages[0].content }}
28
+ {%- else %}
29
+ {%- for content in messages[0].content %}
30
+ {%- if content.type == 'audio' %}
31
+ {{- ("<|sosp|>" + (content.meta | tojson) + "<|eosp|>") }}
32
+ {%- elif content.type == 'text' %}
33
+ {{- content.text }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- endif %}
37
+ {{- '\n<|im_end|>\n' }}
38
+ {%- endif %}
39
+ {%- endif %}
40
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1, assistant_is_last=false) %}
41
+ {%- for message in messages[::-1] %}
42
+ {%- set index = (messages|length - 1) - loop.index0 %}
43
+ {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
44
+ {%- set ns.multi_step_tool = false %}
45
+ {%- set ns.last_query_index = index %}
46
+ {%- endif %}
47
+ {%- endfor %}
48
+ {%- for message in messages %}
49
+ {%- if message.content is string %}
50
+ {%- set content = message.content %}
51
+ {%- else %}
52
+ {%- set content = namespace(text="") %}
53
+ {%- for mcontent in message.content %}
54
+ {%- if mcontent.type == 'audio' %}
55
+ {%- set content.text = content.text~("<|sosp|>" + (mcontent.meta | tojson) + "<|eosp|>") %}
56
+ {%- elif mcontent.type == 'text' %}
57
+ {%- set content.text = content.text~mcontent.text %}
58
+ {%- endif %}
59
+ {%- endfor %}
60
+ {%- set content = content.text %}
61
+ {%- endif %}
62
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
63
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
64
+ {%- elif message.role == "assistant" %}
65
+ {%- set reasoning_content = "" %}
66
+ {%- if message.reasoning_content is string %}
67
+ {%- set reasoning_content = message.reasoning_content %}
68
+ {%- else %}
69
+ {%- if '</think>' in content %}
70
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
71
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
72
+ {%- endif %}
73
+ {%- endif %}
74
+ {%- if loop.index0 > ns.last_query_index %}
75
+ {%- if loop.last or (not loop.last and reasoning_content) %}
76
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip("\n") + '\n</think>\n\n' + content.lstrip('\n') }}
77
+ {%- else %}
78
+ {{- '<|im_start|>' + message.role + '\n' + content }}
79
+ {%- endif %}
80
+ {%- else %}
81
+ {{- '<|im_start|>' + message.role + '\n' + content }}
82
+ {%- endif %}
83
+ {%- if message.tool_calls %}
84
+ {%- for tool_call in message.tool_calls %}
85
+ {%- if (loop.first and content) or (not loop.first) %}{{- '\n' }}{%- endif %}
86
+ {%- if tool_call.function %}
87
+ {%- set tool_call = tool_call.function %}
88
+ {%- endif %}
89
+ {{- '<tool_call>\n{"name": "' }}
90
+ {{- tool_call.name }}
91
+ {{- '", "arguments": ' }}
92
+ {%- if tool_call.arguments is string %}
93
+ {{- tool_call.arguments }}
94
+ {%- else %}
95
+ {{- tool_call.arguments | tojson }}
96
+ {%- endif %}
97
+ {{- '}\n</tool_call>' }}
98
+ {%- endfor %}
99
+ {%- endif %}
100
+ {%- if loop.last %}
101
+ {%- set ns.assistant_is_last = true %}
102
+ {%- else %}
103
+ {{- '<|im_end|>\n' }}
104
+ {%- endif %}
105
+ {%- elif message.role == "tool" %}
106
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}{{- '<|im_start|>user' }}{%- endif %}
107
+ {{- '\n<tool_response>\n' }}
108
+ {{- content }}
109
+ {{- '\n</tool_response>' }}
110
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}{{- '<|im_end|>\n' }}{%- endif %}
111
+ {%- endif %}
112
+ {%- endfor %}
113
+ {%- if add_generation_prompt and not ns.assistant_is_last %}
114
+ {{- '<|im_start|>assistant\n' }}
115
+ {%- if audio_output %}
116
+ {{- '<|sostm|>'}}
117
+ {%- elif not enable_thinking %}
118
+ {{- '<think>\n\n</think>\n' }}
119
+ {%- endif %}
120
+ {%- endif %}
audio_tokenizer/config.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_audio_seconds": 300,
3
+ "stride_size": 2,
4
+ "avg_pooler": 2,
5
+ "d_model": 1024,
6
+ "scale_embedding": false,
7
+ "kernel_size": 3,
8
+ "activation_function": "gelu",
9
+ "encoder_layers": 24,
10
+ "encoder_skip_layer_id": 3,
11
+ "encoder_attention_heads": 16,
12
+ "encoder_ffn_dim": 4096,
13
+ "encoder_causal": true,
14
+ "encoder_attn_window_size": [
15
+ 128,
16
+ 0
17
+ ],
18
+ "decoder_layers": 24,
19
+ "decoder_attention_heads": 16,
20
+ "decoder_ffn_dim": 4096,
21
+ "decoder_kernel_size": 3,
22
+ "decoder_stride_size": 2,
23
+ "decoder_causal": true,
24
+ "decoder_attn_window_size": [
25
+ 128,
26
+ 0
27
+ ],
28
+ "nfft": 960,
29
+ "n_mels": 128,
30
+ "sampling_rate": 24000,
31
+ "hop_length": 240,
32
+ "window_size": 960,
33
+ "vocoder_padding": "same",
34
+ "fmin": 0,
35
+ "fmax": null,
36
+ "num_quantizers": 20,
37
+ "codebook_size": [
38
+ 1024,
39
+ 1024,
40
+ 256,
41
+ 128,
42
+ 128,
43
+ 128,
44
+ 128,
45
+ 128,
46
+ 128,
47
+ 128,
48
+ 128,
49
+ 128,
50
+ 128,
51
+ 128,
52
+ 128,
53
+ 128,
54
+ 128,
55
+ 128,
56
+ 128,
57
+ 128
58
+ ],
59
+ "threshold_ema_dead_code": 2,
60
+ "position_embedding_type": "rope",
61
+ "rope_theta": 10000,
62
+ "rope_type": "default",
63
+ "ln_type": "LayerNorm",
64
+ "use_istft_only": true,
65
+ "hybrid_attention": true,
66
+ "hybrid_block_size": 8,
67
+ "swa_per_block": 2
68
+ }
audio_tokenizer/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_sample": true,
3
+ "temperature": 0.6,
4
+ "top_k": -1,
5
+ "top_p": 0.95,
6
+ "audio_temperature": 0.9,
7
+ "audio_top_k": -1,
8
+ "audio_top_p": 0.95
9
+ }
audio_tokenizer/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:077033345d80eef3a315e8d394e0589667e80e4cdaba9bc5a7488410c6657265
3
+ size 1872618384
audio_tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ },
181
+ "151665": {
182
+ "content": "<|mimo_audio_start|>",
183
+ "lstrip": false,
184
+ "normalized": false,
185
+ "rstrip": false,
186
+ "single_word": false,
187
+ "special": true
188
+ },
189
+ "151666": {
190
+ "content": "<|mimo_audio_end|>",
191
+ "lstrip": false,
192
+ "normalized": false,
193
+ "rstrip": false,
194
+ "single_word": false,
195
+ "special": true
196
+ },
197
+ "151667": {
198
+ "content": "<think>",
199
+ "lstrip": false,
200
+ "normalized": false,
201
+ "rstrip": false,
202
+ "single_word": false,
203
+ "special": false
204
+ },
205
+ "151668": {
206
+ "content": "</think>",
207
+ "lstrip": false,
208
+ "normalized": false,
209
+ "rstrip": false,
210
+ "single_word": false,
211
+ "special": false
212
+ },
213
+ "151669": {
214
+ "content": "<|audio_pad|>",
215
+ "lstrip": false,
216
+ "normalized": false,
217
+ "rstrip": false,
218
+ "single_word": false,
219
+ "special": true
220
+ },
221
+ "151670": {
222
+ "content": "<|mimo_video_start|>",
223
+ "lstrip": false,
224
+ "normalized": false,
225
+ "rstrip": false,
226
+ "single_word": false,
227
+ "special": true
228
+ },
229
+ "151671": {
230
+ "content": "<|mimo_video_end|>",
231
+ "lstrip": false,
232
+ "normalized": false,
233
+ "rstrip": false,
234
+ "single_word": false,
235
+ "special": true
236
+ }
237
+ },
238
+ "additional_special_tokens": [
239
+ "<|im_start|>",
240
+ "<|im_end|>",
241
+ "<|object_ref_start|>",
242
+ "<|object_ref_end|>",
243
+ "<|box_start|>",
244
+ "<|box_end|>",
245
+ "<|quad_start|>",
246
+ "<|quad_end|>",
247
+ "<|vision_start|>",
248
+ "<|vision_end|>",
249
+ "<|vision_pad|>",
250
+ "<|image_pad|>",
251
+ "<|video_pad|>",
252
+ "<|audio_pad|>",
253
+ "<|mimo_audio_start|>",
254
+ "<|mimo_audio_end|>",
255
+ "<|mimo_video_start|>",
256
+ "<|mimo_video_end|>"
257
+ ],
258
+ "bos_token": null,
259
+ "clean_up_tokenization_spaces": false,
260
+ "eos_token": "<|im_end|>",
261
+ "errors": "replace",
262
+ "model_max_length": 131072,
263
+ "pad_token": "<|endoftext|>",
264
+ "split_special_tokens": false,
265
+ "tokenizer_class": "Qwen2Tokenizer",
266
+ "unk_token": null
267
+ }
chat_template.jinja ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- macro render_value(value) -%}
2
+ {%- if value is string -%}
3
+ {{- value -}}
4
+ {%- else -%}
5
+ {{- value | tojson(ensure_ascii=False) -}}
6
+ {%- endif -%}
7
+ {%- endmacro -%}
8
+
9
+ {%- macro render_content(message_content) -%}
10
+ {%- if message_content is string -%}
11
+ {{- message_content -}}
12
+ {%- elif message_content is iterable -%}
13
+ {%- for part in message_content -%}
14
+ {%- if part is not mapping -%}
15
+ {{- part -}}
16
+ {%- elif part['type'] == 'image' or 'image' in part or 'image_url' in part -%}
17
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' -}}
18
+ {%- elif part['type'] == 'audio' or part['type'] == 'input_audio' or 'audio' in part or 'audio_url' in part or 'input_audio' in part -%}
19
+ {{- '<|mimo_audio_start|><|audio_pad|><|mimo_audio_end|>' -}}
20
+ {%- elif part['type'] == 'video' or 'video' in part or 'video_url' in part -%}
21
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' -}}
22
+ {%- elif 'text' in part -%}
23
+ {{- part['text'] -}}
24
+ {%- endif -%}
25
+ {%- endfor -%}
26
+ {%- endif -%}
27
+ {%- endmacro -%}
28
+
29
+ {%- macro render_tools(tools) -%}
30
+ {{- 'You are provided with the following tools:\n\n<tools>' -}}
31
+ {%- for tool in tools -%}
32
+ {{- '\n' ~ (tool | tojson(ensure_ascii=False)) -}}
33
+ {%- endfor -%}
34
+ {{- '\n</tools>' -}}
35
+ {%- endmacro -%}
36
+
37
+ {%- macro render_tool_calls(tool_calls) -%}
38
+ {%- for tool_call in tool_calls -%}
39
+ {%- if tool_call.function is defined -%}
40
+ {%- set tool_call = tool_call.function -%}
41
+ {%- elif tool_call.custom is defined -%}
42
+ {%- set tool_call = tool_call.custom -%}
43
+ {%- endif -%}
44
+ {{- '<tool_call><function=' ~ tool_call.name ~ '>' -}}
45
+ {%- if tool_call.input is defined and tool_call.input is string -%}
46
+ {{- tool_call.input -}}
47
+ {%- elif tool_call.arguments -%}
48
+ {%- if tool_call.arguments is string -%}
49
+ {{- tool_call.arguments -}}
50
+ {%- else -%}
51
+ {%- for args_name, args_value in tool_call.arguments | items -%}
52
+ {{- '<parameter=' ~ args_name ~ '>' ~ render_value(args_value) ~ '</parameter>' -}}
53
+ {%- endfor -%}
54
+ {%- endif -%}
55
+ {%- endif -%}
56
+ {{- '</function></tool_call>' -}}
57
+ {%- endfor -%}
58
+ {%- endmacro -%}
59
+
60
+ {%- macro render_assistant_message(message) -%}
61
+ {%- set content = render_content(message.content) -%}
62
+ {%- set reasoning = message.reasoning_content if message.reasoning_content is string else '' -%}
63
+ {{- '<|im_start|>assistant\n<think>' ~ reasoning ~ '</think>' ~ content -}}
64
+ {%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 -%}
65
+ {{- render_tool_calls(message.tool_calls) -}}
66
+ {%- endif -%}
67
+ {{- '<|im_end|>' -}}
68
+ {%- endmacro -%}
69
+
70
+ {%- if tools is defined and tools is iterable and tools | length > 0 -%}
71
+ {{- '<|im_start|>system\n' ~ render_tools(tools) ~ '<|im_end|>' -}}
72
+ {%- endif -%}
73
+
74
+ {%- for message in messages -%}
75
+ {%- if message.role == 'assistant' -%}
76
+ {{- render_assistant_message(message) -}}
77
+ {%- else -%}
78
+ {%- set body = render_content(message.content) -%}
79
+ {{- '<|im_start|>' ~ message.role ~ '\n' ~ body -}}
80
+ {%- if message.tools is defined and message.tools is iterable and message.tools | length > 0 -%}
81
+ {%- if body -%}
82
+ {{- '\n\n' -}}
83
+ {%- endif -%}
84
+ {{- render_tools(message.tools) -}}
85
+ {%- endif -%}
86
+ {{- '<|im_end|>' -}}
87
+ {%- endif -%}
88
+ {%- endfor -%}
89
+
90
+ {%- if add_generation_prompt -%}
91
+ {{- '<|im_start|>assistant\n' -}}
92
+ {%- if enable_thinking is false -%}
93
+ {{- '<think></think>' -}}
94
+ {%- endif -%}
95
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_full_attention_sink_bias": false,
3
+ "add_swa_attention_sink_bias": true,
4
+ "architectures": [
5
+ "MiMoV2ForCausalLM"
6
+ ],
7
+ "attention_bias": false,
8
+ "attention_chunk_size": 128,
9
+ "attention_dropout": 0.0,
10
+ "attention_projection_layout": "fused_qkv",
11
+ "attention_value_scale": 0.612,
12
+ "audio_config": {
13
+ "add_post_norm": true,
14
+ "audio_channels": 20,
15
+ "audio_segment_size": 6000,
16
+ "group_size": 4,
17
+ "input_full_attention": true,
18
+ "input_local_attn_heads": 16,
19
+ "input_local_dim": 1024,
20
+ "input_local_head_dim": 64,
21
+ "input_local_hidden_dropout": 0.0,
22
+ "input_local_intermediate_size": 4096,
23
+ "input_local_layers": 6,
24
+ "out_hidden_size": 6144,
25
+ "partial_rotary_factor": 1.0,
26
+ "projection_layers": 2,
27
+ "rope_theta": 640000,
28
+ "speech_vocab_size": "1280",
29
+ "speech_zeroemb_idx": "1024"
30
+ },
31
+ "audio_end_token_id": 151674,
32
+ "audio_start_token_id": 151673,
33
+ "audio_token_id": 151669,
34
+ "auto_map": {
35
+ "AutoConfig": "configuration_mimo_v2.MiMoV2Config",
36
+ "AutoModel": "modeling_mimo_v2.MiMoV2Model",
37
+ "AutoModelForCausalLM": "modeling_mimo_v2.MiMoV2ForCausalLM"
38
+ },
39
+ "moe_router_dtype": "bfloat16",
40
+ "bos_token_id": null,
41
+ "dtype": "bfloat16",
42
+ "eos_token_id": 151645,
43
+ "head_dim": 192,
44
+ "hidden_act": "silu",
45
+ "hidden_size": 6144,
46
+ "hybrid_block_size": null,
47
+ "hybrid_layer_pattern": [
48
+ 0,
49
+ 1,
50
+ 1,
51
+ 1,
52
+ 1,
53
+ 1,
54
+ 1,
55
+ 0,
56
+ 1,
57
+ 1,
58
+ 1,
59
+ 1,
60
+ 1,
61
+ 1,
62
+ 1,
63
+ 0,
64
+ 1,
65
+ 1,
66
+ 1,
67
+ 1,
68
+ 1,
69
+ 1,
70
+ 1,
71
+ 0,
72
+ 1,
73
+ 1,
74
+ 1,
75
+ 1,
76
+ 1,
77
+ 1,
78
+ 1,
79
+ 0,
80
+ 1,
81
+ 1,
82
+ 1,
83
+ 1,
84
+ 1,
85
+ 1,
86
+ 1,
87
+ 0,
88
+ 1,
89
+ 1,
90
+ 1,
91
+ 1,
92
+ 1,
93
+ 1,
94
+ 1,
95
+ 0,
96
+ 1,
97
+ 1,
98
+ 1,
99
+ 1,
100
+ 1,
101
+ 1,
102
+ 1,
103
+ 0,
104
+ 1,
105
+ 1,
106
+ 1,
107
+ 1,
108
+ 1,
109
+ 1,
110
+ 0,
111
+ 1,
112
+ 1,
113
+ 1,
114
+ 1,
115
+ 1,
116
+ 1,
117
+ 0
118
+ ],
119
+ "image_token_id": 151655,
120
+ "initializer_range": 0.02,
121
+ "intermediate_size": 16384,
122
+ "layernorm_epsilon": 1e-05,
123
+ "max_position_embeddings": 1048576,
124
+ "model_type": "mimo_v2",
125
+ "moe_intermediate_size": 2048,
126
+ "moe_layer_freq": [
127
+ 0,
128
+ 1,
129
+ 1,
130
+ 1,
131
+ 1,
132
+ 1,
133
+ 1,
134
+ 1,
135
+ 1,
136
+ 1,
137
+ 1,
138
+ 1,
139
+ 1,
140
+ 1,
141
+ 1,
142
+ 1,
143
+ 1,
144
+ 1,
145
+ 1,
146
+ 1,
147
+ 1,
148
+ 1,
149
+ 1,
150
+ 1,
151
+ 1,
152
+ 1,
153
+ 1,
154
+ 1,
155
+ 1,
156
+ 1,
157
+ 1,
158
+ 1,
159
+ 1,
160
+ 1,
161
+ 1,
162
+ 1,
163
+ 1,
164
+ 1,
165
+ 1,
166
+ 1,
167
+ 1,
168
+ 1,
169
+ 1,
170
+ 1,
171
+ 1,
172
+ 1,
173
+ 1,
174
+ 1,
175
+ 1,
176
+ 1,
177
+ 1,
178
+ 1,
179
+ 1,
180
+ 1,
181
+ 1,
182
+ 1,
183
+ 1,
184
+ 1,
185
+ 1,
186
+ 1,
187
+ 1,
188
+ 1,
189
+ 1,
190
+ 1,
191
+ 1,
192
+ 1,
193
+ 1,
194
+ 1,
195
+ 1,
196
+ 1
197
+ ],
198
+ "n_group": 1,
199
+ "n_routed_experts": 384,
200
+ "n_shared_experts": null,
201
+ "norm_topk_prob": true,
202
+ "num_attention_heads": 128,
203
+ "num_experts_per_tok": 8,
204
+ "num_hidden_layers": 70,
205
+ "num_key_value_heads": 8,
206
+ "pad_token_id": 151643,
207
+ "partial_rotary_factor": 0.334,
208
+ "processor_config": {
209
+ "audio_avg_pooler": 2,
210
+ "audio_channels": 20,
211
+ "audio_end_token_id": 151674,
212
+ "audio_fmax": null,
213
+ "audio_fmin": 0,
214
+ "audio_group_size": 4,
215
+ "audio_hop_length": 240,
216
+ "audio_input_id_per_second": 25.0,
217
+ "audio_kernel_size": 3,
218
+ "audio_n_mels": 128,
219
+ "audio_nfft": 960,
220
+ "audio_sampling_rate": 24000,
221
+ "audio_segment_size": 6000,
222
+ "audio_start_token_id": 151673,
223
+ "audio_stride_size": 2,
224
+ "audio_token_id": 151669,
225
+ "audio_window_size": 960,
226
+ "audio_zeroemb_idx": [
227
+ 1024,
228
+ 1024,
229
+ 1024,
230
+ 1024,
231
+ 1024,
232
+ 1024,
233
+ 1024,
234
+ 1024,
235
+ 1024,
236
+ 1024,
237
+ 1024,
238
+ 1024,
239
+ 1024,
240
+ 1024,
241
+ 1024,
242
+ 1024,
243
+ 1024,
244
+ 1024,
245
+ 1024,
246
+ 1024
247
+ ],
248
+ "fps": 1.0,
249
+ "image_max_pixels": 8388608,
250
+ "image_min_pixels": 8192,
251
+ "image_token_id": 151655,
252
+ "max_frames": 3600,
253
+ "merge_size": 2,
254
+ "min_frames": null,
255
+ "num_frames": null,
256
+ "pad_token_id": 151643,
257
+ "patch_size": 16,
258
+ "rope_type": "rope",
259
+ "temporal_compression_ratio": 1,
260
+ "temporal_patch_size": 2,
261
+ "use_per_grid_t_timestamps": false,
262
+ "use_video_timestamps": true,
263
+ "video_audio_interleave_length": 0.0,
264
+ "video_end_token_id": 151671,
265
+ "video_max_pixels": 8388608,
266
+ "video_min_pixels": 8192,
267
+ "video_process_num_threads": 16,
268
+ "video_start_token_id": 151670,
269
+ "video_token_id": 151656,
270
+ "video_tokens_per_second": 2,
271
+ "video_total_max_pixels": 268435456,
272
+ "vision_end_token_id": 151653,
273
+ "vision_start_token_id": 151652
274
+ },
275
+ "quantization_config": {
276
+ "activation_scheme": "dynamic",
277
+ "fmt": "e4m3",
278
+ "ignored_layers": [
279
+ "model.layers.0.self_attn.o_proj",
280
+ "model.layers.1.self_attn.o_proj",
281
+ "model.layers.10.self_attn.o_proj",
282
+ "model.layers.11.self_attn.o_proj",
283
+ "model.layers.12.self_attn.o_proj",
284
+ "model.layers.13.self_attn.o_proj",
285
+ "model.layers.14.self_attn.o_proj",
286
+ "model.layers.15.self_attn.o_proj",
287
+ "model.layers.16.self_attn.o_proj",
288
+ "model.layers.17.self_attn.o_proj",
289
+ "model.layers.18.self_attn.o_proj",
290
+ "model.layers.19.self_attn.o_proj",
291
+ "model.layers.2.self_attn.o_proj",
292
+ "model.layers.20.self_attn.o_proj",
293
+ "model.layers.21.self_attn.o_proj",
294
+ "model.layers.22.self_attn.o_proj",
295
+ "model.layers.23.self_attn.o_proj",
296
+ "model.layers.24.self_attn.o_proj",
297
+ "model.layers.25.self_attn.o_proj",
298
+ "model.layers.26.self_attn.o_proj",
299
+ "model.layers.27.self_attn.o_proj",
300
+ "model.layers.28.self_attn.o_proj",
301
+ "model.layers.29.self_attn.o_proj",
302
+ "model.layers.3.self_attn.o_proj",
303
+ "model.layers.30.self_attn.o_proj",
304
+ "model.layers.31.self_attn.o_proj",
305
+ "model.layers.32.self_attn.o_proj",
306
+ "model.layers.33.self_attn.o_proj",
307
+ "model.layers.34.self_attn.o_proj",
308
+ "model.layers.35.self_attn.o_proj",
309
+ "model.layers.36.self_attn.o_proj",
310
+ "model.layers.37.self_attn.o_proj",
311
+ "model.layers.38.self_attn.o_proj",
312
+ "model.layers.39.self_attn.o_proj",
313
+ "model.layers.4.self_attn.o_proj",
314
+ "model.layers.40.self_attn.o_proj",
315
+ "model.layers.41.self_attn.o_proj",
316
+ "model.layers.42.self_attn.o_proj",
317
+ "model.layers.43.self_attn.o_proj",
318
+ "model.layers.44.self_attn.o_proj",
319
+ "model.layers.45.self_attn.o_proj",
320
+ "model.layers.46.self_attn.o_proj",
321
+ "model.layers.47.self_attn.o_proj",
322
+ "model.layers.48.self_attn.o_proj",
323
+ "model.layers.49.self_attn.o_proj",
324
+ "model.layers.5.self_attn.o_proj",
325
+ "model.layers.50.self_attn.o_proj",
326
+ "model.layers.51.self_attn.o_proj",
327
+ "model.layers.52.self_attn.o_proj",
328
+ "model.layers.53.self_attn.o_proj",
329
+ "model.layers.54.self_attn.o_proj",
330
+ "model.layers.55.self_attn.o_proj",
331
+ "model.layers.56.self_attn.o_proj",
332
+ "model.layers.57.self_attn.o_proj",
333
+ "model.layers.58.self_attn.o_proj",
334
+ "model.layers.59.self_attn.o_proj",
335
+ "model.layers.6.self_attn.o_proj",
336
+ "model.layers.60.self_attn.o_proj",
337
+ "model.layers.61.self_attn.o_proj",
338
+ "model.layers.62.self_attn.o_proj",
339
+ "model.layers.63.self_attn.o_proj",
340
+ "model.layers.64.self_attn.o_proj",
341
+ "model.layers.65.self_attn.o_proj",
342
+ "model.layers.66.self_attn.o_proj",
343
+ "model.layers.67.self_attn.o_proj",
344
+ "model.layers.68.self_attn.o_proj",
345
+ "model.layers.69.self_attn.o_proj",
346
+ "model.layers.7.self_attn.o_proj",
347
+ "model.layers.8.self_attn.o_proj",
348
+ "model.layers.9.self_attn.o_proj",
349
+ "model.decoder.self_attn.o_proj"
350
+ ],
351
+ "mxfp4_block_size": 32,
352
+ "quant_method": "fp8",
353
+ "store_dtype": "mxfp4",
354
+ "weight_block_size": [
355
+ 128,
356
+ 128
357
+ ]
358
+ },
359
+ "rope_parameters": {
360
+ "partial_rotary_factor": 0.334,
361
+ "rope_theta": 10000000,
362
+ "rope_type": "default",
363
+ "type": "default"
364
+ },
365
+ "rope_theta": 10000000,
366
+ "routed_scaling_factor": null,
367
+ "scoring_func": "sigmoid",
368
+ "sliding_window": 128,
369
+ "sliding_window_size": 128,
370
+ "swa_head_dim": 192,
371
+ "swa_num_attention_heads": 128,
372
+ "swa_num_key_value_heads": 8,
373
+ "swa_rope_theta": 10000,
374
+ "swa_v_head_dim": 128,
375
+ "tie_word_embeddings": false,
376
+ "topk_group": 1,
377
+ "topk_method": "noaux_tc",
378
+ "transformers_version": "5.3.0",
379
+ "use_cache": true,
380
+ "v_head_dim": 128,
381
+ "video_token_id": 151656,
382
+ "vision_config": {
383
+ "depth": 28,
384
+ "fullatt_block_indexes": [
385
+ 0,
386
+ 9,
387
+ 18,
388
+ 27
389
+ ],
390
+ "hidden_act": "silu",
391
+ "hidden_size": 1280,
392
+ "in_chans": 3,
393
+ "intermediate_size": 4608,
394
+ "num_heads": 32,
395
+ "num_key_value_heads": 8,
396
+ "num_query_groups": 4,
397
+ "out_hidden_size": 6144,
398
+ "patch_size": 16,
399
+ "spatial_merge_size": 2,
400
+ "spatial_patch_size": 16,
401
+ "temporal_patch_size": 2,
402
+ "tokens_per_second": 2,
403
+ "use_sink": true,
404
+ "visual_token_window_size": 64,
405
+ "vit_window_attn_types": [
406
+ -1,
407
+ 0,
408
+ 0,
409
+ 0,
410
+ 0,
411
+ 1,
412
+ 1,
413
+ 1,
414
+ 1,
415
+ -1,
416
+ 0,
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 1,
421
+ 1,
422
+ 1,
423
+ 1,
424
+ -1,
425
+ 0,
426
+ 0,
427
+ 0,
428
+ 0,
429
+ 1,
430
+ 1,
431
+ 1,
432
+ 1,
433
+ -1
434
+ ],
435
+ "window_size": 128
436
+ },
437
+ "vision_end_token_id": 151653,
438
+ "vision_model_type": "mimovl",
439
+ "vision_start_token_id": 151652,
440
+ "vocab_size": 152576
441
+ }
configuration_mimo_v2.py ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ #
3
+ # Copyright 2026 Xiaomi Corporation.
4
+ # Copyright 2026 The HuggingFace Inc. team.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ from copy import deepcopy
19
+
20
+ from transformers.configuration_utils import PretrainedConfig
21
+ from transformers.modeling_rope_utils import rope_config_validation
22
+ from transformers.utils import logging
23
+
24
+
25
+ logger = logging.get_logger(__name__)
26
+
27
+
28
+ _MIMOV2_ATTENTION_PROJECTION_LAYOUTS = {"split", "fused_qkv"}
29
+
30
+ _MIMOV2_SPLIT_TP_PLAN = {
31
+ "layers.*.self_attn.q_proj": "colwise",
32
+ "layers.*.self_attn.k_proj": "colwise",
33
+ "layers.*.self_attn.v_proj": "colwise",
34
+ "layers.*.self_attn.o_proj": "rowwise",
35
+ "layers.*.mlp.gate_proj": "colwise",
36
+ "layers.*.mlp.up_proj": "colwise",
37
+ "layers.*.mlp.down_proj": "rowwise",
38
+ }
39
+
40
+ _MIMOV2_FUSED_QKV_TP_PLAN = {
41
+ "layers.*.self_attn.qkv_proj": "colwise",
42
+ "layers.*.self_attn.o_proj": "rowwise",
43
+ "layers.*.mlp.gate_proj": "colwise",
44
+ "layers.*.mlp.up_proj": "colwise",
45
+ "layers.*.mlp.down_proj": "rowwise",
46
+ }
47
+
48
+ _MIMOV2_PP_PLAN = {
49
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
50
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
51
+ "norm": (["hidden_states"], ["hidden_states"]),
52
+ }
53
+
54
+
55
+ def _to_plain_dict(value):
56
+ if value is None:
57
+ return {}
58
+ if isinstance(value, dict):
59
+ return deepcopy(value)
60
+ if hasattr(value, "to_dict"):
61
+ return deepcopy(value.to_dict())
62
+ if hasattr(value, "__dict__"):
63
+ return deepcopy(vars(value))
64
+ raise TypeError(f"Unsupported config value type: {type(value)!r}")
65
+
66
+
67
+ class MiMoV2Config(PretrainedConfig):
68
+
69
+ model_type = "mimo_v2"
70
+ keys_to_ignore_at_inference = ["past_key_values"]
71
+
72
+ base_model_tp_plan = _MIMOV2_SPLIT_TP_PLAN
73
+ base_model_pp_plan = _MIMOV2_PP_PLAN
74
+
75
+ attribute_map = {
76
+ "num_local_experts": "n_routed_experts",
77
+ }
78
+
79
+ def __init__(
80
+ self,
81
+ vocab_size=151936,
82
+ hidden_size=4096,
83
+ intermediate_size=22016,
84
+ num_hidden_layers=32,
85
+ num_attention_heads=32,
86
+ num_key_value_heads=32,
87
+ hidden_act="silu",
88
+ max_position_embeddings=32768,
89
+ initializer_range=0.02,
90
+ layernorm_epsilon=1e-6,
91
+ use_cache=True,
92
+ tie_word_embeddings=False,
93
+ rope_theta=10000.0,
94
+ rope_scaling=None,
95
+ attention_dropout=0.0,
96
+ attention_bias=False,
97
+ attention_value_scale=None,
98
+ head_dim=None,
99
+ v_head_dim=None,
100
+ swa_num_attention_heads=None,
101
+ swa_num_key_value_heads=None,
102
+ swa_head_dim=None,
103
+ swa_v_head_dim=None,
104
+ swa_rope_theta=None,
105
+ sliding_window=None,
106
+ sliding_window_size=None,
107
+ add_full_attention_sink_bias=False,
108
+ add_swa_attention_sink_bias=False,
109
+ hybrid_block_size=None,
110
+ hybrid_layer_pattern=None,
111
+ partial_rotary_factor=1.0,
112
+ n_routed_experts=None,
113
+ moe_intermediate_size=None,
114
+ num_experts_per_tok=None,
115
+ routed_scaling_factor=None,
116
+ scoring_func="sigmoid",
117
+ topk_method="noaux_tc",
118
+ n_group=None,
119
+ topk_group=None,
120
+ norm_topk_prob=True,
121
+ moe_layer_freq=None,
122
+ attention_projection_layout="split",
123
+ vision_config=None,
124
+ audio_config=None,
125
+ processor_config=None,
126
+ image_token_id=None,
127
+ video_token_id=None,
128
+ vision_start_token_id=None,
129
+ vision_end_token_id=None,
130
+ vision_model_type=None,
131
+ **kwargs,
132
+ ):
133
+ rope_parameters = kwargs.pop("rope_parameters", None)
134
+ if rope_scaling is None and rope_parameters is not None:
135
+ rope_scaling = rope_parameters
136
+
137
+ if attention_projection_layout is None:
138
+ attention_projection_layout = "split"
139
+ if attention_projection_layout not in _MIMOV2_ATTENTION_PROJECTION_LAYOUTS:
140
+ raise ValueError(f"Unsupported MiMoV2 attention projection layout: {attention_projection_layout}")
141
+
142
+ self.attention_projection_layout = attention_projection_layout
143
+ self.base_model_tp_plan = (
144
+ _MIMOV2_FUSED_QKV_TP_PLAN.copy()
145
+ if attention_projection_layout == "fused_qkv"
146
+ else _MIMOV2_SPLIT_TP_PLAN.copy()
147
+ )
148
+ self.base_model_pp_plan = _MIMOV2_PP_PLAN.copy()
149
+
150
+ self.vocab_size = vocab_size
151
+ self.max_position_embeddings = max_position_embeddings
152
+ self.hidden_size = hidden_size
153
+ self.intermediate_size = intermediate_size
154
+ self.num_hidden_layers = num_hidden_layers
155
+ self.num_attention_heads = num_attention_heads
156
+
157
+ if num_key_value_heads is None:
158
+ num_key_value_heads = num_attention_heads
159
+ if num_attention_heads % num_key_value_heads != 0:
160
+ raise ValueError("num_attention_heads must be divisible by num_key_value_heads")
161
+
162
+ self.num_key_value_heads = num_key_value_heads
163
+ self.hidden_act = hidden_act
164
+ self.initializer_range = initializer_range
165
+ self.layernorm_epsilon = layernorm_epsilon
166
+ self.use_cache = use_cache
167
+ self.rope_theta = rope_theta
168
+ self.rope_scaling = rope_scaling
169
+ self.attention_dropout = attention_dropout
170
+ self.attention_bias = attention_bias
171
+ self.attention_value_scale = attention_value_scale
172
+
173
+ self.head_dim = head_dim if head_dim is not None else hidden_size // num_attention_heads
174
+ self.v_head_dim = v_head_dim if v_head_dim is not None else self.head_dim
175
+ self.swa_num_attention_heads = (
176
+ swa_num_attention_heads if swa_num_attention_heads is not None else num_attention_heads
177
+ )
178
+ self.swa_num_key_value_heads = (
179
+ swa_num_key_value_heads if swa_num_key_value_heads is not None else num_key_value_heads
180
+ )
181
+ if self.swa_num_attention_heads % self.swa_num_key_value_heads != 0:
182
+ raise ValueError("swa_num_attention_heads must be divisible by swa_num_key_value_heads")
183
+ self.swa_head_dim = swa_head_dim if swa_head_dim is not None else self.head_dim
184
+ self.swa_v_head_dim = swa_v_head_dim if swa_v_head_dim is not None else self.swa_head_dim
185
+ self.swa_rope_theta = swa_rope_theta if swa_rope_theta is not None else rope_theta
186
+
187
+ if sliding_window is None:
188
+ sliding_window = sliding_window_size
189
+ self.sliding_window = sliding_window
190
+ self.sliding_window_size = sliding_window_size if sliding_window_size is not None else sliding_window
191
+ self.add_full_attention_sink_bias = add_full_attention_sink_bias
192
+ self.add_swa_attention_sink_bias = add_swa_attention_sink_bias
193
+
194
+ if hybrid_block_size is not None and hybrid_layer_pattern is None:
195
+ hybrid_layer_pattern = [0 if ((i + 1) % hybrid_block_size == 0) else 1 for i in range(num_hidden_layers)]
196
+ elif hybrid_layer_pattern is None:
197
+ hybrid_layer_pattern = [0] * num_hidden_layers
198
+ if len(hybrid_layer_pattern) != num_hidden_layers:
199
+ raise ValueError("hybrid_layer_pattern length must match num_hidden_layers")
200
+ self.hybrid_block_size = hybrid_block_size
201
+ self.hybrid_layer_pattern = hybrid_layer_pattern
202
+
203
+ self.partial_rotary_factor = partial_rotary_factor
204
+
205
+ self.n_routed_experts = n_routed_experts
206
+ self.moe_intermediate_size = moe_intermediate_size if moe_intermediate_size is not None else intermediate_size
207
+ self.num_experts_per_tok = num_experts_per_tok
208
+ self.routed_scaling_factor = routed_scaling_factor
209
+ self.scoring_func = scoring_func
210
+ self.topk_method = topk_method
211
+ self.n_group = n_group
212
+ self.topk_group = topk_group
213
+ self.norm_topk_prob = norm_topk_prob
214
+ if isinstance(moe_layer_freq, int):
215
+ moe_layer_freq = [moe_layer_freq > 0 and i % moe_layer_freq == 0 for i in range(num_hidden_layers)]
216
+ elif moe_layer_freq is None:
217
+ moe_layer_freq = [False] * num_hidden_layers
218
+ if len(moe_layer_freq) != num_hidden_layers:
219
+ raise ValueError("moe_layer_freq length must match num_hidden_layers")
220
+ self.moe_layer_freq = moe_layer_freq
221
+
222
+ self.vision_config = _to_plain_dict(vision_config)
223
+ self.audio_config = _to_plain_dict(audio_config)
224
+ self.processor_config = _to_plain_dict(processor_config)
225
+ self.image_token_id = image_token_id
226
+ self.video_token_id = video_token_id
227
+ self.vision_start_token_id = vision_start_token_id
228
+ self.vision_end_token_id = vision_end_token_id
229
+ self.vision_model_type = vision_model_type
230
+ self.audio_token_id = self.processor_config.get("audio_token_id", None) if self.processor_config else None
231
+ self.audio_start_token_id = (
232
+ self.processor_config.get("audio_start_token_id", None) if self.processor_config else None
233
+ )
234
+ self.audio_end_token_id = (
235
+ self.processor_config.get("audio_end_token_id", None) if self.processor_config else None
236
+ )
237
+
238
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
239
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
240
+ rope_config_validation(self)
241
+
242
+ super().__init__(
243
+ tie_word_embeddings=tie_word_embeddings,
244
+ **kwargs,
245
+ )
246
+
247
+ __all__ = ["MiMoV2Config"]
dflash/config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "DFlashDraftModel"
4
+ ],
5
+ "model_type": "qwen3",
6
+ "auto_map": {
7
+ "AutoModel": "dflash.DFlashDraftModel"
8
+ },
9
+ "hidden_size": 6144,
10
+ "intermediate_size": 16384,
11
+ "num_hidden_layers": 5,
12
+ "num_attention_heads": 128,
13
+ "num_key_value_heads": 8,
14
+ "head_dim": 128,
15
+ "v_head_dim": 128,
16
+ "partial_rotary_factor": 0.5,
17
+ "block_size": 8,
18
+ "dflash_config": {
19
+ "target_layer_ids": [
20
+ 0,
21
+ 15,
22
+ 31,
23
+ 47,
24
+ 69
25
+ ],
26
+ "mask_token_id": 151675,
27
+ "num_anchors": 4096,
28
+ "block_size": 8,
29
+ "loss_decay_gamma": 7.0,
30
+ "attention_value_scale": 0.612,
31
+ "attention_sink_bias": true
32
+ },
33
+ "layer_types": [
34
+ "sliding_attention",
35
+ "sliding_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention"
39
+ ],
40
+ "sliding_window": 1024,
41
+ "use_sliding_window": true,
42
+ "is_causal": false,
43
+ "num_target_layers": 70,
44
+ "target_hidden_size": 6144,
45
+ "vocab_size": 152576,
46
+ "max_position_embeddings": 1048576,
47
+ "rope_theta": 10000.0,
48
+ "rms_norm_eps": 1e-05,
49
+ "torch_dtype": "bfloat16",
50
+ "hidden_act": "silu",
51
+ "attention_bias": false,
52
+ "attention_dropout": 0.0,
53
+ "add_swa_attention_sink_bias": true,
54
+ "tie_word_embeddings": false,
55
+ "use_cache": true
56
+ }
dflash/dflash.py ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Callable, Optional
2
+
3
+ import torch
4
+ from torch import nn
5
+ from transformers import DynamicCache
6
+ from transformers.cache_utils import Cache
7
+ from transformers.modeling_outputs import CausalLMOutputWithPast
8
+ from transformers.models.qwen3.modeling_qwen3 import (
9
+ ALL_ATTENTION_FUNCTIONS,
10
+ FlashAttentionKwargs,
11
+ GradientCheckpointingLayer,
12
+ Qwen3Config,
13
+ Qwen3MLP,
14
+ Qwen3PreTrainedModel,
15
+ Qwen3RMSNorm,
16
+ Qwen3RotaryEmbedding,
17
+ eager_attention_forward,
18
+ rotate_half,
19
+ )
20
+ from typing_extensions import Tuple, Unpack
21
+
22
+
23
+ def sample(logits: torch.Tensor, temperature: float = 0.0) -> torch.Tensor:
24
+ if temperature < 1e-5:
25
+ return torch.argmax(logits, dim=-1)
26
+ bsz, seq_len, vocab_size = logits.shape
27
+ logits = logits.view(-1, vocab_size)
28
+ logits = logits / temperature
29
+ probs = torch.softmax(logits, dim=-1)
30
+ return torch.multinomial(probs, num_samples=1).view(bsz, seq_len)
31
+
32
+
33
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
34
+ cos = cos.unsqueeze(unsqueeze_dim)
35
+ sin = sin.unsqueeze(unsqueeze_dim)
36
+ q_len = q.size(-2)
37
+ q_embed = (q * cos[..., -q_len:, :]) + (rotate_half(q) * sin[..., -q_len:, :])
38
+ k_embed = (k * cos) + (rotate_half(k) * sin)
39
+ return q_embed, k_embed
40
+
41
+
42
+ class Qwen3DFlashAttention(nn.Module):
43
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
44
+
45
+ def __init__(self, config: Qwen3Config, layer_idx: int):
46
+ super().__init__()
47
+ self.config = config
48
+ self.layer_idx = layer_idx
49
+ self.head_dim = getattr(
50
+ config, "head_dim", config.hidden_size // config.num_attention_heads
51
+ )
52
+ self.num_key_value_groups = (
53
+ config.num_attention_heads // config.num_key_value_heads
54
+ )
55
+ self.scaling = self.head_dim**-0.5
56
+ self.attention_dropout = config.attention_dropout
57
+ self.is_causal = False
58
+ self.q_proj = nn.Linear(
59
+ config.hidden_size,
60
+ config.num_attention_heads * self.head_dim,
61
+ bias=config.attention_bias,
62
+ )
63
+ self.k_proj = nn.Linear(
64
+ config.hidden_size,
65
+ config.num_key_value_heads * self.head_dim,
66
+ bias=config.attention_bias,
67
+ )
68
+ self.v_proj = nn.Linear(
69
+ config.hidden_size,
70
+ config.num_key_value_heads * self.head_dim,
71
+ bias=config.attention_bias,
72
+ )
73
+ self.o_proj = nn.Linear(
74
+ config.num_attention_heads * self.head_dim,
75
+ config.hidden_size,
76
+ bias=config.attention_bias,
77
+ )
78
+ self.q_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)
79
+ self.k_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)
80
+ self.sliding_window = (
81
+ config.sliding_window
82
+ if config.layer_types[layer_idx] == "sliding_attention"
83
+ else None
84
+ )
85
+
86
+ def forward(
87
+ self,
88
+ hidden_states: torch.Tensor,
89
+ target_hidden: torch.Tensor,
90
+ position_embeddings: tuple[torch.Tensor, torch.Tensor],
91
+ attention_mask: Optional[torch.Tensor],
92
+ past_key_values: Optional[Cache] = None,
93
+ cache_position: Optional[torch.LongTensor] = None,
94
+ **kwargs: Unpack[FlashAttentionKwargs],
95
+ ) -> tuple[torch.Tensor, Optional[torch.Tensor]]:
96
+ bsz, q_len = hidden_states.shape[:-1]
97
+ ctx_len = target_hidden.shape[1]
98
+ q = self.q_proj(hidden_states)
99
+ q = q.view(bsz, q_len, -1, self.head_dim)
100
+ q = self.q_norm(q).transpose(1, 2)
101
+ k_ctx = self.k_proj(target_hidden)
102
+ k_noise = self.k_proj(hidden_states)
103
+ v_ctx = self.v_proj(target_hidden)
104
+ v_noise = self.v_proj(hidden_states)
105
+ k = torch.cat([k_ctx, k_noise], dim=1).view(
106
+ bsz, ctx_len + q_len, -1, self.head_dim
107
+ )
108
+ v = torch.cat([v_ctx, v_noise], dim=1).view(
109
+ bsz, ctx_len + q_len, -1, self.head_dim
110
+ )
111
+ k = self.k_norm(k).transpose(1, 2)
112
+ v = v.transpose(1, 2)
113
+ cos, sin = position_embeddings
114
+ q, k = apply_rotary_pos_emb(q, k, cos, sin)
115
+ if past_key_values is not None:
116
+ cache_kwargs = {"sin": sin, "cos": cos, "cache_position": cache_position}
117
+ k, v = past_key_values.update(k, v, self.layer_idx, cache_kwargs)
118
+ attn_fn: Callable = eager_attention_forward
119
+ if self.config._attn_implementation != "eager":
120
+ attn_fn = ALL_ATTENTION_FUNCTIONS[self.config._attn_implementation]
121
+ attn_output, attn_weights = attn_fn(
122
+ self,
123
+ q,
124
+ k,
125
+ v,
126
+ attention_mask,
127
+ dropout=0.0 if not self.training else self.attention_dropout,
128
+ scaling=self.scaling,
129
+ sliding_window=self.sliding_window,
130
+ **kwargs,
131
+ )
132
+ attn_output = attn_output.reshape(bsz, q_len, -1)
133
+ attn_output = self.o_proj(attn_output)
134
+ return attn_output, attn_weights
135
+
136
+
137
+ class Qwen3DFlashDecoderLayer(GradientCheckpointingLayer):
138
+ def __init__(self, config: Qwen3Config, layer_idx: int):
139
+ super().__init__()
140
+ self.hidden_size = config.hidden_size
141
+ self.self_attn = Qwen3DFlashAttention(config=config, layer_idx=layer_idx)
142
+ self.mlp = Qwen3MLP(config)
143
+ self.input_layernorm = Qwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
144
+ self.post_attention_layernorm = Qwen3RMSNorm(
145
+ config.hidden_size, eps=config.rms_norm_eps
146
+ )
147
+
148
+ def forward(
149
+ self,
150
+ target_hidden: Optional[torch.Tensor] = None,
151
+ hidden_states: Optional[torch.Tensor] = None,
152
+ attention_mask: Optional[torch.Tensor] = None,
153
+ position_ids: Optional[torch.LongTensor] = None,
154
+ past_key_value: Optional[Cache] = None,
155
+ output_attentions: Optional[bool] = False,
156
+ use_cache: Optional[bool] = False,
157
+ cache_position: Optional[torch.LongTensor] = None,
158
+ position_embeddings: Optional[
159
+ Tuple[torch.Tensor, torch.Tensor]
160
+ ] = None, # necessary, but kept here for BC
161
+ **kwargs: Unpack[FlashAttentionKwargs],
162
+ ) -> Tuple[
163
+ torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]
164
+ ]:
165
+ residual = hidden_states
166
+ hidden_states = self.input_layernorm(hidden_states)
167
+ hidden_states = self.self_attn(
168
+ hidden_states=hidden_states,
169
+ target_hidden=target_hidden,
170
+ attention_mask=attention_mask,
171
+ position_ids=position_ids,
172
+ past_key_values=past_key_value,
173
+ output_attentions=output_attentions,
174
+ use_cache=use_cache,
175
+ cache_position=cache_position,
176
+ position_embeddings=position_embeddings,
177
+ **kwargs,
178
+ )[0]
179
+ hidden_states = residual + hidden_states
180
+ residual = hidden_states
181
+ hidden_states = self.post_attention_layernorm(hidden_states)
182
+ hidden_states = self.mlp(hidden_states)
183
+ hidden_states = residual + hidden_states
184
+ return hidden_states
185
+
186
+
187
+ def build_target_layer_ids(num_target_layers: int, num_draft_layers: int):
188
+ if num_draft_layers == 1:
189
+ return [(num_target_layers // 2)]
190
+ start = 1
191
+ end = num_target_layers - 3
192
+ span = end - start
193
+ target_layer_ids = [
194
+ int(round(start + (i * span) / (num_draft_layers - 1)))
195
+ for i in range(num_draft_layers)
196
+ ]
197
+ return target_layer_ids
198
+
199
+
200
+ def extract_context_feature(
201
+ hidden_states: list[torch.Tensor],
202
+ layer_ids: Optional[list[int]],
203
+ ) -> torch.Tensor:
204
+ offset = 1
205
+ selected_states = []
206
+ for layer_id in layer_ids:
207
+ selected_states.append(hidden_states[layer_id + offset])
208
+ target_hidden = torch.cat(selected_states, dim=-1)
209
+ return target_hidden
210
+
211
+
212
+ class DFlashDraftModel(Qwen3PreTrainedModel):
213
+ config_class = Qwen3Config
214
+ _no_split_modules = ["Qwen3DFlashDecoderLayer"]
215
+
216
+ def __init__(self, config) -> None:
217
+ super().__init__(config)
218
+ self.config = config
219
+ self.layers = nn.ModuleList(
220
+ [
221
+ Qwen3DFlashDecoderLayer(config, layer_idx)
222
+ for layer_idx in range(config.num_hidden_layers)
223
+ ]
224
+ )
225
+ dflash_config = getattr(config, "dflash_config", {}) or {}
226
+ self.target_layer_ids = dflash_config.get(
227
+ "target_layer_ids",
228
+ build_target_layer_ids(config.num_target_layers, config.num_hidden_layers),
229
+ )
230
+ self.norm = Qwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
231
+ self.rotary_emb = Qwen3RotaryEmbedding(config)
232
+ self.fc = nn.Linear(
233
+ len(self.target_layer_ids) * config.hidden_size,
234
+ config.hidden_size,
235
+ bias=False,
236
+ )
237
+ self.hidden_norm = Qwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
238
+ self.block_size = config.block_size
239
+ self.mask_token_id = dflash_config.get("mask_token_id", None)
240
+ self.post_init()
241
+
242
+ def forward(
243
+ self,
244
+ position_ids: torch.LongTensor,
245
+ attention_mask: Optional[torch.Tensor] = None,
246
+ noise_embedding: Optional[torch.Tensor] = None,
247
+ target_hidden: Optional[torch.Tensor] = None,
248
+ past_key_values: Optional[Cache] = None,
249
+ use_cache: bool = False,
250
+ **kwargs,
251
+ ) -> CausalLMOutputWithPast:
252
+ hidden_states = noise_embedding
253
+ target_hidden = self.hidden_norm(self.fc(target_hidden))
254
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
255
+ for layer in self.layers:
256
+ hidden_states = layer(
257
+ hidden_states=hidden_states,
258
+ target_hidden=target_hidden,
259
+ attention_mask=attention_mask,
260
+ position_ids=position_ids,
261
+ past_key_value=past_key_values,
262
+ use_cache=use_cache,
263
+ position_embeddings=position_embeddings,
264
+ **kwargs,
265
+ )
266
+ return self.norm(hidden_states)
267
+
268
+ @torch.inference_mode()
269
+ def spec_generate(
270
+ self,
271
+ target: nn.Module,
272
+ input_ids: torch.LongTensor,
273
+ max_new_tokens: int,
274
+ stop_token_ids: list[int],
275
+ temperature: float,
276
+ ):
277
+ self.eval()
278
+ num_input_tokens = input_ids.shape[1]
279
+ max_length = num_input_tokens + max_new_tokens
280
+
281
+ block_size = self.block_size
282
+ output_ids = torch.full(
283
+ (1, max_length + block_size),
284
+ self.mask_token_id,
285
+ dtype=torch.long,
286
+ device=target.device,
287
+ )
288
+ position_ids = torch.arange(
289
+ output_ids.shape[1], device=target.device
290
+ ).unsqueeze(0)
291
+
292
+ past_key_values_target = DynamicCache()
293
+ past_key_values_draft = DynamicCache()
294
+
295
+ # Prefill stage
296
+ output = target(
297
+ input_ids,
298
+ position_ids=position_ids[:, :num_input_tokens],
299
+ past_key_values=past_key_values_target,
300
+ use_cache=True,
301
+ logits_to_keep=1,
302
+ output_hidden_states=True,
303
+ )
304
+
305
+ output_ids[:, :num_input_tokens] = input_ids
306
+ output_ids[:, num_input_tokens : num_input_tokens + 1] = sample(
307
+ output.logits, temperature
308
+ )
309
+ target_hidden = extract_context_feature(
310
+ output.hidden_states, self.target_layer_ids
311
+ )
312
+
313
+ # Decode stage
314
+ acceptance_lengths = []
315
+ start = input_ids.shape[1]
316
+ while start < max_length:
317
+ block_output_ids = output_ids[:, start : start + block_size].clone()
318
+ block_position_ids = position_ids[:, start : start + block_size]
319
+ noise_embedding = target.model.embed_tokens(block_output_ids)
320
+ draft_logits = target.lm_head(
321
+ self(
322
+ target_hidden=target_hidden,
323
+ noise_embedding=noise_embedding,
324
+ position_ids=position_ids[
325
+ :, past_key_values_draft.get_seq_length() : start + block_size
326
+ ],
327
+ past_key_values=past_key_values_draft,
328
+ use_cache=True,
329
+ is_causal=False,
330
+ )[:, -block_size + 1 :, :]
331
+ )
332
+ past_key_values_draft.crop(start)
333
+ block_output_ids[:, 1:] = sample(draft_logits)
334
+
335
+ output = target(
336
+ block_output_ids,
337
+ position_ids=block_position_ids,
338
+ past_key_values=past_key_values_target,
339
+ use_cache=True,
340
+ output_hidden_states=True,
341
+ )
342
+
343
+ posterior = sample(output.logits, temperature)
344
+ acceptance_length = (
345
+ (block_output_ids[:, 1:] == posterior[:, :-1])
346
+ .cumprod(dim=1)
347
+ .sum(dim=1)[0]
348
+ .item()
349
+ )
350
+ output_ids[:, start : start + acceptance_length + 1] = block_output_ids[
351
+ :, : acceptance_length + 1
352
+ ]
353
+ output_ids[:, start + acceptance_length + 1] = posterior[
354
+ :, acceptance_length
355
+ ]
356
+ start += acceptance_length + 1
357
+ past_key_values_target.crop(start)
358
+ target_hidden = extract_context_feature(
359
+ output.hidden_states, self.target_layer_ids
360
+ )[:, : acceptance_length + 1, :]
361
+ acceptance_lengths.append(acceptance_length + 1)
362
+ if stop_token_ids is not None and any(
363
+ stop_token_id in output_ids[:, num_input_tokens:]
364
+ for stop_token_id in stop_token_ids
365
+ ):
366
+ break
367
+ output_ids = output_ids[:, :max_length]
368
+ output_ids = output_ids[:, output_ids[0] != self.mask_token_id]
369
+ if stop_token_ids is not None:
370
+ stop_token_ids = torch.tensor(stop_token_ids, device=output_ids.device)
371
+ stop_token_indices = torch.isin(
372
+ output_ids[0][num_input_tokens:], stop_token_ids
373
+ ).nonzero(as_tuple=True)[0]
374
+ if stop_token_indices.numel() > 0:
375
+ output_ids = output_ids[
376
+ :, : num_input_tokens + stop_token_indices[0] + 1
377
+ ]
378
+
379
+ return output_ids
dflash/dflash_draft_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39208e3dd45285248c764b4af57dd240c19159d0afba798c217fde50e617a067
3
+ size 5536639384
dflash/mask_embedding.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:436ad08853876f01b644128461a45925e21f3e3e93f34fe6c03f48cb071023e3
3
+ size 13978
dflash/model.safetensors.index.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 5536632576
4
+ },
5
+ "weight_map": {
6
+ "fc.weight": "dflash_draft_model.safetensors",
7
+ "hidden_norm.weight": "dflash_draft_model.safetensors",
8
+ "norm.weight": "dflash_draft_model.safetensors",
9
+ "layers.0.input_layernorm.weight": "dflash_draft_model.safetensors",
10
+ "layers.0.post_attention_layernorm.weight": "dflash_draft_model.safetensors",
11
+ "layers.0.self_attn.q_norm.weight": "dflash_draft_model.safetensors",
12
+ "layers.0.self_attn.k_norm.weight": "dflash_draft_model.safetensors",
13
+ "layers.0.self_attn.q_proj.weight": "dflash_draft_model.safetensors",
14
+ "layers.0.self_attn.k_proj.weight": "dflash_draft_model.safetensors",
15
+ "layers.0.self_attn.v_proj.weight": "dflash_draft_model.safetensors",
16
+ "layers.0.self_attn.o_proj.weight": "dflash_draft_model.safetensors",
17
+ "layers.0.mlp.gate_proj.weight": "dflash_draft_model.safetensors",
18
+ "layers.0.mlp.up_proj.weight": "dflash_draft_model.safetensors",
19
+ "layers.0.mlp.down_proj.weight": "dflash_draft_model.safetensors",
20
+ "layers.0.self_attn.attention_sink_bias": "dflash_draft_model.safetensors",
21
+ "layers.1.input_layernorm.weight": "dflash_draft_model.safetensors",
22
+ "layers.1.post_attention_layernorm.weight": "dflash_draft_model.safetensors",
23
+ "layers.1.self_attn.q_norm.weight": "dflash_draft_model.safetensors",
24
+ "layers.1.self_attn.k_norm.weight": "dflash_draft_model.safetensors",
25
+ "layers.1.self_attn.q_proj.weight": "dflash_draft_model.safetensors",
26
+ "layers.1.self_attn.k_proj.weight": "dflash_draft_model.safetensors",
27
+ "layers.1.self_attn.v_proj.weight": "dflash_draft_model.safetensors",
28
+ "layers.1.self_attn.o_proj.weight": "dflash_draft_model.safetensors",
29
+ "layers.1.mlp.gate_proj.weight": "dflash_draft_model.safetensors",
30
+ "layers.1.mlp.up_proj.weight": "dflash_draft_model.safetensors",
31
+ "layers.1.mlp.down_proj.weight": "dflash_draft_model.safetensors",
32
+ "layers.1.self_attn.attention_sink_bias": "dflash_draft_model.safetensors",
33
+ "layers.2.input_layernorm.weight": "dflash_draft_model.safetensors",
34
+ "layers.2.post_attention_layernorm.weight": "dflash_draft_model.safetensors",
35
+ "layers.2.self_attn.q_norm.weight": "dflash_draft_model.safetensors",
36
+ "layers.2.self_attn.k_norm.weight": "dflash_draft_model.safetensors",
37
+ "layers.2.self_attn.q_proj.weight": "dflash_draft_model.safetensors",
38
+ "layers.2.self_attn.k_proj.weight": "dflash_draft_model.safetensors",
39
+ "layers.2.self_attn.v_proj.weight": "dflash_draft_model.safetensors",
40
+ "layers.2.self_attn.o_proj.weight": "dflash_draft_model.safetensors",
41
+ "layers.2.mlp.gate_proj.weight": "dflash_draft_model.safetensors",
42
+ "layers.2.mlp.up_proj.weight": "dflash_draft_model.safetensors",
43
+ "layers.2.mlp.down_proj.weight": "dflash_draft_model.safetensors",
44
+ "layers.2.self_attn.attention_sink_bias": "dflash_draft_model.safetensors",
45
+ "layers.3.input_layernorm.weight": "dflash_draft_model.safetensors",
46
+ "layers.3.post_attention_layernorm.weight": "dflash_draft_model.safetensors",
47
+ "layers.3.self_attn.q_norm.weight": "dflash_draft_model.safetensors",
48
+ "layers.3.self_attn.k_norm.weight": "dflash_draft_model.safetensors",
49
+ "layers.3.self_attn.q_proj.weight": "dflash_draft_model.safetensors",
50
+ "layers.3.self_attn.k_proj.weight": "dflash_draft_model.safetensors",
51
+ "layers.3.self_attn.v_proj.weight": "dflash_draft_model.safetensors",
52
+ "layers.3.self_attn.o_proj.weight": "dflash_draft_model.safetensors",
53
+ "layers.3.mlp.gate_proj.weight": "dflash_draft_model.safetensors",
54
+ "layers.3.mlp.up_proj.weight": "dflash_draft_model.safetensors",
55
+ "layers.3.mlp.down_proj.weight": "dflash_draft_model.safetensors",
56
+ "layers.3.self_attn.attention_sink_bias": "dflash_draft_model.safetensors",
57
+ "layers.4.input_layernorm.weight": "dflash_draft_model.safetensors",
58
+ "layers.4.post_attention_layernorm.weight": "dflash_draft_model.safetensors",
59
+ "layers.4.self_attn.q_norm.weight": "dflash_draft_model.safetensors",
60
+ "layers.4.self_attn.k_norm.weight": "dflash_draft_model.safetensors",
61
+ "layers.4.self_attn.q_proj.weight": "dflash_draft_model.safetensors",
62
+ "layers.4.self_attn.k_proj.weight": "dflash_draft_model.safetensors",
63
+ "layers.4.self_attn.v_proj.weight": "dflash_draft_model.safetensors",
64
+ "layers.4.self_attn.o_proj.weight": "dflash_draft_model.safetensors",
65
+ "layers.4.mlp.gate_proj.weight": "dflash_draft_model.safetensors",
66
+ "layers.4.mlp.up_proj.weight": "dflash_draft_model.safetensors",
67
+ "layers.4.mlp.down_proj.weight": "dflash_draft_model.safetensors",
68
+ "layers.4.self_attn.attention_sink_bias": "dflash_draft_model.safetensors"
69
+ }
70
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": false,
4
+ "eos_token_id": [151643, 151645, 151672],
5
+ "temperature": 1.0,
6
+ "top_p": 0.95,
7
+ "max_new_tokens": 2048,
8
+ "transformers_version": "4.37.0"
9
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e855ee9dd7ae748a6258b0725ca217d382a93561d17fc3dbf84d83a152deb54b
3
+ size 15201042
model_mtp.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eba334c8613d9eb5913ae9d896fb8b3ccc4aeae97a3610589fb985b51a60d08a
3
+ size 2463641280
model_pp0_ep0_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:457fbf20a75a776898037cbc0d9e7ca4ba09ff3dc9bd9f75d3fd87c5bbcc9126
3
+ size 34362605520
model_pp0_ep0_shard1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f5be09d843b60c3559a64c032bd6bfbb51a65b3a87fe63ceeba85f24698d9de
3
+ size 2001997472
model_pp0_ep100_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:47403b29d8849a72afc0591846545832f76128d8aae905a097805dc98cb3ff0a
3
+ size 4151337816
model_pp0_ep101_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45fb8bbbc1f92186b9c70b588800675c8cb75269f8c7242143a7697aa8c6fee8
3
+ size 4151337816
model_pp0_ep102_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7db63a2f918ab314b36aa9e66d7bf05c395256cdbaf75691a30a88c88224c6ea
3
+ size 4151337816
model_pp0_ep103_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:812c35bd8eda9b6aa97bed31b0cd5cf3bafcd1088fb83712a4733a206f9e929a
3
+ size 4151337816
model_pp0_ep104_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afb2cdf18078316b9217fed2c8e6b0b7360a31556c0af5e1f8ae0d0a4258adb6
3
+ size 4151337816
model_pp0_ep105_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7cfe0e99ba9daf51008f2c2e83774240563d912bdb60e6662874728b738851ca
3
+ size 4151337816
model_pp0_ep106_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2476b54862aea74bba4979a1530cf6e604f4cfa52312fe2a02439837c5bfb9d5
3
+ size 4151337816
model_pp0_ep107_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:998e0c383b3e6d51b5ed63e807c202789f06f5e9731210266e24d2d119aa00d2
3
+ size 4151337816
model_pp0_ep108_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d24c1b87af2c649cf772bd5974d4ee81060b61e78a7943a64b1babcf377e690
3
+ size 4151337816
model_pp0_ep109_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a46b4a647d91de2dc5c06101eae335d395605a5de42908516e5fb0c7534b00f
3
+ size 4151337816
model_pp0_ep10_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24d80d06ac4323fd586edae385b7858d81ab65ca5d9775823ed210d40223efa4
3
+ size 4151336576
model_pp0_ep110_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22bde5b3769cc9f909f8970dce6f8a222340e699e93a3f2fdd61e3e3e1adb41b
3
+ size 4151337816
model_pp0_ep111_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e777a871c219a06d3248db90bd3fb0b64b7b57df7e0b86a9e9329bda0871acb5
3
+ size 4151337816
model_pp0_ep112_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86ec11f215f91856b8c89b79ad548cafd9c2025eea834cbed2597f2e0d62e5b6
3
+ size 4151337816
model_pp0_ep113_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:79d80c98115df86c6cc209edbbc339171ad80dbae7690b0a46164985513cc69d
3
+ size 4151337816
model_pp0_ep114_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ae9e102623b08289f64f8adce3a543eea60dd313f7d87aaf0f48cacdc26b279
3
+ size 4151337816
model_pp0_ep115_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:062678f2e6fe56e3272ba56c3e2e7504d46330e70af98af483763aa96033d6b6
3
+ size 4151337816
model_pp0_ep116_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a2903ea03b84dc07623df76b386b7dbaf8504da8f6635b08946a6903ced7292
3
+ size 4151337816
model_pp0_ep117_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87a2dfe3c8ec663f2136bac6666a85f945b240fd1b42bf9d45eb2b2dede30db1
3
+ size 4151337816
model_pp0_ep118_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a723bfe7f43b4ee3575132afcd75cb48435388ce2475289df31d7dead4bd2d4
3
+ size 4151337816
model_pp0_ep119_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c1cbc2af036a6f0cf6093259ac48b9b53be1602df33316fa0fcb452891375d8e
3
+ size 4151337816
model_pp0_ep11_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ec6c79fa658de8fcad3e22a216ea4444386c161e2aa9079fe5d6504bf0e0a8c
3
+ size 4151336576
model_pp0_ep120_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a5927cdedb8577e7544f2dcd8d79c7d8152abf595408394b49fd8b08d3efd48
3
+ size 4151337816
model_pp0_ep121_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e131992cd440a5daf84c26a5d15c74a7b08d7ca5e7b817a563212f432f74bbb3
3
+ size 4151337816
model_pp0_ep122_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fe86280f26bf4e2cdb277eaa86c9275730c5d410cbe25690ac496187065a1b7
3
+ size 4151337816
model_pp0_ep123_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4c96ee7b894bbd38603aa21181c84fc732387e22f42650b2ad10adbad57729b
3
+ size 4151337816
model_pp0_ep124_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fb9ef76464bdfe56d42e75b3bd1f0dab99914a1bc5cba9e04cc2acea9e7d108
3
+ size 4151337816