shaikat2007 bwshen-mi commited on
Commit
9255b13
·
0 Parent(s):

Duplicate from XiaomiMiMo/MiMo-V2.6-Flash-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 +38 -0
  2. MiMo_V2_6_technical_report.pdf +3 -0
  3. README.md +229 -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 +96 -0
  11. config.json +376 -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 +0 -0
  21. model_mtp.safetensors +3 -0
  22. model_pp0_ep0_shard0.safetensors +3 -0
  23. model_pp0_ep10_shard0.safetensors +3 -0
  24. model_pp0_ep11_shard0.safetensors +3 -0
  25. model_pp0_ep12_shard0.safetensors +3 -0
  26. model_pp0_ep13_shard0.safetensors +3 -0
  27. model_pp0_ep14_shard0.safetensors +3 -0
  28. model_pp0_ep15_shard0.safetensors +3 -0
  29. model_pp0_ep16_shard0.safetensors +3 -0
  30. model_pp0_ep17_shard0.safetensors +3 -0
  31. model_pp0_ep18_shard0.safetensors +3 -0
  32. model_pp0_ep19_shard0.safetensors +3 -0
  33. model_pp0_ep1_shard0.safetensors +3 -0
  34. model_pp0_ep20_shard0.safetensors +3 -0
  35. model_pp0_ep21_shard0.safetensors +3 -0
  36. model_pp0_ep22_shard0.safetensors +3 -0
  37. model_pp0_ep23_shard0.safetensors +3 -0
  38. model_pp0_ep24_shard0.safetensors +3 -0
  39. model_pp0_ep25_shard0.safetensors +3 -0
  40. model_pp0_ep26_shard0.safetensors +3 -0
  41. model_pp0_ep27_shard0.safetensors +3 -0
  42. model_pp0_ep28_shard0.safetensors +3 -0
  43. model_pp0_ep29_shard0.safetensors +3 -0
  44. model_pp0_ep2_shard0.safetensors +3 -0
  45. model_pp0_ep30_shard0.safetensors +3 -0
  46. model_pp0_ep31_shard0.safetensors +3 -0
  47. model_pp0_ep32_shard0.safetensors +3 -0
  48. model_pp0_ep33_shard0.safetensors +3 -0
  49. model_pp0_ep34_shard0.safetensors +3 -0
  50. model_pp0_ep35_shard0.safetensors +3 -0
.gitattributes ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
38
+ 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,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-Flash-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-Flash-RL
60
+
61
+ **Scaling Reinforcement Learning Toward Self-Improvement**
62
+
63
+ <p align="center">
64
+ <a href="https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Flash-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-Flash-RL is the efficiency-balanced 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), 309B total / 15B 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-Flash-RL |
129
+ | --- | --- |
130
+ | Layers (Total / SWA / GA) | 48 / 39 / 9 |
131
+ | Hidden Size | 4096 |
132
+ | SWA Heads (Q/KV) | 64 / 8 |
133
+ | GA Heads (Q/KV) | 64 / 4 |
134
+ | Head Dimensions (QK / V) | 192 / 128 |
135
+ | Sliding Window Size | 128 |
136
+ | Routed Experts (Total / Activated) | 256 / 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-Flash-RL \
173
+ --tp 8 \
174
+ --dp 2 \
175
+ --enable-dp-attention \
176
+ --enable-dp-lm-head \
177
+ --mm-enable-dp-encoder \
178
+ --mem-fraction-static 0.65 \
179
+ --chunked-prefill-size 16384 \
180
+ --speculative-algorithm EAGLE \
181
+ --speculative-num-steps 3 \
182
+ --speculative-eagle-topk 1 \
183
+ --speculative-num-draft-tokens 4 \
184
+ --enable-multi-layer-eagle \
185
+ --reasoning-parser mimo \
186
+ --tool-call-parser mimo \
187
+ --host 0.0.0.0 \
188
+ --port 30000
189
+ ```
190
+
191
+ ### vLLM
192
+
193
+ Follow the [vLLM MiMo-V2.5 recipe](https://recipes.vllm.ai/XiaomiMiMo/MiMo-V2.5). Stable vLLM may lag; pre-built image: `docker pull vllm/vllm-openai:mimov25-cu129`.
194
+
195
+ ```bash
196
+ vllm serve XiaomiMiMo/MiMo-V2.6-Flash-RL \
197
+ --tensor-parallel-size 4 \
198
+ --trust-remote-code \
199
+ --gpu-memory-utilization 0.95 \
200
+ --max-model-len auto \
201
+ --reasoning-parser mimo \
202
+ --tool-call-parser mimo \
203
+ --enable-auto-tool-choice \
204
+ --generation-config vllm
205
+ ```
206
+
207
+ Recommended sampling: `temperature=1.0`, `top_p=0.95`.
208
+
209
+ Also available in AI Studio, MiMo Code, Xiaomi MiMo Desktop, Xiaomi MiMo Open Platform API, and OpenRouter.
210
+
211
+ ## Citation
212
+
213
+ ```bibtex
214
+ @misc{mimo2026v26flash,
215
+ title={MiMo-V2.6-Flash-RL},
216
+ author={{Xiaomi MiMo Team}},
217
+ year={2026},
218
+ howpublished={\url{https://huggingface.co/XiaomiMiMo/MiMo-V2.6-Flash-RL}},
219
+ }
220
+ ```
221
+
222
+ ## Contact
223
+
224
+ For questions or feedback, reach us at [mimo@xiaomi.com](mailto:mimo@xiaomi.com) or join our community:
225
+
226
+ - [WeChat Group](https://work.weixin.qq.com/apph5/external_room/join/group_mng?plg_id=c417f99bd9014b5dd894daa8bfe19790&)
227
+ - [Discord](https://discord.gg/WX2R2uNp)
228
+ - [Telegram](https://t.me/+3T-I0pekOVIyNDBl)
229
+ - [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,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
71
+ {%- if tools is defined and tools is iterable and tools | length > 0 -%}
72
+ {{- '<|im_start|>system\n' ~ render_tools(tools) ~ '<|im_end|>' -}}
73
+ {%- endif -%}
74
+
75
+ {%- for message in messages -%}
76
+ {%- if message.role == 'assistant' -%}
77
+ {{- render_assistant_message(message) -}}
78
+ {%- else -%}
79
+ {%- set body = render_content(message.content) -%}
80
+ {{- '<|im_start|>' ~ message.role ~ '\n' ~ body -}}
81
+ {%- if message.tools is defined and message.tools is iterable and message.tools | length > 0 -%}
82
+ {%- if body -%}
83
+ {{- '\n\n' -}}
84
+ {%- endif -%}
85
+ {{- render_tools(message.tools) -}}
86
+ {%- endif -%}
87
+ {{- '<|im_end|>' -}}
88
+ {%- endif -%}
89
+ {%- endfor -%}
90
+
91
+ {%- if add_generation_prompt -%}
92
+ {{- '<|im_start|>assistant\n' -}}
93
+ {%- if enable_thinking is false -%}
94
+ {{- '<think></think>' -}}
95
+ {%- endif -%}
96
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.707,
12
+ "moe_router_dtype": "bfloat16",
13
+ "audio_config": {
14
+ "add_post_norm": true,
15
+ "audio_channels": 20,
16
+ "audio_segment_size": 6000,
17
+ "group_size": 4,
18
+ "input_full_attention": true,
19
+ "input_local_attn_heads": 16,
20
+ "input_local_dim": 1024,
21
+ "input_local_head_dim": 64,
22
+ "input_local_hidden_dropout": 0.0,
23
+ "input_local_intermediate_size": 4096,
24
+ "input_local_layers": 6,
25
+ "out_hidden_size": 4096,
26
+ "partial_rotary_factor": 1.0,
27
+ "projection_layers": 2,
28
+ "rope_theta": 640000,
29
+ "speech_vocab_size": "1280",
30
+ "speech_zeroemb_idx": "1024"
31
+ },
32
+ "audio_end_token_id": 151674,
33
+ "audio_start_token_id": 151673,
34
+ "audio_token_id": 151669,
35
+ "auto_map": {
36
+ "AutoConfig": "configuration_mimo_v2.MiMoV2Config",
37
+ "AutoModel": "modeling_mimo_v2.MiMoV2Model",
38
+ "AutoModelForCausalLM": "modeling_mimo_v2.MiMoV2ForCausalLM"
39
+ },
40
+ "bos_token_id": null,
41
+ "dtype": "bfloat16",
42
+ "eos_token_id": 151645,
43
+ "head_dim": 192,
44
+ "hidden_act": "silu",
45
+ "hidden_size": 4096,
46
+ "hybrid_block_size": null,
47
+ "hybrid_layer_pattern": [
48
+ 0,
49
+ 1,
50
+ 1,
51
+ 1,
52
+ 1,
53
+ 0,
54
+ 1,
55
+ 1,
56
+ 1,
57
+ 1,
58
+ 1,
59
+ 0,
60
+ 1,
61
+ 1,
62
+ 1,
63
+ 1,
64
+ 1,
65
+ 0,
66
+ 1,
67
+ 1,
68
+ 1,
69
+ 1,
70
+ 1,
71
+ 0,
72
+ 1,
73
+ 1,
74
+ 1,
75
+ 1,
76
+ 1,
77
+ 0,
78
+ 1,
79
+ 1,
80
+ 1,
81
+ 1,
82
+ 1,
83
+ 0,
84
+ 1,
85
+ 1,
86
+ 1,
87
+ 1,
88
+ 1,
89
+ 0,
90
+ 1,
91
+ 1,
92
+ 1,
93
+ 1,
94
+ 1,
95
+ 0
96
+ ],
97
+ "image_token_id": 151655,
98
+ "initializer_range": 0.02,
99
+ "intermediate_size": 16384,
100
+ "layernorm_epsilon": 1e-06,
101
+ "max_position_embeddings": 1048576,
102
+ "model_type": "mimo_v2",
103
+ "moe_intermediate_size": 2048,
104
+ "moe_layer_freq": [
105
+ 0,
106
+ 1,
107
+ 1,
108
+ 1,
109
+ 1,
110
+ 1,
111
+ 1,
112
+ 1,
113
+ 1,
114
+ 1,
115
+ 1,
116
+ 1,
117
+ 1,
118
+ 1,
119
+ 1,
120
+ 1,
121
+ 1,
122
+ 1,
123
+ 1,
124
+ 1,
125
+ 1,
126
+ 1,
127
+ 1,
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
+ ],
154
+ "n_group": 1,
155
+ "n_routed_experts": 256,
156
+ "n_shared_experts": null,
157
+ "norm_topk_prob": true,
158
+ "num_attention_heads": 64,
159
+ "num_experts_per_tok": 8,
160
+ "num_hidden_layers": 48,
161
+ "num_key_value_heads": 4,
162
+ "num_nextn_predict_layers": 3,
163
+ "pad_token_id": 151643,
164
+ "partial_rotary_factor": 0.334,
165
+ "processor_config": {
166
+ "audio_avg_pooler": 2,
167
+ "audio_channels": 20,
168
+ "audio_end_token_id": 151674,
169
+ "audio_fmax": null,
170
+ "audio_fmin": 0,
171
+ "audio_group_size": 4,
172
+ "audio_hop_length": 240,
173
+ "audio_input_id_per_second": 25.0,
174
+ "audio_kernel_size": 3,
175
+ "audio_n_mels": 128,
176
+ "audio_nfft": 960,
177
+ "audio_sampling_rate": 24000,
178
+ "audio_segment_size": 6000,
179
+ "audio_start_token_id": 151673,
180
+ "audio_stride_size": 2,
181
+ "audio_token_id": 151669,
182
+ "audio_window_size": 960,
183
+ "audio_zeroemb_idx": [
184
+ 1024,
185
+ 1024,
186
+ 1024,
187
+ 1024,
188
+ 1024,
189
+ 1024,
190
+ 1024,
191
+ 1024,
192
+ 1024,
193
+ 1024,
194
+ 1024,
195
+ 1024,
196
+ 1024,
197
+ 1024,
198
+ 1024,
199
+ 1024,
200
+ 1024,
201
+ 1024,
202
+ 1024,
203
+ 1024
204
+ ],
205
+ "fps": 1.0,
206
+ "image_max_pixels": 8388608,
207
+ "image_min_pixels": 8192,
208
+ "image_token_id": 151655,
209
+ "max_frames": 3600,
210
+ "merge_size": 2,
211
+ "min_frames": null,
212
+ "num_frames": null,
213
+ "pad_token_id": 151643,
214
+ "patch_size": 16,
215
+ "rope_type": "rope",
216
+ "temporal_compression_ratio": 1,
217
+ "temporal_patch_size": 2,
218
+ "use_per_grid_t_timestamps": false,
219
+ "use_video_timestamps": true,
220
+ "video_audio_interleave_length": 0.0,
221
+ "video_end_token_id": 151671,
222
+ "video_max_pixels": 8388608,
223
+ "video_min_pixels": 8192,
224
+ "video_process_num_threads": 16,
225
+ "video_start_token_id": 151670,
226
+ "video_token_id": 151656,
227
+ "video_tokens_per_second": 2,
228
+ "video_total_max_pixels": 268435456,
229
+ "vision_end_token_id": 151653,
230
+ "vision_start_token_id": 151652
231
+ },
232
+ "quantization_config": {
233
+ "activation_scheme": "dynamic",
234
+ "fmt": "e4m3",
235
+ "ignored_layers": [
236
+ "model.layers.0.self_attn.o_proj",
237
+ "model.layers.1.self_attn.o_proj",
238
+ "model.layers.10.self_attn.o_proj",
239
+ "model.layers.11.self_attn.o_proj",
240
+ "model.layers.12.self_attn.o_proj",
241
+ "model.layers.13.self_attn.o_proj",
242
+ "model.layers.14.self_attn.o_proj",
243
+ "model.layers.15.self_attn.o_proj",
244
+ "model.layers.16.self_attn.o_proj",
245
+ "model.layers.17.self_attn.o_proj",
246
+ "model.layers.18.self_attn.o_proj",
247
+ "model.layers.19.self_attn.o_proj",
248
+ "model.layers.2.self_attn.o_proj",
249
+ "model.layers.20.self_attn.o_proj",
250
+ "model.layers.21.self_attn.o_proj",
251
+ "model.layers.22.self_attn.o_proj",
252
+ "model.layers.23.self_attn.o_proj",
253
+ "model.layers.24.self_attn.o_proj",
254
+ "model.layers.25.self_attn.o_proj",
255
+ "model.layers.26.self_attn.o_proj",
256
+ "model.layers.27.self_attn.o_proj",
257
+ "model.layers.28.self_attn.o_proj",
258
+ "model.layers.29.self_attn.o_proj",
259
+ "model.layers.3.self_attn.o_proj",
260
+ "model.layers.30.self_attn.o_proj",
261
+ "model.layers.31.self_attn.o_proj",
262
+ "model.layers.32.self_attn.o_proj",
263
+ "model.layers.33.self_attn.o_proj",
264
+ "model.layers.34.self_attn.o_proj",
265
+ "model.layers.35.self_attn.o_proj",
266
+ "model.layers.36.self_attn.o_proj",
267
+ "model.layers.37.self_attn.o_proj",
268
+ "model.layers.38.self_attn.o_proj",
269
+ "model.layers.39.self_attn.o_proj",
270
+ "model.layers.4.self_attn.o_proj",
271
+ "model.layers.40.self_attn.o_proj",
272
+ "model.layers.41.self_attn.o_proj",
273
+ "model.layers.42.self_attn.o_proj",
274
+ "model.layers.43.self_attn.o_proj",
275
+ "model.layers.44.self_attn.o_proj",
276
+ "model.layers.45.self_attn.o_proj",
277
+ "model.layers.46.self_attn.o_proj",
278
+ "model.layers.47.self_attn.o_proj",
279
+ "model.layers.5.self_attn.o_proj",
280
+ "model.layers.6.self_attn.o_proj",
281
+ "model.layers.7.self_attn.o_proj",
282
+ "model.layers.8.self_attn.o_proj",
283
+ "model.layers.9.self_attn.o_proj",
284
+ "model.decoder.self_attn.o_proj"
285
+ ],
286
+ "mxfp4_block_size": 32,
287
+ "quant_method": "fp8",
288
+ "store_dtype": "mxfp4",
289
+ "weight_block_size": [
290
+ 128,
291
+ 128
292
+ ]
293
+ },
294
+ "rope_parameters": {
295
+ "partial_rotary_factor": 0.334,
296
+ "rope_theta": 10000000.0,
297
+ "rope_type": "default",
298
+ "type": "default"
299
+ },
300
+ "rope_theta": 10000000.0,
301
+ "routed_scaling_factor": null,
302
+ "scoring_func": "sigmoid",
303
+ "sliding_window": 128,
304
+ "sliding_window_size": 128,
305
+ "swa_head_dim": 192,
306
+ "swa_num_attention_heads": 64,
307
+ "swa_num_key_value_heads": 8,
308
+ "swa_rope_theta": 10000.0,
309
+ "swa_v_head_dim": 128,
310
+ "tie_word_embeddings": false,
311
+ "topk_group": 1,
312
+ "topk_method": "noaux_tc",
313
+ "transformers_version": "5.3.0",
314
+ "use_cache": true,
315
+ "v_head_dim": 128,
316
+ "video_token_id": 151656,
317
+ "vision_config": {
318
+ "depth": 28,
319
+ "fullatt_block_indexes": [
320
+ 0,
321
+ 9,
322
+ 18,
323
+ 27
324
+ ],
325
+ "hidden_act": "silu",
326
+ "hidden_size": 1280,
327
+ "in_chans": 3,
328
+ "intermediate_size": 4608,
329
+ "num_heads": 32,
330
+ "num_key_value_heads": 8,
331
+ "num_query_groups": 4,
332
+ "out_hidden_size": 4096,
333
+ "patch_size": 16,
334
+ "spatial_merge_size": 2,
335
+ "spatial_patch_size": 16,
336
+ "temporal_patch_size": 2,
337
+ "tokens_per_second": 2,
338
+ "use_sink": true,
339
+ "visual_token_window_size": 64,
340
+ "vit_window_attn_types": [
341
+ -1,
342
+ 0,
343
+ 0,
344
+ 0,
345
+ 0,
346
+ 1,
347
+ 1,
348
+ 1,
349
+ 1,
350
+ -1,
351
+ 0,
352
+ 0,
353
+ 0,
354
+ 0,
355
+ 1,
356
+ 1,
357
+ 1,
358
+ 1,
359
+ -1,
360
+ 0,
361
+ 0,
362
+ 0,
363
+ 0,
364
+ 1,
365
+ 1,
366
+ 1,
367
+ 1,
368
+ -1
369
+ ],
370
+ "window_size": 128
371
+ },
372
+ "vision_end_token_id": 151653,
373
+ "vision_model_type": "mimovl",
374
+ "vision_start_token_id": 151652,
375
+ "vocab_size": 152576
376
+ }
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": 4096,
10
+ "intermediate_size": 16384,
11
+ "num_hidden_layers": 5,
12
+ "num_attention_heads": 64,
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
+ 11,
22
+ 23,
23
+ 35,
24
+ 47
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": 48,
44
+ "target_hidden_size": 4096,
45
+ "vocab_size": 152576,
46
+ "max_position_embeddings": 1048576,
47
+ "rope_theta": 10000.0,
48
+ "rms_norm_eps": 1e-06,
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:94d9c02c17e0b469f88699e98424825ebe13a17f07eb3b86727b5e0c8143d287
3
+ size 2936121080
dflash/mask_embedding.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b35b379fe0497ffdc0d6407f502622237d9346e0d03f457ec574be60f6c2cee0
3
+ size 9882
dflash/model.safetensors.index.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 2936114304
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
The diff for this file is too large to render. See raw diff
 
model_mtp.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8f78a78a79e4ec9e42e02ff94790d2a0183995ae278ff521416baa25ae2f38c
3
+ size 1189405960
model_pp0_ep0_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:88ff485461b925982205b2ffafd5696e4cc69b42bcbf05b00a3915cf17266120
3
+ size 13387692392
model_pp0_ep10_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da00ca1b796d2f9c44ff523a90cfccde0f1cf63c5ef37120a476f08a3d911c6f
3
+ size 2513577216
model_pp0_ep11_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e71b67866924b57684c7234b071fb0c9c8c56bc4cc7cfb225ca4589862090356
3
+ size 2513577216
model_pp0_ep12_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:415a846ced38b6a158d870dd30e6c9af270b2c4cecfdd70b804e9eff1d961c57
3
+ size 2513577216
model_pp0_ep13_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfdf506f2f41f799f6d4d0357ea55fc7e57f47c6d5478962e01988eae0c957f7
3
+ size 2513577216
model_pp0_ep14_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:035ec01fe9adcd7d8d47bc6b601193f9a0aa8b7a946992f516007b99e95865f9
3
+ size 2513577216
model_pp0_ep15_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c68e1ccf79a6a0f31588cb85e77252618d86aad58e30a9af5de324a863b4fb3e
3
+ size 2513577216
model_pp0_ep16_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff707d5aeaec2301c1b59491718967c96b7dbace4056a569b8c99b164653e3ed
3
+ size 2513577216
model_pp0_ep17_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:284187f225f7215953744c629fabd7bbf55953b7eea7d6ed508ae795f5aef093
3
+ size 2513577216
model_pp0_ep18_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5a701a582e98b80d058897d7ce01ca7883c19e005d2798ff49ab4401cd12da2
3
+ size 2513577216
model_pp0_ep19_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9f48244d5d0d96af2b0c326716a4550eb2d264280117e4e92ece5453082eaef
3
+ size 2513577216
model_pp0_ep1_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22b6affecd08eec16a4c52fb1c303f1c7533102b7e42535348afde2c2f7aab01
3
+ size 2513576088
model_pp0_ep20_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a705193ebcd176bcfd13fd1a711733a62f0f026878c315d2e927cbd1449b89f5
3
+ size 2513577216
model_pp0_ep21_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00d5447c5189557a0027591e8d99297b14739a2d20ce9a61244fc04845172de6
3
+ size 2513577216
model_pp0_ep22_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28a81aa95b2c4d1b6b1ec9448d3652b0e8483f9dfcec3adad8ca51c8c50a6999
3
+ size 2513577216
model_pp0_ep23_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b26e23a99ee8b758bcd74701c8af2186938f2561b20df2694b4b1a3682354ac
3
+ size 2513577216
model_pp0_ep24_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a7d6d132b4e7a03e18503416a30c29e7fd7d66f38ff991a4f523a37008f294c
3
+ size 2513577216
model_pp0_ep25_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4381d38a657568ef7682a1d1794f7c07124869cd9680fa858dbf0fd393f7560
3
+ size 2513578344
model_pp0_ep26_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e60972151139b905a9854d5b9947bd82c59be6f5dac01d569e09fe74303241b8
3
+ size 2513578344
model_pp0_ep27_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:667920e72309345e0ff1f689fd8e7869d715e485e3d3c5d4e17ed8c10d1fd534
3
+ size 2513578344
model_pp0_ep28_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1276d80fccbb05d0ae25b03f71b8a8d3a897d041472664dda9e86bfca32244db
3
+ size 2513578344
model_pp0_ep29_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b14eeeff5a315ede738cdf979f3e70bb3ab0909f0f2174113848b38fbe546f90
3
+ size 2513578344
model_pp0_ep2_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09e0e60b70a493666bb1212a21790cc8cee4b5f408488eb204b1877c3e9b793d
3
+ size 2513576656
model_pp0_ep30_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71a1cafd2049ea436581844805ca535ed847c653f3e8ac07282945457128b1e2
3
+ size 2513578344
model_pp0_ep31_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d63c0b26ffce16c636696b1d9bf6ec9503f8e7a544746f5658e1bd8a8777f79
3
+ size 2513578344
model_pp0_ep32_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3227c1161ea3191c9532414054e296b177e81b7ba989dd60e05131c5f9e3cb25
3
+ size 2513578344
model_pp0_ep33_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:454ea014bf041c46578a5953a762ddfcfde0449e9440ef1407d7797ac0c23bfe
3
+ size 2513578344
model_pp0_ep34_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca87893994c731b195cf58d61f3b31a6ac55140cd4e57869975f2e62d48d6aaf
3
+ size 2513578344
model_pp0_ep35_shard0.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d32d422768055b66e02846208510bf3089e57375da2e0dbf2eef9a913fd55e97
3
+ size 2513578344