HelloSun commited on
Commit
c1fa642
·
1 Parent(s): cb7e361

README: usage instructions, features, and real test-environment details

Browse files
Files changed (1) hide show
  1. README.md +147 -0
README.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # openPangu-2.0-Flash support for llama.cpp v0.7.0
2
+
3
+ This repository contains a patch that adds support for **openPangu-2.0-Flash**
4
+ (92B MoE, ~6B active parameters, 512K context) to the latest llama.cpp release
5
+ **v0.7.0** (commit `620d2225cc436ab0b001e3200e590e3b286ef9ab`, 2026-10-15).
6
+
7
+ The support was ported from
8
+ [mrexodia/llama.cpp-openPangu-2.0-Flash](https://github.com/mrexodia/llama.cpp-openPangu-2.0-Flash)
9
+ (which tracks an older llama.cpp base) and rebased on top of v0.7.0.
10
+
11
+ Files:
12
+
13
+ - `llama.cpp-openpangu-v0.7.0.diff` — the full patch (40 files, +2845 / −49)
14
+ - `patch.sh` — downloads the pinned llama.cpp commit, applies the patch and
15
+ prints build/run instructions
16
+
17
+ ## 中文說明
18
+
19
+ 本 repo 是將 openPangu-2.0-Flash(92B MoE、約 6B 激活參數、512K 上下文)
20
+ 的 llama.cpp 支援,從 mrexodia 的 fork 移植到最新的 llama.cpp **v0.7.0** 上。
21
+
22
+ 用法:
23
+
24
+ 1. 執行 `./patch.sh`(會自動下載 v0.7.0 原始碼並套用 patch)
25
+ 2. `cd llama.cpp-620d2225cc436ab0b001e3200e590e3b286ef9ab`
26
+ 3. `cmake -B build -S . -DCMAKE_BUILD_TYPE=Release && cmake --build build -j`
27
+ 4. 下載 GGUF 模型(見下方連結)後即可執行 `llama-cli` / `llama-server`
28
+
29
+ ## What is included
30
+
31
+ - The `openpangu-v2` architecture: absorbed MLA attention, DSA sparse attention
32
+ (lightning-indexer top-2048 selection on the global layers), per-layer
33
+ sliding-window attention via a hybrid iSWA cache, 4-stream manifold
34
+ hyper-connections (mHC), MoME causal convolutions with recurrent cross-batch
35
+ state, and 128 learned cache-resident attention sinks per layer
36
+ - Fused CPU/CUDA kernels for the mHC mixing chain (`GGML_OP_SINKHORN`,
37
+ `GGML_OP_HC_MIX`), with automatic fallback to the unfused ops on backends
38
+ without the kernels
39
+ - Gather-based sparse attention at decode: DSA layers attend only the top-2048
40
+ selected tokens (plus sinks), with a fused indexer-scoring kernel
41
+ (`GGML_OP_DSA_SCORE`)
42
+ - Fused DSA indexer scoring at prefill (tiled kernel that skips the multi-GB
43
+ scoring intermediate) plus a radix-select top-k for `GGML_OP_TOP_K`
44
+ - Multi-token-prediction self-speculative decoding (`--spec-type draft-mtp`,
45
+ with the split MTP draft GGUF)
46
+ - Chat support: tool calling and ` thinking` reasoning parsing for the openPangu
47
+ template
48
+ - HF → GGUF conversion (`conversion/pangu.py`) and a base/MTP split tool
49
+ (`conversion/split_pangu_mtp.py`)
50
+
51
+ Ported and adapted to v0.7.0 APIs, plus fixes on top of the original fork:
52
+
53
+ - adapted to the v0.7.0 common chat parser API (`build_chat_peg_parser`),
54
+ per-layer `n_ff_exp()`, and the new `build_attn_mha(..., n_kv_max, ...)`
55
+ signature
56
+ - CPU AMX fix: the AMX weight packer only implements 2D layouts; batched
57
+ (3D/4D) quantized weights — e.g. the MLA `wk_b`/`wv_b` tensors — were
58
+ corrupted when routed through the AMX extra buffer, producing gibberish
59
+ output. The AMX backend now rejects batched tensors and they run on the
60
+ plain CPU path
61
+ - the absorbed-MLA `wk_b`/`wv_b` inputs are kept contiguous so they are also
62
+ correct with weight repacking on other backends
63
+
64
+ ## Requirements
65
+
66
+ - A C/C++ build environment (CMake ≥ 3.14, C++17 compiler)
67
+ - No GPU required (CPU-only works); CUDA/ Metal/ Vulkan also supported
68
+ - Get the GGUF models at
69
+ [mrexodia/openPangu-2.0-Flash-GGUF](https://huggingface.co/mrexodia/openPangu-2.0-Flash-GGUF):
70
+ - `openPangu-2.0-Flash-base-Q3_K_M.gguf` — 40.7 GiB
71
+ - `openPangu-2.0-Flash-base-Q4_K_M.gguf` — 51.5 GiB
72
+ - `openPangu-2.0-Flash-base-Q8_0.gguf` — 90.8 GiB
73
+ - `openPangu-2.0-Flash-base-BF16.gguf` — 170.7 GiB
74
+ - `openPangu-2.0-Flash-mtp-Q8_0.gguf` — 9.2 GiB (optional MTP head)
75
+
76
+ ## Quick start
77
+
78
+ ```sh
79
+ ./patch.sh
80
+ cd llama.cpp-620d2225cc436ab0b001e3200e590e3b286ef9ab
81
+ cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
82
+ cmake --build build -j --target llama-cli llama-server
83
+ ```
84
+
85
+ CUDA build:
86
+
87
+ ```sh
88
+ cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON
89
+ ```
90
+
91
+ ## Run
92
+
93
+ ```sh
94
+ ./build/bin/llama-cli -m openPangu-2.0-Flash-base-Q3_K_M.gguf -c 65536 --jinja -t $(nproc)
95
+
96
+ ./build/bin/llama-server -m openPangu-2.0-Flash-base-Q3_K_M.gguf \
97
+ -c 65536 --jinja --host 0.0.0.0 --port 8080
98
+ ```
99
+
100
+ Context scales up to `-c 524288`; the compressed MLA KV cache needs only ~12 GB
101
+ at the full 512K.
102
+
103
+ ### Multi-token prediction (self-speculative decoding)
104
+
105
+ ```sh
106
+ ./build/bin/llama-cli -m openPangu-2.0-Flash-base-Q3_K_M.gguf \
107
+ --spec-draft-model openPangu-2.0-Flash-mtp-Q8_0.gguf \
108
+ --spec-type draft-mtp -c 65536 --jinja
109
+ ```
110
+
111
+ Notes:
112
+
113
+ - The MTP draft adds ~10 GB of RAM usage on top of the base model
114
+ - On CPUs with AMX, weight repacking (`--repack`, enabled by default) costs
115
+ ~16 GiB of extra RAM; if the combined footprint does not fit, run with `-nr`
116
+ (no repack)
117
+ - On CPU-only setups the draft overhead can make generation slower than plain
118
+ decoding — measure on your hardware (`llama-bench` does not support draft
119
+ models; use `llama-cli` and compare the reported t/s)
120
+
121
+ ## Test environment(測試環境)
122
+
123
+ All performance numbers below were measured on a real machine:
124
+
125
+ - **CPU**: Intel Xeon Platinum 8559C (Emerald Rapids, supports AMX); the test
126
+ container is capped at **16 vCPUs** (host has 2 sockets × 48 cores × 2 SMT)
127
+ - **RAM**: 2.0 TiB host; the test environment enforces a **64 GiB per-process
128
+ memory cap**, which is why all testing used the 40.7 GiB `Q3_K_M` quant
129
+ - **GPU**: none — CPU-only inference, 16 threads (`-t 16`)
130
+ - **OS/toolchain**: Linux, gcc 14.2.0, CMake 3.31.6
131
+ - **Model**: `openPangu-2.0-Flash-base-Q3_K_M.gguf` (40.72 GiB, 91.6 B params)
132
+
133
+ Measured resident memory of `llama-cli` with this model (`-c 512`, `-n 1`):
134
+
135
+ | configuration | peak RSS |
136
+ |---|---|
137
+ | default (AMX weight repacking enabled) | ~57.1 GiB |
138
+ | `-nr` (no repack) | ~41.2 GiB |
139
+ | `-nr` + MTP draft (Q8_0) | ~52 GiB |
140
+ | default + MTP draft (Q8_0) | exceeds 64 GiB — could not run under the test cap |
141
+
142
+ ## Tests
143
+
144
+ - `test-backend-ops -b CPU -o SINKHORN -o HC_MIX -o DSA_SCORE -o TOP_K`:
145
+ 534/534 tests pass
146
+ - `test-chat`, `test-chat-template`, `test-chat-peg-parser`,
147
+ `test-chat-auto-parser`: all pass