anemll commited on
Commit
84d333f
·
verified ·
1 Parent(s): 9d18cfd

Add model card: download + build + test (--slot8) instructions

Browse files
Files changed (1) hide show
  1. README.md +96 -0
README.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: glm-5.2
4
+ tags:
5
+ - gguf
6
+ - moe
7
+ - glm
8
+ - flash-moe
9
+ - llama.cpp
10
+ - metal
11
+ library_name: llama.cpp
12
+ ---
13
+
14
+ # GLM-5.2 Flash-MoE Sidecar (UD-IQ1_M)
15
+
16
+ SSD-streamed Mixture-of-Experts **expert sidecar** for **GLM-5.2** (Unsloth Dynamic `UD-IQ1_M`),
17
+ built for the **Flash-MoE slot-bank** runtime in the
18
+ [`anemll/flash-llama.cpp`](https://github.com/Anemll/anemll-flash-llama.cpp/tree/GLM-5.2-Moe) fork.
19
+
20
+ The routed experts are stored as per-layer `layer_*.bin` files and streamed from SSD on demand into
21
+ a small resident **slot bank** during decode, so the full MoE runs on a unified-memory Mac without
22
+ keeping every expert in RAM. The dense / shared weights live in a separate small GGUF.
23
+
24
+ ## What's in this repo
25
+
26
+ | Path | Size | Description |
27
+ |------|------|-------------|
28
+ | `dense/model-dense.gguf` | ~15.5 GB | Dense + shared weights, router, attention (the model you pass to `-m`) |
29
+ | `dense/flashmoe-package.json` | — | Flash-MoE package descriptor |
30
+ | `layer_003.bin` … `layer_NNN.bin` | ~213 GB total | Per-layer routed-expert tensors (IQ1_M), streamed on demand |
31
+ | `manifest.json` | — | Sidecar manifest (tensor map, quant types, byte offsets) |
32
+
33
+ **Model facts:** arch `glm-dsa`, 256 routed experts, top-8 per token, 3 leading dense layers,
34
+ `n_embd = 6144`, routed `n_ff = 2048`, experts quantized `IQ1_M`. Layout: `layer_major_whole_tensor`.
35
+
36
+ > Total download is ~**213 GB**. You need a fast SSD; decode is I/O-bound on expert streaming.
37
+
38
+ ## Download
39
+
40
+ ```bash
41
+ hf download anemll/GLM-5.2-sidecar --repo-type model --local-dir ~/Models/GLM-5.2-sidecar
42
+ ```
43
+
44
+ ## Build the runtime (Apple Metal)
45
+
46
+ This sidecar requires the Flash-MoE fork on the **`GLM-5.2-Moe`** branch:
47
+
48
+ ```bash
49
+ git clone -b GLM-5.2-Moe https://github.com/Anemll/anemll-flash-llama.cpp
50
+ cd anemll-flash-llama.cpp
51
+ cmake -B build -DGGML_METAL=ON
52
+ cmake --build build --config Release -j --target llama-cli
53
+ ```
54
+
55
+ ## Run / test
56
+
57
+ ```bash
58
+ ./build/bin/llama-cli --perf \
59
+ -m ~/Models/GLM-5.2-sidecar/dense/model-dense.gguf \
60
+ --moe-mode slot-bank \
61
+ --moe-sidecar ~/Models/GLM-5.2-sidecar/ \
62
+ --moe-verify-sidecar \
63
+ --moe-slot-bank 64 \
64
+ --moe-topk 8 \
65
+ --moe-cache-io-split 2 \
66
+ --moe-prefetch-temporal \
67
+ -fit on \
68
+ -ub 1 -b 64 \
69
+ -ngl 999 \
70
+ -c 512 \
71
+ --seed 123 --temp 0 \
72
+ -p "What is Apple Neural Engine? Answer in one sentence." \
73
+ -n 2000 -st \
74
+ --slot8
75
+ ```
76
+
77
+ ### `--slot8` (fused single-kernel routed FFN)
78
+
79
+ This branch adds `--slot8`, which collapses the whole routed FFN — gate, up, SwiGLU, down, and the
80
+ routed weighted-sum over all selected experts — into a **single fused op** (two Metal kernels,
81
+ IQ1_M) for single-token decode. It reads the resident slot ids once at encode time, so the
82
+ per-expert `mul_mat_id` decode replay / ICB cache is no longer used on that path. Output is
83
+ validated byte-identical to the unfused reference path.
84
+
85
+ Toggles:
86
+ - `--slot8` / `--no-slot8` — enable/disable the fused path (only engages on eligible top-k decode layers).
87
+ - `LLAMA_FLASH_MOE_SLOT8_REFERENCE=1` — force the `mul_mat` reference path (A/B comparison / fallback).
88
+ - `LLAMA_FLASH_MOE_SLOT8_DEBUG=1` — log which layers take the fused path.
89
+
90
+ > Tested on Apple M5 Max (128 GB). `--slot8` is a decode-only fast path; prefill and non-eligible
91
+ > layers use the normal slot-bank route.
92
+
93
+ ## License
94
+
95
+ Derived from **GLM-5.2** (Z.ai / Zhipu AI). Use is subject to the original GLM-5.2 model license;
96
+ this sidecar only repackages those weights for SSD-streamed inference.