lazarevich commited on
Commit
8e9d388
·
0 Parent(s):

upload checkpoint

Browse files
README.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ library_name: transformers
5
+ tags:
6
+ - glm
7
+ - MOE
8
+ - pruning
9
+ - compression
10
+ license: mit
11
+ name: cerebras/GLM-4.7-Flash-REAP-23B-A3B
12
+ description: >
13
+ This model was obtained by uniformly pruning 25% of experts in GLM-4.7-Flash using the REAP method.
14
+ readme: >
15
+ https://huggingface.co/cerebras/GLM-4.7-Flash-REAP-23B-A3B/main/README.md
16
+ license_link: https://huggingface.co/zai-org/GLM-4.7-Flash/blob/main/LICENSE
17
+ pipeline_tag: text-generation
18
+ base_model:
19
+ - zai-org/GLM-4.7-Flash
20
+ ---
21
+
22
+ <p align="center">
23
+ <em>𓌳 <strong>REAP</strong>𓌳 the Experts: Why Pruning Prevails for One-Shot MoE Compression</em><br>
24
+ <img src="https://i.imgur.com/rmzG3gg.png" alt="REAP" width="75%">
25
+ </p>
26
+
27
+ # GLM-4.7-Flash-REAP-23B-A3B
28
+
29
+ ## ✨ Highlights
30
+
31
+ Introducing **GLM-4.7-Flash-REAP-23B-A3B**, a **memory-efficient compressed variant** of GLM-4.7-Flash that maintains near-identical performance while being **25% lighter**.
32
+
33
+ This model was created using **REAP (Router-weighted Expert Activation Pruning)**, a novel expert pruning method that selectively removes redundant experts while preserving the router's independent control over remaining experts. Key features include:
34
+
35
+ - **Near-Lossless Performance**: Maintains almost identical accuracy on code generation, agentic coding, and function calling tasks compared to the full 355B model
36
+ - **25% Memory Reduction**: Compressed from 355B to 218B parameters, significantly lowering deployment costs and memory requirements
37
+ - **Preserved Capabilities**: Retains all core functionalities including code generation, agentic workflows, repository-scale understanding, and function calling
38
+ - **Drop-in Compatibility**: Works with vanilla vLLM - no source modifications or custom patches required
39
+ - **Optimized for Real-World Use**: Particularly effective for resource-constrained environments, local deployments, and academic research
40
+
41
+ ---
42
+ ## 📋 Model Overview
43
+
44
+ **GLM-4.7-Flash-REAP-23B-A3B** has the following specifications:
45
+
46
+ - **Base Model**: GLM-4.7-Flash
47
+ - **Compression Method**: REAP (Router-weighted Expert Activation Pruning)
48
+ - **Compression Ratio**: 25% expert pruning
49
+ - **Type**: Sparse Mixture-of-Experts (SMoE) Causal Language Model
50
+ - **Number of Parameters**: 23B total, 3B activated per token
51
+ - **Number of Layers**: 47
52
+ - **Number of Attention Heads**: 20 for QKV
53
+ - **Number of Experts**: 48 (uniformly pruned from 64)
54
+ - **Number of Activated Experts**: 4 per token
55
+ - **Context Length**: 202,752 tokens
56
+ - **License**: MIT
57
+
58
+ ---
59
+
60
+ ## 📊 Evaluations
61
+
62
+ <table>
63
+ <thead>
64
+ <tr>
65
+ <th align="left">Benchmark</th>
66
+ <th align="center">GLM-4.7-Flash</th>
67
+ <th align="center"><a href="https://huggingface.co/cerebras/GLM-4.7-Flash-REAP-23B-A3B">GLM-4.7-Flash-REAP-23B-A3B</a></th>
68
+ </tr>
69
+ </thead>
70
+ <tbody>
71
+ <tr>
72
+ <td><strong>Compression</strong></td>
73
+ <td align="center">—</td>
74
+ <td align="center">25%</td>
75
+ </tr>
76
+ <tr>
77
+ <td colspan="5" align="center"><strong>Coding</strong></td>
78
+ </tr>
79
+ <tr>
80
+ <td><strong>HumanEval</strong></td>
81
+ <td align="center">94.5</td>
82
+ <td align="center">95.1</td>
83
+ </tr>
84
+ <tr>
85
+ <td><strong>HumanEval+</strong></td>
86
+ <td align="center">89.0</td>
87
+ <td align="center">89.0</td>
88
+ </tr>
89
+ </table>
90
+
91
+ 🟩 *This checkpoint maintains almost identical performance while being 25% lighter.*
92
+
93
+ For more details on the evaluation setup, refer to the [REAP arXiv preprint](https://arxiv.org/abs/2510.13999).
94
+
95
+ ---
96
+
97
+ ## 🚀 Deployment
98
+
99
+ You can deploy the model directly using the **latest vLLM** (that supports GLM4.7-Flash), no source modifications or custom patches required.
100
+
101
+ ```bash
102
+ vllm serve cerebras/GLM-4.7-Flash-REAP-23B-A3B \
103
+ --tensor-parallel-size 4 \
104
+ --reasoning-parser glm45 \
105
+ --tool-call-parser glm47 \
106
+ --enable-auto-tool-choice
107
+ ```
108
+
109
+ If you encounter insufficient memory when running this model, you might need to set a lower value for `--max-num-seqs` flag (e.g. set to 64).
110
+
111
+
112
+ ## 🧩 Model Creation
113
+
114
+ This checkpoint was created by applying the **REAP (Router-weighted Expert Activation Pruning)** method uniformly across all Mixture-of-Experts (MoE) blocks of **GLM-4.7**, with a **25% pruning rate**.
115
+
116
+ ### How REAP Works
117
+
118
+ REAP selects experts to prune based on a novel **saliency criterion** that considers both:
119
+ - **Router gate values**: How frequently and strongly the router activates each expert
120
+ - **Expert activation norms**: The magnitude of each expert's output contributions
121
+
122
+ This dual consideration ensures that experts contributing minimally to the layer's output are pruned, while preserving those that play critical roles in the model's computations.
123
+
124
+ ### Key Advantages
125
+
126
+ - **One-Shot Compression**: No fine-tuning required after pruning - the model is immediately ready for deployment
127
+ - **Preserved Router Control**: Unlike expert merging methods, REAP maintains the router's independent, input-dependent control over remaining experts, avoiding "functional subspace collapse"
128
+ - **Generative Task Superiority**: REAP significantly outperforms expert merging approaches on generative benchmarks (code generation, creative writing, mathematical reasoning) while maintaining competitive performance on discriminative tasks
129
+
130
+ ### Calibration
131
+
132
+ The model was calibrated using a diverse mixture of domain-specific datasets including:
133
+ - Code generation samples ([evol-codealpaca](https://huggingface.co/datasets/theblackcat102/evol-codealpaca-v1))
134
+ - Function calling examples ([xlam-function-calling](https://huggingface.co/datasets/Salesforce/xlam-function-calling-60k))
135
+ - Agentic multi-turn trajectories ([SWE-smith-trajectories](https://huggingface.co/datasets/SWE-bench/SWE-smith-trajectories))
136
+
137
+ 📚 For more details, refer to the following resources:
138
+
139
+ - [🧾 arXiv Preprint](https://arxiv.org/abs/2510.13999)
140
+ - [🧾 REAP Blog](https://www.cerebras.ai/blog/reap)
141
+ - [💻 REAP Codebase (GitHub)](https://github.com/CerebrasResearch/reap)
142
+
143
+ ---
144
+
145
+ ## ⚖️ License
146
+
147
+ This model is derived from
148
+ **[`zai-org/GLM-4.7-Flash`](https://huggingface.co/zai-org/GLM-4.7-Flash)**
149
+ and distributed under the **MIT license**.
150
+
151
+ ---
152
+
153
+ ## 🧾 Citation
154
+
155
+ If you use this checkpoint, please cite the REAP paper:
156
+
157
+ ```bibtex
158
+ @article{lasby-reap,
159
+ title={REAP the Experts: Why Pruning Prevails for One-Shot MoE compression},
160
+ author={Lasby, Mike and Lazarevich, Ivan and Sinnadurai, Nish and Lie, Sean and Ioannou, Yani and Thangarasa, Vithursan},
161
+ journal={arXiv preprint arXiv:2510.13999},
162
+ year={2025}
163
+ }
164
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gMASK]<sop>
2
+ {%- if tools -%}
3
+ <|system|>
4
+ # Tools
5
+
6
+ You may call one or more functions to assist with the user query.
7
+
8
+ You are provided with function signatures within <tools></tools> XML tags:
9
+ <tools>
10
+ {% for tool in tools %}
11
+ {{ tool | tojson(ensure_ascii=False) }}
12
+ {% endfor %}
13
+ </tools>
14
+
15
+ For each function call, output the function name and arguments within the following XML format:
16
+ <tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%- endif -%}
17
+ {%- macro visible_text(content) -%}
18
+ {%- if content is string -%}
19
+ {{- content }}
20
+ {%- elif content is iterable and content is not mapping -%}
21
+ {%- for item in content -%}
22
+ {%- if item is mapping and item.type == 'text' -%}
23
+ {{- item.text }}
24
+ {%- elif item is string -%}
25
+ {{- item }}
26
+ {%- endif -%}
27
+ {%- endfor -%}
28
+ {%- else -%}
29
+ {{- content }}
30
+ {%- endif -%}
31
+ {%- endmacro -%}
32
+ {%- set ns = namespace(last_user_index=-1) %}
33
+ {%- for m in messages %}
34
+ {%- if m.role == 'user' %}
35
+ {% set ns.last_user_index = loop.index0 -%}
36
+ {%- endif %}
37
+ {%- endfor %}
38
+ {% for m in messages %}
39
+ {%- if m.role == 'user' -%}<|user|>{{ visible_text(m.content) }}
40
+ {%- elif m.role == 'assistant' -%}
41
+ <|assistant|>
42
+ {%- set reasoning_content = '' %}
43
+ {%- set content = visible_text(m.content) %}
44
+ {%- if m.reasoning_content is string %}
45
+ {%- set reasoning_content = m.reasoning_content %}
46
+ {%- else %}
47
+ {%- if '</think>' in content %}
48
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
49
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
50
+ {%- endif %}
51
+ {%- endif %}
52
+ {%- if ((clear_thinking is defined and not clear_thinking) or loop.index0 > ns.last_user_index) and reasoning_content -%}
53
+ {{ '<think>' + reasoning_content.strip() + '</think>'}}
54
+ {%- else -%}
55
+ {{ '</think>' }}
56
+ {%- endif -%}
57
+ {%- if content.strip() -%}
58
+ {{ content.strip() }}
59
+ {%- endif -%}
60
+ {% if m.tool_calls %}
61
+ {% for tc in m.tool_calls %}
62
+ {%- if tc.function %}
63
+ {%- set tc = tc.function %}
64
+ {%- endif %}
65
+ {{- '<tool_call>' + tc.name -}}
66
+ {% set _args = tc.arguments %}{% for k, v in _args.items() %}<arg_key>{{ k }}</arg_key><arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>{% endfor %}</tool_call>{% endfor %}
67
+ {% endif %}
68
+ {%- elif m.role == 'tool' -%}
69
+ {%- if m.content is string -%}
70
+ {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
71
+ {{- '<|observation|>' }}
72
+ {%- endif %}
73
+ {{- '<tool_response>' }}
74
+ {{- m.content }}
75
+ {{- '</tool_response>' }}
76
+ {%- else -%}
77
+ <|observation|>{% for tr in m.content %}
78
+ <tool_response>{{ tr.output if tr.output is defined else tr }}</tool_response>{% endfor -%}
79
+ {% endif -%}
80
+ {%- elif m.role == 'system' -%}
81
+ <|system|>{{ visible_text(m.content) }}
82
+ {%- endif -%}
83
+ {%- endfor -%}
84
+ {%- if add_generation_prompt -%}
85
+ <|assistant|>{{- '</think>' if (enable_thinking is defined and not enable_thinking) else '<think>' -}}
86
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Glm4MoeLiteForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 0,
8
+ "dtype": "bfloat16",
9
+ "eos_token_id": [
10
+ 154820,
11
+ 154827,
12
+ 154829
13
+ ],
14
+ "first_k_dense_replace": 1,
15
+ "head_dim": 64,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 2048,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 10240,
20
+ "kv_lora_rank": 512,
21
+ "max_position_embeddings": 202752,
22
+ "mlp_layer_types": [
23
+ "dense",
24
+ "sparse",
25
+ "sparse",
26
+ "sparse",
27
+ "sparse",
28
+ "sparse",
29
+ "sparse",
30
+ "sparse",
31
+ "sparse",
32
+ "sparse",
33
+ "sparse",
34
+ "sparse",
35
+ "sparse",
36
+ "sparse",
37
+ "sparse",
38
+ "sparse",
39
+ "sparse",
40
+ "sparse",
41
+ "sparse",
42
+ "sparse",
43
+ "sparse",
44
+ "sparse",
45
+ "sparse",
46
+ "sparse",
47
+ "sparse",
48
+ "sparse",
49
+ "sparse",
50
+ "sparse",
51
+ "sparse",
52
+ "sparse",
53
+ "sparse",
54
+ "sparse",
55
+ "sparse",
56
+ "sparse",
57
+ "sparse",
58
+ "sparse",
59
+ "sparse",
60
+ "sparse",
61
+ "sparse",
62
+ "sparse",
63
+ "sparse",
64
+ "sparse",
65
+ "sparse",
66
+ "sparse",
67
+ "sparse",
68
+ "sparse",
69
+ "sparse"
70
+ ],
71
+ "model_type": "glm4_moe_lite",
72
+ "moe_intermediate_size": 1536,
73
+ "n_group": 1,
74
+ "n_routed_experts": 48,
75
+ "n_shared_experts": 1,
76
+ "norm_topk_prob": true,
77
+ "num_attention_heads": 20,
78
+ "num_experts_per_tok": 4,
79
+ "num_hidden_layers": 47,
80
+ "num_key_value_heads": 20,
81
+ "num_nextn_predict_layers": 0,
82
+ "pad_token_id": 154820,
83
+ "partial_rotary_factor": 1.0,
84
+ "pretraining_tp": 1,
85
+ "q_lora_rank": 768,
86
+ "qk_head_dim": 256,
87
+ "qk_nope_head_dim": 192,
88
+ "qk_rope_head_dim": 64,
89
+ "rms_norm_eps": 1e-05,
90
+ "rope_interleave": true,
91
+ "rope_parameters": {
92
+ "partial_rotary_factor": 1.0,
93
+ "rope_theta": 1000000,
94
+ "rope_type": "default"
95
+ },
96
+ "routed_scaling_factor": 1.8,
97
+ "tie_word_embeddings": false,
98
+ "topk_group": 1,
99
+ "topk_method": "noaux_tc",
100
+ "transformers_version": "5.0.0rc3",
101
+ "use_cache": true,
102
+ "v_head_dim": 256,
103
+ "vocab_size": 154880
104
+ }
model-00001-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b230d13ddfce3d53835b9b3b97c7219321be8e9f3465d84de787e4a6b6459720
3
+ size 5363354288
model-00002-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:642adcd78a9d886f6300135a629cf74245996e5fc58ff10add693f0e43b5dd90
3
+ size 5364819824
model-00003-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d32b9b4173bb8179e25a66ce0c70ff3f10684d9120ffa7ba0ffb38011437431
3
+ size 5365136840
model-00004-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c82d622e113410c959e165e698e87a9d0fd3730a9e99be5acc610ee747dff73
3
+ size 5364820504
model-00005-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d160458b9dab6c72f379948724d582981a78ce5d964db308f95046c3cacd7b64
3
+ size 5365136840
model-00006-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f1259f8393bdd3cec42f1eb6ab8b91fa5b1693a69dd0a401a27de47e5c16ef4
3
+ size 5364820504
model-00007-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd83eec1cccf4bf3d3f4af0e61d0035d9c395fbf18849baf7f7d01366ee29b95
3
+ size 5365136840
model-00008-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dff1b3e5fd3dcd5a6c2f01342b0e2ae609a022b73d4d8fce8555e26bc253e0f0
3
+ size 5364820488
model-00009-of-00009.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8233be0ef2f6327e34b9ce892dc141c9a9aa86f784fb616d1587557fa88cc4e
3
+ size 3075099000
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19e773648cb4e65de8660ea6365e10acca112d42a854923df93db4a6f333a82d
3
+ size 20217442
tokenizer_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "clean_up_tokenization_spaces": false,
4
+ "do_lower_case": false,
5
+ "eos_token": "<|endoftext|>",
6
+ "extra_special_tokens": [
7
+ "<|endoftext|>",
8
+ "[MASK]",
9
+ "[gMASK]",
10
+ "[sMASK]",
11
+ "<sop>",
12
+ "<eop>",
13
+ "<|system|>",
14
+ "<|user|>",
15
+ "<|assistant|>",
16
+ "<|observation|>",
17
+ "<|begin_of_image|>",
18
+ "<|end_of_image|>",
19
+ "<|begin_of_video|>",
20
+ "<|end_of_video|>",
21
+ "<|begin_of_audio|>",
22
+ "<|end_of_audio|>",
23
+ "<|begin_of_transcription|>",
24
+ "<|end_of_transcription|>"
25
+ ],
26
+ "is_local": true,
27
+ "model_max_length": 128000,
28
+ "model_specific_special_tokens": {},
29
+ "pad_token": "<|endoftext|>",
30
+ "padding_side": "left",
31
+ "remove_space": false,
32
+ "tokenizer_class": "TokenizersBackend"
33
+ }