Hikari07jp commited on
Commit
6ecd459
·
verified ·
1 Parent(s): c3fab39

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -1,35 +1,3 @@
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.safetensors filter=lfs diff=lfs merge=lfs -text
2
+ *.json -text
3
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
README.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - stepfun-ai/Step-3.7-Flash
5
+ - stepfun-ai/Step-3.7-Flash-NVFP4
6
+ tags:
7
+ - speculative-decoding
8
+ - mtp
9
+ - multi-token-prediction
10
+ - vllm
11
+ - nvfp4
12
+ - step3
13
+ language:
14
+ - en
15
+ - zh
16
+ - ja
17
+ library_name: vllm
18
+ pipeline_tag: text-generation
19
+ ---
20
+
21
+ # Step-3.7-Flash MTP draft (for the NVFP4 checkpoint)
22
+
23
+ A tiny **Multi-Token-Prediction (MTP / nextn) draft** for **`stepfun-ai/Step-3.7-Flash-NVFP4`**, so you can run
24
+ **speculative decoding** on the NVFP4 checkpoint in vLLM.
25
+
26
+ > **Why this exists:** the official `Step-3.7-Flash-NVFP4` checkpoint **declares**
27
+ > `num_nextn_predict_layers: 3` in its config but **ships zero MTP weights** — the
28
+ > 3 nextn layers were dropped during quantization, and the per-layer config arrays
29
+ > were truncated to 45 (so even loading them would `IndexError`). The BF16 and FP8
30
+ > releases keep the MTP weights, but **the NVFP4 one — the SM120-friendly, smallest
31
+ > one — cannot do speculative decoding out of the box.** This repo is the missing
32
+ > piece: the 3 MTP layers extracted from the BF16 release, kept in BF16 (they're
33
+ > tiny), packaged as a vLLM-loadable draft.
34
+
35
+ - **~5.9 GB**, BF16. Base = NVFP4 (mixed precision is fine; the draft is small).
36
+ - **Lossless** in the speculative sense: vLLM's rejection sampling provably matches
37
+ the target distribution; at `temperature=0` it follows the target's greedy tokens.
38
+ - Drop-in: point vLLM's `--speculative-config` at this directory.
39
+
40
+ ## Usage (vLLM, stepfun37 image / vLLM ≥ the build with `Step3p5MTP`)
41
+
42
+ The draft is auto-routed to vLLM's native `Step3p5MTP` + `Step3p5MTPProposer`
43
+ because its config is `model_type: step3p7` with `num_nextn_predict_layers > 0`.
44
+
45
+ ```bash
46
+ docker run -d --gpus all --ipc=host --shm-size=64g --network host \
47
+ -v /path/to/Step-3.7-Flash-NVFP4:/model:ro \
48
+ -v /path/to/Step-3.7-Flash-MTP-draft:/draft:ro \
49
+ vllm/vllm-openai:stepfun37 \
50
+ /model \
51
+ --served-model-name step3p7 --port 8000 \
52
+ --trust-remote-code --tensor-parallel-size 2 --enable-expert-parallel \
53
+ --quantization modelopt --kv-cache-dtype fp8 \
54
+ --max-model-len 262144 --gpu-memory-utilization 0.92 --async-scheduling \
55
+ --speculative-config '{"method":"mtp","model":"/draft","num_speculative_tokens":1}'
56
+ ```
57
+
58
+ JSON for `--speculative-config` must have **no spaces** (brace-expansion safety).
59
+ **`num_speculative_tokens: 1` (K=1) is the sweet spot** — see below.
60
+
61
+ ## Benchmarks (2× RTX PRO 6000 Blackwell, SM120, TP=2)
62
+
63
+ Measured on the NVFP4 base + this draft, K=1, vs. NVFP4 with speculation off.
64
+ `per_req` = decode tok/s a single user feels (prefill excluded). Acceptance ≈ **0.80** in production traffic.
65
+
66
+ **Single-stream decode (short context):**
67
+
68
+ | workload | base | + MTP K=1 | speedup | accept |
69
+ |---|---|---|---|---|
70
+ | free-form | 106.8 | **125.5** | +17.5% | 0.77 |
71
+ | code | 106.7 | **133.7** | +25.3% | 0.88 |
72
+ | Japanese | 107.0 | **129.3** | +20.9% | 0.80 |
73
+ | tool-call | 106.9 | **135.4** | +26.6% | 0.90 |
74
+
75
+ **Decode speedup grows with context length** (longer KV → base is more
76
+ memory-bound → bigger speculative win):
77
+
78
+ | context | C=1 | C=2 | C=4 | C=8 |
79
+ |---|---|---|---|---|
80
+ | 1K | +20% | +8% | +32% | +34% |
81
+ | 8K | +22% | +24% | +25% | **+44%** |
82
+ | 32K | +22% | +26% | +20% | +17% |
83
+ | **128K** | **+28%** | **+33%** | **+38%** | — |
84
+
85
+ Net-positive across the whole concurrency range we tested (MoE stays memory-bound
86
+ to high batch). Best `K`: **K=1** (K=2/K=3 lose to draft cost — later positions
87
+ have lower acceptance and add forward cost). NaN-free on SM120 (Gate0 5/5).
88
+
89
+ ## How it was built (reproducible)
90
+
91
+ The draft is **not retrained** — it's the original StepFun MTP layers, extracted verbatim:
92
+
93
+ 1. From `stepfun-ai/Step-3.7-Flash` (BF16), take the 52 tensors of
94
+ `model.layers.{45,46,47}.*` (the 3 nextn layers, dense-MLP, 17 tensors each)
95
+ plus `model.embed_tokens.weight`. They all live in one shard
96
+ (`model-00024.safetensors`).
97
+ 2. Keep the **original BF16 weight names** — vLLM's `Step3p5MTP` loader does its own
98
+ renaming (`.transformer.` strip, `shared_head.output→head`, `.mtp_block.` insert).
99
+ 3. `config.json` = the **BF16 original** config (NOT the NVFP4 one): its per-layer
100
+ arrays (`layer_types`, `partial_rotary_factors`, …) are length 48 and cover the
101
+ MTP layer indices 45-47. **Strip `quantization_config`** so the draft loads as BF16.
102
+
103
+ Full scripts + benchmark harness: **[GitHub repo](#)** (`build_draft.py`,
104
+ `launch_mtp.sh`, `eval_mtp.py`, `bench_matrix.py`).
105
+
106
+ ## License & attribution
107
+
108
+ Apache-2.0, inherited from the base model **`stepfun-ai/Step-3.7-Flash`**. These are
109
+ StepFun's weights, redistributed unchanged (only re-sharded/re-packaged as a draft).
110
+ All credit for the model and the MTP layers goes to StepFun.
config.json ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Step3p7ForConditionalGeneration"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_step3p7.Step3p7Config",
7
+ "AutoProcessor": "processing_step3.Step3VLProcessor",
8
+ "AutoModelForCausalLM": "modeling_step3p7.Step3p7ForConditionalGeneration"
9
+ },
10
+ "model_type": "step3p7",
11
+ "im_end_token": "<im_end>",
12
+ "im_patch_token": "<im_patch>",
13
+ "im_start_token": "<im_start>",
14
+ "image_token_len": 169,
15
+ "patch_token_len": 81,
16
+ "image_token_id": 128001,
17
+ "understand_projector_stride": 2,
18
+ "use_im_start_end": "true",
19
+ "vision_select_layer": -1,
20
+ "projector_bias": false,
21
+ "vision_config": {
22
+ "model_type": "perception_encoder",
23
+ "image_size": 728,
24
+ "patch_size": 14,
25
+ "width": 1536,
26
+ "layers": 47,
27
+ "heads": 16,
28
+ "pool_type": "none",
29
+ "output_dim": null,
30
+ "use_cls_token": false,
31
+ "ls_init_value": 0.1,
32
+ "use_ln_post": false,
33
+ "hidden_act": "quick_gelu"
34
+ },
35
+ "text_config": {
36
+ "architectures": [
37
+ "Step3p5ForCausalLM"
38
+ ],
39
+ "rope_scaling": {
40
+ "rope_type": "llama3",
41
+ "factor": 2.0,
42
+ "original_max_position_embeddings": 131072,
43
+ "low_freq_factor": 1.0,
44
+ "high_freq_factor": 32.0
45
+ },
46
+ "yarn_only_types": [
47
+ "full_attention"
48
+ ],
49
+ "model_type": "step3p5",
50
+ "hidden_size": 4096,
51
+ "intermediate_size": 11264,
52
+ "num_hidden_layers": 45,
53
+ "max_seq_len": 262144,
54
+ "max_position_embeddings": 262144,
55
+ "vocab_size": 128896,
56
+ "torch_dtype": "bfloat16",
57
+ "use_qk_norm": false,
58
+ "moe_layers_enum": "3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44",
59
+ "use_mfa": false,
60
+ "num_attention_heads": 64,
61
+ "num_attention_groups": 8,
62
+ "head_dim": 128,
63
+ "use_moe": true,
64
+ "moe_num_experts": 288,
65
+ "moe_top_k": 8,
66
+ "moe_intermediate_size": 1280,
67
+ "share_expert_dim": 1280,
68
+ "moe_layer_offset": 0,
69
+ "moe_every_n_layer": 1,
70
+ "norm_expert_weight": true,
71
+ "moe_router_activation": "sigmoid",
72
+ "moe_router_scaling_factor": 3.0,
73
+ "att_impl_type": "GQA",
74
+ "num_nextn_predict_layers": 3,
75
+ "rope_theta": [
76
+ 5000000.0,
77
+ 10000.0,
78
+ 10000.0,
79
+ 10000.0,
80
+ 5000000.0,
81
+ 10000.0,
82
+ 10000.0,
83
+ 10000.0,
84
+ 5000000.0,
85
+ 10000.0,
86
+ 10000.0,
87
+ 10000.0,
88
+ 5000000.0,
89
+ 10000.0,
90
+ 10000.0,
91
+ 10000.0,
92
+ 5000000.0,
93
+ 10000.0,
94
+ 10000.0,
95
+ 10000.0,
96
+ 5000000.0,
97
+ 10000.0,
98
+ 10000.0,
99
+ 10000.0,
100
+ 5000000.0,
101
+ 10000.0,
102
+ 10000.0,
103
+ 10000.0,
104
+ 5000000.0,
105
+ 10000.0,
106
+ 10000.0,
107
+ 10000.0,
108
+ 5000000.0,
109
+ 10000.0,
110
+ 10000.0,
111
+ 10000.0,
112
+ 5000000.0,
113
+ 10000.0,
114
+ 10000.0,
115
+ 10000.0,
116
+ 5000000.0,
117
+ 10000.0,
118
+ 10000.0,
119
+ 10000.0,
120
+ 5000000.0,
121
+ 10000.0,
122
+ 10000.0,
123
+ 10000.0
124
+ ],
125
+ "use_head_wise_attn_gate": true,
126
+ "sliding_window": 512,
127
+ "use_moe_router_bias": true,
128
+ "need_fp32_gate": true,
129
+ "sink": false,
130
+ "layer_types": [
131
+ "full_attention",
132
+ "sliding_attention",
133
+ "sliding_attention",
134
+ "sliding_attention",
135
+ "full_attention",
136
+ "sliding_attention",
137
+ "sliding_attention",
138
+ "sliding_attention",
139
+ "full_attention",
140
+ "sliding_attention",
141
+ "sliding_attention",
142
+ "sliding_attention",
143
+ "full_attention",
144
+ "sliding_attention",
145
+ "sliding_attention",
146
+ "sliding_attention",
147
+ "full_attention",
148
+ "sliding_attention",
149
+ "sliding_attention",
150
+ "sliding_attention",
151
+ "full_attention",
152
+ "sliding_attention",
153
+ "sliding_attention",
154
+ "sliding_attention",
155
+ "full_attention",
156
+ "sliding_attention",
157
+ "sliding_attention",
158
+ "sliding_attention",
159
+ "full_attention",
160
+ "sliding_attention",
161
+ "sliding_attention",
162
+ "sliding_attention",
163
+ "full_attention",
164
+ "sliding_attention",
165
+ "sliding_attention",
166
+ "sliding_attention",
167
+ "full_attention",
168
+ "sliding_attention",
169
+ "sliding_attention",
170
+ "sliding_attention",
171
+ "full_attention",
172
+ "sliding_attention",
173
+ "sliding_attention",
174
+ "sliding_attention",
175
+ "full_attention",
176
+ "sliding_attention",
177
+ "sliding_attention",
178
+ "sliding_attention"
179
+ ],
180
+ "use_rope_layers": [],
181
+ "partial_rotary_factors": [
182
+ 0.5,
183
+ 1.0,
184
+ 1.0,
185
+ 1.0,
186
+ 0.5,
187
+ 1.0,
188
+ 1.0,
189
+ 1.0,
190
+ 0.5,
191
+ 1.0,
192
+ 1.0,
193
+ 1.0,
194
+ 0.5,
195
+ 1.0,
196
+ 1.0,
197
+ 1.0,
198
+ 0.5,
199
+ 1.0,
200
+ 1.0,
201
+ 1.0,
202
+ 0.5,
203
+ 1.0,
204
+ 1.0,
205
+ 1.0,
206
+ 0.5,
207
+ 1.0,
208
+ 1.0,
209
+ 1.0,
210
+ 0.5,
211
+ 1.0,
212
+ 1.0,
213
+ 1.0,
214
+ 0.5,
215
+ 1.0,
216
+ 1.0,
217
+ 1.0,
218
+ 0.5,
219
+ 1.0,
220
+ 1.0,
221
+ 1.0,
222
+ 0.5,
223
+ 1.0,
224
+ 1.0,
225
+ 1.0,
226
+ 0.5,
227
+ 1.0,
228
+ 1.0,
229
+ 1.0
230
+ ],
231
+ "eos_token_id": [
232
+ 1,
233
+ 2,
234
+ 128007
235
+ ],
236
+ "bos_token_id": 0,
237
+ "attention_other_setting": {
238
+ "attention_type": "sliding_attention",
239
+ "num_attention_heads": 96,
240
+ "num_attention_groups": 8,
241
+ "head_dim": 128,
242
+ "true_head_dim": 128
243
+ },
244
+ "swiglu_limits": [
245
+ 0.0,
246
+ 0.0,
247
+ 0.0,
248
+ 0.0,
249
+ 0.0,
250
+ 0.0,
251
+ 0.0,
252
+ 0.0,
253
+ 0.0,
254
+ 0.0,
255
+ 0.0,
256
+ 0.0,
257
+ 0.0,
258
+ 0.0,
259
+ 0.0,
260
+ 0.0,
261
+ 0.0,
262
+ 0.0,
263
+ 0.0,
264
+ 0.0,
265
+ 0.0,
266
+ 0.0,
267
+ 0.0,
268
+ 0.0,
269
+ 0.0,
270
+ 0.0,
271
+ 0.0,
272
+ 0.0,
273
+ 0.0,
274
+ 0.0,
275
+ 0.0,
276
+ 0.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0,
280
+ 0.0,
281
+ 0.0,
282
+ 0.0,
283
+ 0.0,
284
+ 0.0,
285
+ 0.0,
286
+ 0.0,
287
+ 0.0,
288
+ 7,
289
+ 7,
290
+ 0.0,
291
+ 0.0,
292
+ 0.0
293
+ ],
294
+ "swiglu_limits_shared": [
295
+ 0.0,
296
+ 0.0,
297
+ 0.0,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.0,
303
+ 0.0,
304
+ 0.0,
305
+ 0.0,
306
+ 0.0,
307
+ 0.0,
308
+ 0.0,
309
+ 0.0,
310
+ 0.0,
311
+ 0.0,
312
+ 0.0,
313
+ 0.0,
314
+ 0.0,
315
+ 0.0,
316
+ 0.0,
317
+ 0.0,
318
+ 0.0,
319
+ 0.0,
320
+ 0.0,
321
+ 0.0,
322
+ 0.0,
323
+ 0.0,
324
+ 0.0,
325
+ 0.0,
326
+ 0.0,
327
+ 0.0,
328
+ 0.0,
329
+ 0.0,
330
+ 0.0,
331
+ 0.0,
332
+ 0.0,
333
+ 0.0,
334
+ 0.0,
335
+ 0.0,
336
+ 0.0,
337
+ 0.0,
338
+ 16,
339
+ 16,
340
+ 0.0,
341
+ 0.0,
342
+ 0.0
343
+ ]
344
+ }
345
+ }
configuration_step3p7.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Optional, Sequence, Union
2
+
3
+ from transformers.configuration_utils import PretrainedConfig
4
+
5
+ class StepRoboticsVisionEncoderConfig(PretrainedConfig):
6
+ model_type = "perception_encoder"
7
+
8
+ def __init__(
9
+ self,
10
+ width=1536,
11
+ layers=47,
12
+ heads=16,
13
+ num_channels=3,
14
+ image_size=728,
15
+ mlp_ratio = 8960/1536,
16
+ patch_size=14,
17
+ hidden_act="quick_gelu",
18
+ layer_norm_eps=1e-5,
19
+ ues_cls_token=False,
20
+ use_cls_token: Optional[bool] = None,
21
+ use_ln_pre=True,
22
+ use_ln_post=False,
23
+ use_abs_posemb=True,
24
+ use_rope2d=True,
25
+ ls_init_value=0.1,
26
+ **kwargs,
27
+ ):
28
+ self.width = width
29
+ self.layers = layers
30
+ self.heads = heads
31
+ self.num_channels = num_channels
32
+ self.patch_size = patch_size
33
+ self.image_size = image_size
34
+ self.mlp_ratio = mlp_ratio
35
+ self.layer_norm_eps = layer_norm_eps
36
+ self.hidden_act = hidden_act
37
+ if use_cls_token is None:
38
+ use_cls_token = ues_cls_token
39
+ self.ues_cls_token = use_cls_token
40
+ self.use_cls_token = use_cls_token
41
+ self.use_ln_pre = use_ln_pre
42
+ self.ls_init_value = ls_init_value
43
+ self.use_ln_post = use_ln_post
44
+ self.use_abs_posemb = use_abs_posemb
45
+ self.use_rope2d = use_rope2d
46
+ super().__init__(**kwargs)
47
+
48
+
49
+ class Step3p7TextConfig(PretrainedConfig):
50
+ model_type = "step3p5"
51
+ architectures = ["Step3p5ForCausalLM"]
52
+
53
+ def __init__(
54
+ self,
55
+ hidden_size: int = 4096,
56
+ intermediate_size: int = 11264,
57
+ num_attention_heads: int = 64,
58
+ num_attention_groups: int = 8,
59
+ num_hidden_layers: int = 45,
60
+ max_seq_len: int = 128000,
61
+ vocab_size: int = 128815,
62
+ rms_norm_eps: float = 1e-5,
63
+ moe_intermediate_size: int = 1280,
64
+ moe_num_experts: int = 288,
65
+ moe_top_k: int = 8,
66
+ rope_theta: float = 10000,
67
+ rope_scaling: Optional[dict[str, Any]] = None,
68
+ max_position_embeddings: int = 128000,
69
+ share_expert_dims: int = 1280,
70
+ share_expert_dim: Optional[int] = None,
71
+ head_dim: int = 128,
72
+ norm_expert_weight: bool = True,
73
+ layer_types: list[str] = None,
74
+ sliding_window: Optional[int] = None,
75
+ pad_token_id: int = 1,
76
+ attention_dropout: float = 0.0,
77
+ use_head_wise_attn_gate: bool = False,
78
+ use_moe_router_bias: bool = False,
79
+ moe_router_activation: str = "softmax",
80
+ moe_router_scaling_factor: float = 1.0,
81
+ need_fp32_gate: bool = False,
82
+ attention_other_setting: Optional[dict[str, Any]] = None,
83
+ swiglu_limits: Optional[list[Optional[float]]] = None,
84
+ swiglu_limits_shared: Optional[list[Optional[float]]] = None,
85
+ use_rope_layers: Optional[list[bool]] = None,
86
+ yarn_only_types: Optional[list[str]] = None,
87
+ moe_layers_enum: tuple[int] = (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
88
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
89
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
90
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44),
91
+ **kwargs,
92
+ ) -> None:
93
+ torch_dtype = kwargs.get("torch_dtype")
94
+ trim_layer_types = _normalize_per_layer_values(layer_types,
95
+ num_hidden_layers)
96
+ if isinstance(rope_scaling, dict):
97
+ rope_scaling = dict(rope_scaling)
98
+ if share_expert_dim is None:
99
+ share_expert_dim = share_expert_dims
100
+ self.hidden_size = hidden_size
101
+ self.intermediate_size = intermediate_size
102
+ self.num_attention_heads = num_attention_heads
103
+ self.num_attention_groups = num_attention_groups
104
+ self.num_hidden_layers = num_hidden_layers
105
+ self.max_seq_len = max_seq_len
106
+ self.vocab_size = vocab_size
107
+ self.rms_norm_eps = rms_norm_eps
108
+ self.moe_intermediate_size = moe_intermediate_size
109
+ self.moe_num_experts = moe_num_experts
110
+ self.moe_top_k = moe_top_k
111
+ self.rope_theta = rope_theta
112
+ self.rope_scaling = rope_scaling
113
+ self.max_position_embeddings = max_position_embeddings
114
+ self.share_expert_dim = share_expert_dim
115
+ self.head_dim = head_dim
116
+ self.norm_expert_weight = norm_expert_weight
117
+ self.moe_layers_enum = moe_layers_enum
118
+ self.layer_types = trim_layer_types
119
+ self.sliding_window = sliding_window
120
+ self.pad_token_id = pad_token_id
121
+ self.attention_dropout = attention_dropout
122
+ self.use_head_wise_attn_gate = use_head_wise_attn_gate
123
+ self.use_moe_router_bias = use_moe_router_bias
124
+ self.moe_router_activation = moe_router_activation
125
+ self.moe_router_scaling_factor = moe_router_scaling_factor
126
+ self.need_fp32_gate = need_fp32_gate
127
+ self.attention_other_setting = attention_other_setting
128
+ self.swiglu_limits = swiglu_limits
129
+ self.swiglu_limits_shared = swiglu_limits_shared
130
+ self.use_rope_layers = use_rope_layers
131
+ self.yarn_only_types = yarn_only_types
132
+ super().__init__(**kwargs)
133
+ if torch_dtype is not None:
134
+ self.torch_dtype = torch_dtype
135
+ self.layer_types = layer_types
136
+
137
+ def to_dict(self):
138
+ output = super().to_dict()
139
+ torch_dtype = getattr(self, "torch_dtype", None)
140
+ if torch_dtype is not None:
141
+ output["torch_dtype"] = torch_dtype
142
+ return output
143
+
144
+
145
+ def _normalize_per_layer_values(
146
+ values: Optional[Sequence[Any]],
147
+ num_hidden_layers: int,
148
+ ) -> Optional[list[Any]]:
149
+ if values is None:
150
+ return None
151
+ normalized = list(values)
152
+ if not normalized:
153
+ return normalized
154
+ if len(normalized) < num_hidden_layers:
155
+ normalized.extend([normalized[-1]] *
156
+ (num_hidden_layers - len(normalized)))
157
+ # Some checkpoints keep MTP/spec layer entries after the decoder layers.
158
+ # This config only builds num_hidden_layers decoder layers, and HF strict
159
+ # validation requires per-layer fields to match that decoder count.
160
+ return normalized[:num_hidden_layers]
161
+
162
+ class Step3p7Config(PretrainedConfig):
163
+ # This loader is a compatibility shim for original Step VL checkpoints
164
+ # whose top-level config model_type is `step3p7`.
165
+ model_type = "step3p7"
166
+
167
+ def __init__(
168
+ self,
169
+ vision_config: Optional[Union[dict, StepRoboticsVisionEncoderConfig]] = None,
170
+ text_config: Optional[Union[dict, Step3p7TextConfig]] = None,
171
+ understand_projector_stride: int = 2,
172
+ projector_bias: bool = False,
173
+ image_token_id: int = 151679,
174
+ **kwargs,
175
+ ) -> None:
176
+ shared_rope_scaling = kwargs.get("rope_scaling")
177
+ if isinstance(shared_rope_scaling, dict):
178
+ shared_rope_scaling = dict(shared_rope_scaling)
179
+
180
+ if vision_config is None:
181
+ vision_config = StepRoboticsVisionEncoderConfig()
182
+ elif isinstance(vision_config, dict):
183
+ vision_config = StepRoboticsVisionEncoderConfig(**vision_config)
184
+ self.vision_config = vision_config
185
+
186
+ if text_config is None:
187
+ text_config = Step3p7TextConfig(rope_scaling=shared_rope_scaling)
188
+ elif isinstance(text_config, dict):
189
+ text_config = dict(text_config)
190
+ if shared_rope_scaling is not None and "rope_scaling" not in text_config:
191
+ text_config["rope_scaling"] = shared_rope_scaling
192
+ text_config = Step3p7TextConfig(**text_config)
193
+ elif shared_rope_scaling is not None and text_config.rope_scaling is None:
194
+ text_config.rope_scaling = dict(shared_rope_scaling)
195
+ self.text_config = text_config
196
+
197
+ rope_scaling = kwargs.get("rope_scaling")
198
+ if isinstance(rope_scaling, dict):
199
+ kwargs["rope_scaling"] = dict(rope_scaling)
200
+
201
+ self.understand_projector_stride = understand_projector_stride
202
+ self.projector_bias = projector_bias
203
+ self.hidden_size = text_config.hidden_size
204
+ self.max_position_embeddings = text_config.max_position_embeddings
205
+ self.image_token_id = image_token_id
206
+ # Help Auto classes find the correct implementation when saving/loading.
207
+ super().__init__(**kwargs)
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": [
5
+ 1,
6
+ 2,
7
+ 128007
8
+ ],
9
+ "transformers_version": "4.56.2"
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc7600d64dba5fc566a9a00d09f3f4fa7691aa6eccc27b606a225c5ff7cbc7bc
3
+ size 5912264080
model.safetensors.index.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 5912258048
4
+ },
5
+ "weight_map": {
6
+ "model.embed_tokens.weight": "model.safetensors",
7
+ "model.layers.45.eh_proj.weight": "model.safetensors",
8
+ "model.layers.45.enorm.weight": "model.safetensors",
9
+ "model.layers.45.hnorm.weight": "model.safetensors",
10
+ "model.layers.45.input_layernorm.weight": "model.safetensors",
11
+ "model.layers.45.mlp.down_proj.weight": "model.safetensors",
12
+ "model.layers.45.mlp.gate_proj.weight": "model.safetensors",
13
+ "model.layers.45.mlp.up_proj.weight": "model.safetensors",
14
+ "model.layers.45.post_attention_layernorm.weight": "model.safetensors",
15
+ "model.layers.45.self_attn.g_proj.weight": "model.safetensors",
16
+ "model.layers.45.self_attn.k_norm.weight": "model.safetensors",
17
+ "model.layers.45.self_attn.k_proj.weight": "model.safetensors",
18
+ "model.layers.45.self_attn.o_proj.weight": "model.safetensors",
19
+ "model.layers.45.self_attn.q_norm.weight": "model.safetensors",
20
+ "model.layers.45.self_attn.q_proj.weight": "model.safetensors",
21
+ "model.layers.45.self_attn.v_proj.weight": "model.safetensors",
22
+ "model.layers.45.transformer.shared_head.norm.weight": "model.safetensors",
23
+ "model.layers.45.transformer.shared_head.output.weight": "model.safetensors",
24
+ "model.layers.46.eh_proj.weight": "model.safetensors",
25
+ "model.layers.46.enorm.weight": "model.safetensors",
26
+ "model.layers.46.hnorm.weight": "model.safetensors",
27
+ "model.layers.46.input_layernorm.weight": "model.safetensors",
28
+ "model.layers.46.mlp.down_proj.weight": "model.safetensors",
29
+ "model.layers.46.mlp.gate_proj.weight": "model.safetensors",
30
+ "model.layers.46.mlp.up_proj.weight": "model.safetensors",
31
+ "model.layers.46.post_attention_layernorm.weight": "model.safetensors",
32
+ "model.layers.46.self_attn.g_proj.weight": "model.safetensors",
33
+ "model.layers.46.self_attn.k_norm.weight": "model.safetensors",
34
+ "model.layers.46.self_attn.k_proj.weight": "model.safetensors",
35
+ "model.layers.46.self_attn.o_proj.weight": "model.safetensors",
36
+ "model.layers.46.self_attn.q_norm.weight": "model.safetensors",
37
+ "model.layers.46.self_attn.q_proj.weight": "model.safetensors",
38
+ "model.layers.46.self_attn.v_proj.weight": "model.safetensors",
39
+ "model.layers.46.transformer.shared_head.norm.weight": "model.safetensors",
40
+ "model.layers.46.transformer.shared_head.output.weight": "model.safetensors",
41
+ "model.layers.47.eh_proj.weight": "model.safetensors",
42
+ "model.layers.47.enorm.weight": "model.safetensors",
43
+ "model.layers.47.hnorm.weight": "model.safetensors",
44
+ "model.layers.47.input_layernorm.weight": "model.safetensors",
45
+ "model.layers.47.mlp.down_proj.weight": "model.safetensors",
46
+ "model.layers.47.mlp.gate_proj.weight": "model.safetensors",
47
+ "model.layers.47.mlp.up_proj.weight": "model.safetensors",
48
+ "model.layers.47.post_attention_layernorm.weight": "model.safetensors",
49
+ "model.layers.47.self_attn.g_proj.weight": "model.safetensors",
50
+ "model.layers.47.self_attn.k_norm.weight": "model.safetensors",
51
+ "model.layers.47.self_attn.k_proj.weight": "model.safetensors",
52
+ "model.layers.47.self_attn.o_proj.weight": "model.safetensors",
53
+ "model.layers.47.self_attn.q_norm.weight": "model.safetensors",
54
+ "model.layers.47.self_attn.q_proj.weight": "model.safetensors",
55
+ "model.layers.47.self_attn.v_proj.weight": "model.safetensors",
56
+ "model.layers.47.transformer.shared_head.norm.weight": "model.safetensors",
57
+ "model.layers.47.transformer.shared_head.output.weight": "model.safetensors"
58
+ }
59
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|begin▁of▁sentence|>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|im_end|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|end▁of▁sentence|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff