hugging-yiii commited on
Commit
cd86fef
Β·
verified Β·
1 Parent(s): 654a1a9

Add model card

Browse files
Files changed (1) hide show
  1. README.md +377 -0
README.md ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: glm-5.3-license
4
+ license_link: https://huggingface.co/orcarouter/GLM-5.3-MLX/blob/main/LICENSE
5
+ base_model: zai-org/GLM-5.3
6
+ base_model_relation: quantized
7
+ pipeline_tag: text-generation
8
+ library_name: mlx
9
+ language:
10
+ - en
11
+ - zh
12
+ tags:
13
+ - glm
14
+ - glm-5
15
+ - glm_moe_dsa
16
+ - mlx
17
+ - apple-silicon
18
+ - quantized
19
+ - 2-8bit
20
+ - moe
21
+ - orcasaq
22
+ - dynamic-quant
23
+ - reasoning
24
+ - coding
25
+ - agentic
26
+ ---
27
+
28
+ # GLM-5.3-MLX
29
+
30
+ *An MLX build of the official GLM-5.3 β€” 2 / 3 / 4 / 6-bit OrcaSAQ quant for Apple Silicon & the MLX CUDA backend*
31
+
32
+ **β–Ά [Run GLM-5.3 instantly on the OrcaRouter API](https://www.orcarouter.ai/models/z-ai/glm-5.3)** β€” no download, full precision.
33
+
34
+ [Website](https://www.orcarouter.ai) Β· [Model Catalog](https://www.orcarouter.ai/models) Β· [Model API](https://www.orcarouter.ai/models/z-ai/glm-5.3) Β· [GitHub](https://github.com/Continuum-AI-Corp) Β· [OrcaCode Review](https://github.com/Continuum-AI-Corp/Orca-Code-Review) Β· [Discord](https://discord.gg/yAh6Tex6kx) Β· [X](https://x.com/OrcaRouter)
35
+
36
+ ---
37
+
38
+ ## Overview
39
+
40
+ An **MLX** build of the official [`zai-org/GLM-5.3`](https://huggingface.co/zai-org/GLM-5.3) β€” Z.AI's **753B-total / ~39B-active** MoE flagship for frontier coding and long-horizon agentic engineering, built on the **`glm_moe_dsa`** architecture (MLA + DeepSeek-style **sparse attention with a shared indexer**) β€” quantized to **MLX** for **Apple Silicon** and the MLX CUDA backend.
41
+
42
+ Four builds (**2 / 3 / 4 / 6-bit**) ship as subfolders, with the **4-bit build mirrored at the repo root**, produced with **OrcaSAQ (Sensitivity-Aware Quantization)** β€” calibration-free and architecture-aware: sensitive tensors get more bits (shared experts `+2`, `down_proj` `+1`), and the components that decide *what attention sees* are never quantized at all.
43
+
44
+ Two things are specific to this checkpoint and drive the whole recipe:
45
+
46
+ - **Attention is FP8 upstream** (unlike GLM-5.3-Flash, where it shipped BF16), so it *is* quantizable β€” and it is **pinned to 8-bit in every build**, never dropped to the base tier.
47
+ - **The DSA indexer is kept in BF16 everywhere.** It selects which tokens attention attends to; degrading it degrades the long-context path itself, which is exactly the failure mode teacher-forced evals hide.
48
+
49
+ Everything that was *not* FP8 in the base release β€” the indexer, router `gate` weights, the FP32 `e_score_correction_bias`, every norm, `embed_tokens` and `lm_head` β€” is carried through at its **original dtype**, never a lossy cast.
50
+
51
+ ---
52
+
53
+ ## Available Quantizations
54
+
55
+ | Folder | Expert base bits | Group size | Size | Min RAM | Quality vs FP8 |
56
+ |---|---|---|---:|---:|---|
57
+ | `6-bit/` | 6 | 64 | **671 GB** (625 GiB) | ~700 GB | **Near-lossless** β€” best quality |
58
+ | `4-bit/` | 4 | 64 | **459 GB** (427 GiB) | ~480 GB | Very good β€” **recommended default** |
59
+ | `3-bit/` | 3 | 64 | **368 GB** (343 GiB) | ~390 GB | Good β€” aggressive but usable |
60
+ | `2-bit/` | 2 | 32 | **322 GB** (300 GiB) | ~340 GB | Aggressive β€” best-effort |
61
+
62
+ The **repository root is a mirror of `4-bit/`**, so `orcarouter/GLM-5.3-MLX` resolves to the recommended default with no subfolder needed.
63
+
64
+ > Quantized from the official **FP8** release (756 GB, block-wise `e4m3` 128Γ—128, dynamic activation scheme). Bit-widths above are the **expert base** precision; the OrcaSAQ policy below raises sensitive tensors above the base. Group size is 64 everywhere except the `2-bit` routed experts, which use 32 β€” at two bits the finer grid is what keeps the build usable (see the fidelity table).
65
+
66
+ **Hardware reality check.** This is a 753B model; even the smallest build is 322 GB. On a **512 GB M3 Ultra Mac Studio**, `2-bit` and `3-bit` leave comfortable KV headroom and `4-bit` fits but runs tight β€” raise the wired-memory limit and keep the context bounded. `6-bit` does not fit any single Apple Silicon machine today: run it across two 512 GB boxes with `mlx.distributed`, or on a CUDA host (8Γ—H200 = 1128 GB) via the MLX CUDA backend. If the hardware isn't there, the [hosted API](https://www.orcarouter.ai/models/z-ai/glm-5.3) needs no local memory at all.
67
+
68
+ No 8-bit build was produced: `6-bit` already lands at cosine β‰₯ 0.9997 against FP8, and 8-bit expert weights would exceed the FP8 source in size.
69
+
70
+ ---
71
+
72
+ ## OrcaSAQ β€” Sensitivity-Aware Quantization
73
+
74
+ OrcaSAQ is a **calibration-free, architecture-aware mixed-precision quantization method** designed to preserve model quality while aggressively reducing memory footprint.
75
+
76
+ Instead of running expensive calibration datasets or per-layer sensitivity searches, OrcaSAQ uses **architectural and tensor-role priors** to determine which weights are most sensitive to quantization. Critical components receive higher precision, while more quantization-tolerant tensors remain at the target base precision.
77
+
78
+ For MoE architectures, for example, OrcaSAQ can preserve shared experts at **base +2 bits**, `down_proj` at **base +1 bit**, keep `gate_proj` and `up_proj` at the base precision, and retain sensitive non-quantized components at their source dtype.
79
+
80
+ The result is a **fast, deterministic, zero-calibration quantization pipeline** that can be applied to new architectures without costly dataset-driven optimization.
81
+
82
+ **Architecture-aware. Calibration-free. Quality-preserving.**
83
+
84
+ ### Bit Allocation for GLM-5.3
85
+
86
+ | Component | Tensors | Params | 2-bit | 3-bit | 4-bit | 6-bit | Policy |
87
+ |---|---:|---:|---|---|---|---|---|
88
+ | Expert `gate_proj` / `up_proj` | 38,400 | 483.2B | 2 `gs32` | 3 | 4 | 6 | base |
89
+ | Expert `down_proj` | 19,200 | 241.6B | 3 `gs32` | 4 | 5 | 8 | base **+1** |
90
+ | Shared expert `gate` / `up` / `down` | 225 | 2.83B | 4 | 5 | 6 | 8 | base **+2** |
91
+ | MLA `q_a` / `q_b` / `kv_a_with_mqa` / `kv_b` / `o_proj` | 390 | 12.87B | **8** | **8** | **8** | **8** | pinned 8-bit |
92
+ | Dense-MLP `gate` / `up` / `down` (layers 0–2) | 9 | 0.68B | **6** | **6** | **6** | **6** | pinned 6-bit |
93
+ | DSA indexer `wk` / `wq_b` / `weights_proj` | 63 | 0.19B | BF16 | BF16 | BF16 | BF16 | never quantized |
94
+ | Router `gate.weight` | 75 | 0.12B | BF16 | BF16 | BF16 | BF16 | never quantized |
95
+ | Router `e_score_correction_bias` | 75 | β€” | FP32 | FP32 | FP32 | FP32 | never quantized |
96
+ | Norms (incl. indexer `k_norm`), `embed_tokens`, `lm_head` | 357 | 1.90B | BF16 | BF16 | BF16 | BF16 | never quantized |
97
+
98
+ **58,224 tensors are quantized** in total (97.5 % of all parameters live in the routed experts). Bits are rounded to the nearest MLX-supported width (`{2,3,4,5,6,8}`), and group size must divide the tensor's last dim β€” `gs64` on attention is mandatory because `qk_nope_head_dim` is 192 and `gs128` breaks mlx-lm's `kv_b β†’ embed_q` re-quantization.
99
+
100
+ Effective width on the experts, including the FP16 scales and biases MLX stores per group:
101
+
102
+ | Build | Expert effective bpw | Experts as share of build |
103
+ |---|---:|---:|
104
+ | `2-bit` | 3.33 | 93.7 % |
105
+ | `3-bit` | 3.83 | 94.4 % |
106
+ | `4-bit` | 4.83 | 95.4 % |
107
+ | `6-bit` | 7.17 | 96.8 % |
108
+
109
+ The assignment is recorded in `config.json` β†’ `quantization` (and mirrored to `quantization_config`) as **per-module `{group_size, bits}` overrides keyed by MLX module path** β€” e.g. `model.layers.3.mlp.switch_mlp.down_proj`. MLX fuses a layer's 256 routed experts into one `switch_mlp`, so **699 entries** cover all 58,224 tensors. This is what the loader reads at load time and it is **required**: the top-level `bits`/`group_size` alone would mis-shape every raised-precision tensor. A full per-tensor record is also shipped as `quantization_map.json`.
110
+
111
+ The **MTP (multi-token prediction) layer β€” layer 78 β€” is dropped**, and `num_nextn_predict_layers` is set to `0`. 791 tensors (~9.95B params) are removed; MLX runtimes drop it at load anyway.
112
+
113
+ ---
114
+
115
+ ## Quality vs FP8
116
+
117
+ ### Weight-Space Fidelity
118
+
119
+ Measured on **every quantized tensor** at pack time (58,224 per build), against the FP8 source block-dequantized to BF16 β€” so the only variable is the quantization.
120
+
121
+ | Build | Size | Cosine sim | SNR (dB) | Rel. error |
122
+ |---|---:|---:|---:|---:|
123
+ | `6-bit` | 671 GB | **0.9998** | **37.2** | **1.7 %** |
124
+ | `4-bit` | 459 GB | **0.9968** | **22.9** | **7.6 %** |
125
+ | `3-bit` | 368 GB | **0.9865** | **16.7** | **15.7 %** |
126
+ | `2-bit` | 322 GB | **0.9517** | **11.2** | **29.7 %** |
127
+
128
+ Worst-case per build (`cos_min` / `snr_min`): `6-bit` 0.99972 / 32.5 dB Β· `4-bit` 0.99509 / 20.1 dB Β· `3-bit` 0.97869 / 13.7 dB Β· `2-bit` 0.92718 / 8.3 dB.
129
+
130
+ > Relative error is the mean of the **per-tensor** relative error `10^(-SNR/20)` over all 58,224 quantized tensors β€” not a value back-derived from the mean SNR, which would understate it (1.4 / 7.1 / 14.7 / 27.5 %).
131
+
132
+ Per role β€” this is where the OrcaSAQ policy shows up:
133
+
134
+ | Role | bits/gs | 2-bit cos | 3-bit cos | 4-bit cos | 6-bit cos |
135
+ |---|---|---:|---:|---:|---:|
136
+ | Expert `gate_proj`/`up_proj` | base | 0.93417 | 0.98169 | 0.99570 | 0.99975 |
137
+ | Expert `down_proj` | base +1 | 0.98510 | 0.99568 | 0.99898 | 0.99998 |
138
+ | Shared expert | base +2 | 0.99561 | 0.99896 | 0.99974 | 0.99998 |
139
+ | MLA attention | 8/64 | 0.99998 | 0.99998 | 0.99998 | 0.99998 |
140
+ | Dense MLP | 6/64 | 0.99975 | 0.99975 | 0.99975 | 0.99975 |
141
+
142
+ Cosine distribution across all quantized tensors (tight percentiles = no outlier tensors hiding behind a good mean):
143
+
144
+ | Build | min | p1 | p5 | median | p95 | max |
145
+ |---|---:|---:|---:|---:|---:|---:|
146
+ | `2-bit` | 0.92718 | 0.93133 | 0.93390 | 0.93437 | 0.98515 | 0.99999 |
147
+ | `3-bit` | 0.97869 | 0.98047 | 0.98157 | 0.98178 | 0.99571 | 0.99999 |
148
+ | `4-bit` | 0.99509 | 0.99546 | 0.99566 | 0.99571 | 0.99899 | 0.99999 |
149
+ | `6-bit` | 0.99972 | 0.99974 | 0.99975 | 0.99975 | 0.99999 | 0.99999 |
150
+
151
+ The worst tensors in every build are the same ones β€” early-layer routed experts (`layers.3–5`, e.g. `layers.4.mlp.experts.168.gate_proj`) β€” and `6-bit` still holds them above 0.9997.
152
+
153
+ ### Perplexity
154
+
155
+ Measured against the **FP8 reference** on wikitext-2 test, 4 chunks Γ— 1024 tokens
156
+ (4,092 predicted tokens). Both sides run the identical `glm_moe_dsa` forward on the
157
+ same FP8 kernels β€” each build's actual dequantized bytes are injected back into the
158
+ transformers model β€” so quantization is the only variable.
159
+
160
+ | Build | Size | PPL | Ξ”PPL |
161
+ |---|---:|---:|---:|
162
+ | **FP8 (ref)** | 756 GB | **1.6666** | β€” |
163
+ | **6-bit** | 671 GB | **1.6642** | **βˆ’0.14 %** |
164
+ | **4-bit** | 459 GB | **1.7015** | **+2.10 %** |
165
+ | **3-bit** | 368 GB | **1.8249** | **+9.50 %** |
166
+ | **2-bit** | 322 GB | **2.6385** | **+58.3 %** |
167
+
168
+ `6-bit` scoring a hair *below* the reference is sampling noise at this corpus size, not
169
+ an improvement β€” read it as "indistinguishable from FP8."
170
+
171
+ ### KL Divergence & Top-1 Token Agreement
172
+
173
+ KLD is `KL(ref β€– quant)` per token against the FP8 reference distribution, Top-1 is how
174
+ often the build's argmax matches the reference's. Lower KLD and higher Top-1 = closer to
175
+ the original. Same corpus and token budget as the PPL table.
176
+
177
+ | Build | Size | Mean KLD | KLD p95 | Top-1 agreement |
178
+ |---|---:|---:|---:|---:|
179
+ | **FP8 (ref)** | 756 GB | β€” | β€” | 100 % |
180
+ | **6-bit** | 671 GB | **0.0295** | 0.1629 | **96.39 %** |
181
+ | **4-bit** | 459 GB | **0.0574** | 0.3049 | **95.46 %** |
182
+ | **3-bit** | 368 GB | **0.1668** | 0.9764 | **90.43 %** |
183
+ | **2-bit** | 322 GB | **0.5272** | 2.7405 | **80.18 %** |
184
+
185
+ All three measurements β€” weight fidelity, perplexity, and KLD/Top-1 β€” agree on the
186
+ ordering and on where the cliff is: `6-bit` is effectively lossless, `4-bit` costs about
187
+ 2 % perplexity for 43 % less memory, `3-bit` degrades gently, and `2-bit` is a large
188
+ step down (+58 % PPL, 1 token in 5 disagreeing with the reference). Pick `2-bit` for
189
+ fit, not for quality.
190
+
191
+ > **Scope of these numbers.** This is a 4,092-token quick evaluation, enough to rank the
192
+ > builds and size the gap, but a small sample. The full-corpus suite (2048 Γ— 12) and the
193
+ > free-running generation gate below have not been run against these builds yet.
194
+
195
+ ### Long-Context Generation Gate
196
+
197
+ Teacher-forced metrics can look fine on a build that loops in a real chat, so the
198
+ pipeline also has a **free-running greedy generation gate**: long prompts, cycle
199
+ detection and distinct-4, compared against the FP8 reference. A build fails if it
200
+ degenerates where the reference does not.
201
+
202
+ **Not yet run for these builds** β€” the reference outputs exist, the per-build runs do
203
+ not. Treat the `2-bit` build in particular as unvalidated for long-form generation until
204
+ this gate has passed; that is exactly the failure mode the teacher-forced tables above
205
+ cannot see.
206
+
207
+ ### Build Verification
208
+
209
+ Independent of quality, every build passed a structural release gate before upload:
210
+
211
+ - **accounting** β€” 175,242 tensors on disk, 58,224 quantized modules, `weight`/`scales`/`biases` triplets all paired
212
+ - **dtype preservation** β€” kept tensors byte-identical in their source dtype (FP32 router bias stays FP32; FP8 `keep` goes through a proper block dequant, never a raw cast)
213
+ - **index integrity** β€” `model.safetensors.index.json` resolves every tensor; `total_size` matches the shards on disk
214
+ - **config ↔ map reconstruction** β€” the 699 per-module overrides reproduce the full per-tensor map exactly
215
+ - **spot dequant** β€” randomly sampled tensors per role dequantized and compared against the golden FP8 values
216
+ - **runtime skeleton** β€” mlx-vlm's `glm_moe_dsa` module tree vs the post-sanitize key set: **1497/1497**, zero missing, zero extra
217
+
218
+ ---
219
+
220
+ ## Usage
221
+
222
+ ### Hosted API β€” No Download
223
+
224
+ The full-precision model is live on OrcaRouter as **`z-ai/glm-5.3`** β€” 1M context, 128K max output, $1.26 / $3.96 per 1M input / output tokens:
225
+
226
+ ```python
227
+ import os
228
+ from openai import OpenAI
229
+
230
+ client = OpenAI(
231
+ base_url="https://api.orcarouter.ai/v1",
232
+ api_key=os.environ["ORCAROUTER_API_KEY"],
233
+ )
234
+
235
+ response = client.chat.completions.create(
236
+ model="z-ai/glm-5.3",
237
+ messages=[{"role": "user", "content": "Refactor this module and explain the tradeoffs."}],
238
+ )
239
+ print(response.choices[0].message.content)
240
+ ```
241
+
242
+ **https://www.orcarouter.ai/models/z-ai/glm-5.3**
243
+
244
+ ### Run it Locally (mlx-vlm)
245
+
246
+ > **Use `mlx-vlm`, not `mlx-lm`.** GLM-5.3 is a text-only model, but as of **mlx-lm 0.31.3** the `glm_moe_dsa` implementation builds an indexer for *every* layer, while this checkpoint shares one indexer across four layers (`indexer_types`) β€” 285 tensors come up missing. **mlx-vlm 0.6.17** implements the shared-indexer layout and loads these builds as-is. Check for mlx-lm support before switching back.
247
+
248
+ ```bash
249
+ pip install -U "mlx-vlm>=0.6.17"
250
+ ```
251
+
252
+ The repo root is the 4-bit build, so the recommended default needs no subfolder β€” the excludes are what stop `hf download` from also pulling the four variant folders:
253
+
254
+ ```bash
255
+ hf download orcarouter/GLM-5.3-MLX --local-dir ./GLM-5.3-MLX \
256
+ --exclude "2-bit/*" "3-bit/*" "4-bit/*" "6-bit/*"
257
+
258
+ python -m mlx_vlm.generate --model ./GLM-5.3-MLX \
259
+ --prompt "Write a Rust function that merges overlapping intervals." --max-tokens 512
260
+ ```
261
+
262
+ To pick a different precision, download just that subfolder and load it from the local path:
263
+
264
+ ```bash
265
+ hf download orcarouter/GLM-5.3-MLX --include "6-bit/*" --local-dir ./GLM-5.3-MLX
266
+
267
+ python -m mlx_vlm.generate --model ./GLM-5.3-MLX/6-bit \
268
+ --prompt "Write a Rust function that merges overlapping intervals." --max-tokens 512
269
+ ```
270
+
271
+ Python API:
272
+
273
+ ```python
274
+ from mlx_vlm import load, generate
275
+ from mlx_vlm.prompt_utils import apply_chat_template
276
+
277
+ model, processor = load("./GLM-5.3-MLX") # repo root == 4-bit
278
+ prompt = apply_chat_template(processor, model.config, "Explain MLA vs GQA in three sentences.")
279
+
280
+ print(generate(model, processor, prompt, max_tokens=512, verbose=True))
281
+ ```
282
+
283
+ **Reasoning effort.** GLM-5.3's chat template takes a `reasoning_effort` variable β€” `low`, `high`, or `max` (the default when unset) β€” emitted as a system directive, plus a `clear_thinking` flag that strips prior `<think>` blocks from the history. Both pass straight through `apply_chat_template`:
284
+
285
+ ```python
286
+ prompt = apply_chat_template(processor, model.config, "Port this service to async.",
287
+ reasoning_effort="low")
288
+ ```
289
+
290
+ Tool calling is in the template too (`<tool_call>` / `<arg_key>` blocks, `tools=[...]`).
291
+
292
+ > **Long context.** `max_position_embeddings` is **1,048,576** (`rope_theta` 8e6). The KV cache, not the weights, is what will bite you at those lengths β€” budget for it, or cap it with `--max-kv-size` / quantize it with `--kv-bits`.
293
+ >
294
+ > On Apple Silicon the Metal backend is used automatically. On the Linux **CUDA** backend install `mlx[cuda]` and set `MLX_CUDA_USE_CUDNN_SDPA=0`.
295
+
296
+ ---
297
+
298
+ ## 🐳 Run it with OrcaCode Review
299
+
300
+ [Website](https://www.orcarouter.ai) Β· [GitHub](https://github.com/Continuum-AI-Corp/Orca-Code-Review)
301
+
302
+ **Models are only half the system.**
303
+
304
+ [**OrcaCode Review**](https://github.com/Continuum-AI-Corp/Orca-Code-Review) turns every model listed on [**OrcaRouter**](https://www.orcarouter.ai) into a production code-review agent:
305
+
306
+ - reviews every PR
307
+ - finds security + correctness issues
308
+ - posts inline findings
309
+ - P0/P1 can block merges
310
+ - swap models anytime
311
+
312
+ **Open model. Open harness. Open bill.**
313
+
314
+ - Website β€” https://www.orcarouter.ai
315
+ - GitHub β€” https://github.com/Continuum-AI-Corp/Orca-Code-Review
316
+
317
+ ---
318
+
319
+ ## GLM-5.3
320
+
321
+ > Available full-precision on the OrcaRouter API as **`z-ai/glm-5.3`** β€”
322
+ > **https://www.orcarouter.ai/models/z-ai/glm-5.3**
323
+
324
+ GLM-5.3 is Z.AI (Zhipu AI)'s flagship model for **complex software engineering and long-horizon agentic tasks** β€” roughly **50 % better at coding than its predecessor**, tuned for repo-scale work and autonomous engineering loops, with tool calling and JSON output over an OpenAI-compatible API.
325
+
326
+ ### Model Overview
327
+
328
+ - **Type:** Mixture-of-Experts Causal LM (`glm_moe_dsa`, `GlmMoeDsaForCausalLM`)
329
+ - **Parameters:** **753B total** Β· **~39B active** per token (22.6B routed + 16.7B always-on; 743B after the MTP layer is dropped)
330
+ - **Experts:** 256 routed + 1 shared, **top-8** routing, sigmoid scoring with `e_score_correction_bias`, single group, `routed_scaling_factor` 2.5
331
+ - **Layers:** 78 (3 dense + 75 MoE), plus 1 MTP layer (dropped in these builds)
332
+ - **Attention:** **MLA** β€” `q_lora_rank` 2048, `kv_lora_rank` 512, 64 heads, `qk_nope` 192 + `qk_rope` 64, `v_head_dim` 256 β€” with a **DeepSeek-style sparse-attention indexer** (`index_topk` 2048, 32 index heads) built on every 4th layer and shared by the three that follow
333
+ - **Precision (base release):** FP8 (block-wise `e4m3`, 128Γ—128), dynamic activation scheme
334
+ - **Context:** 1,048,576 tokens Β· vocab 154,880
335
+ - **Modality:** text
336
+
337
+ ### Best Practices
338
+
339
+ - **Pick a precision:** `6-bit` for near-lossless, `4-bit` (repo root) as the everyday default, `3-bit` when memory is the binding constraint, `2-bit` only when nothing else fits β€” the cosine table shows the cliff between 3 and 2 bits, and coding/agentic work is where it shows up first.
340
+ - **Sampling:** follow the official GLM-5.3 guidance. The shipped `generation_config.json` is `temperature` 1.0, `top_p` 0.95; long-horizon agentic and coding tasks want generous `max-tokens` headroom.
341
+ - **Reasoning effort:** leave it at the default `max` for hard engineering work; drop to `low` for latency-sensitive turns.
342
+ - **Long context:** budget KV, not just weights β€” at 1M tokens the cache dwarfs the difference between two of these builds.
343
+ - **Or skip the download:** the unquantized model is served at full precision on the [OrcaRouter API](https://www.orcarouter.ai/models/z-ai/glm-5.3) as `z-ai/glm-5.3`.
344
+
345
+ ---
346
+
347
+ ## Build Provenance
348
+
349
+ | | |
350
+ |---|---|
351
+ | Source | `zai-org/GLM-5.3` (FP8, 141 shards, 756 GB) |
352
+ | Quantized | 2026-08-28 |
353
+ | Toolchain | MLX 0.32.2, safetensors 0.8.0, NumPy 2.5.2 |
354
+ | Method | OrcaSAQ β€” calibration-free, role-based mixed precision |
355
+ | Per-build files | 140 shards + `config.json`, `quantization_map.json`, `build_manifest.json`, `fidelity_summary.json`, tokenizer, chat template |
356
+
357
+ Each folder carries its own `build_manifest.json` (exact recipe, source path, dropped-tensor count, toolchain versions) and `fidelity_summary.json` (per-role cosine/SNR with the five worst tensors named), so any claim in this card can be checked against the build itself.
358
+
359
+ ---
360
+
361
+ ## Citation
362
+
363
+ ```bibtex
364
+ @misc{glm5team2026glm5vibecodingagentic,
365
+ title={GLM-5: from Vibe Coding to Agentic Engineering},
366
+ author={GLM-5-Team and Aohan Zeng and Xin Lv and Zhenyu Hou and Zhengxiao Du and others},
367
+ year={2026},
368
+ eprint={2602.15763},
369
+ archivePrefix={arXiv},
370
+ primaryClass={cs.LG},
371
+ url={https://arxiv.org/abs/2602.15763},
372
+ }
373
+ ```
374
+
375
+ ## License
376
+
377
+ Inherited from [`zai-org/GLM-5.3`](https://huggingface.co/zai-org/GLM-5.3) β€” an MIT-style grant (use, modify, distribute, fine-tune, sell) with one added condition: operators of a **Model-as-a-Service** business whose aggregate revenue exceeds **US$10B over any 12 consecutive months** must pass a Z.AI security review before commercial use. The full text ships as [`LICENSE`](./LICENSE) in this repo. Quantization does not change the underlying license obligations.