Text Generation
cortiq
English
Russian
Chinese
cmf
quantized
q4tp
Mixture of Experts
code
expert-pruning
cuda
hy4-flash
Instructions to use infosave/Hy4-flash-Fast-Code-cmf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- cortiq
How to use infosave/Hy4-flash-Fast-Code-cmf with cortiq:
# one Rust binary, no additional dependencies cargo install cortiq-cli # or a prebuilt binary from github.com/infosave2007/cmf/releases hf download infosave/Hy4-flash-Fast-Code-cmf --include "*.cmf" --local-dir . ls *.cmf # some repos ship more than one quantization
cortiq run FILE.cmf --prompt "What is the capital of France?"
cortiq serve FILE.cmf --port 8080 # OpenAI-compatible server
- Notebooks
- Google Colab
- Kaggle
cortiq 0.9.8: the q4 file (dense trunk at 4 bits), speeds, card
Browse files- README.md +122 -86
- assets/fc_cuda_en.png +0 -0
- assets/fc_cuda_ru.png +0 -0
- assets/fc_cuda_zh.png +0 -0
- hy4-flash-fast-code-q4.cmf.sha256 +1 -0
README.md
CHANGED
|
@@ -25,13 +25,13 @@ language:
|
|
| 25 |
# Hy4-flash Fast Code — CMF
|
| 26 |
|
| 27 |
[Tencent Hy4-flash](https://huggingface.co/tencent/Hy4-flash) cut for code: 256 of the 512 routed experts of every
|
| 28 |
-
layer,
|
| 29 |
-
|
| 30 |
|
| 31 |
-
- **Speed, CUDA:**
|
| 32 |
-
memory; the full model 48.0 / 11.9 / 8.9 on the same
|
| 33 |
-
|
| 34 |
-
|
| 35 |
- **The router stays whole.** It still chooses 16 of all 512 experts with the full model's weights; a pick of a
|
| 36 |
dropped expert adds nothing and the kept picks keep their weights.
|
| 37 |
|
|
@@ -41,15 +41,24 @@ engine with no Python and no ML framework.
|
|
| 41 |
|
| 42 |
```bash
|
| 43 |
cargo install cortiq-cli --features cuda
|
| 44 |
-
hf download infosave/Hy4-flash-Fast-Code-cmf hy4-flash-fast-code.cmf hy4-flash-fast-code.cmf.sha256 --local-dir .
|
| 45 |
-
sha256sum -c hy4-flash-fast-code.cmf.sha256
|
| 46 |
-
CMF_GPU=cuda cortiq run hy4-flash-fast-code.cmf --prompt "Write a Rust function that parses an ISO 8601 date." --greedy --no-think
|
| 47 |
```
|
| 48 |
|
| 49 |
-
cortiq 0.9.
|
| 50 |
-
toolkit at build time). The
|
| 51 |
below the whole file the routed experts live in host memory (the RAM tier) and the card keeps the hot ones; the
|
| 52 |
-
Engram tables are read from the page cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
## How it was cut
|
| 55 |
|
|
@@ -60,7 +69,9 @@ Engram tables are read from the page cache (63 GB).
|
|
| 60 |
Σ (weight · ‖output‖)² were kept. On held-out tokens this leaves 5.4 % of a layer's routed output missing,
|
| 61 |
against 8.6 % for the most often picked 256.
|
| 62 |
3. `CMF_DEFRAG_ABSENT=1 cortiq moe-defrag --keep 256`: the other experts are left out of the file, the kept ones keep
|
| 63 |
-
their numbers, the router and its selection bias stay whole.
|
|
|
|
|
|
|
| 64 |
|
| 65 |
Why the router stays whole: a plain cut lets the router choose among the kept experts only, so a pick of a dropped
|
| 66 |
expert falls to another one and the weights renormalize over the rest. Hy4-flash's experts do not stand in for
|
|
@@ -71,39 +82,40 @@ code more: perplexity on fresh code 9.75 for the plain cut of the same 256 exper
|
|
| 71 |
|
| 72 |
| model | fresh code | Rust source | HumanEval pass@1 |
|
| 73 |
|---|---:|---:|---:|
|
| 74 |
-
|
|
|
|
|
| 75 |
| plain cut of the same experts | 9.75 | 4.31 | — |
|
| 76 |
| full `q4tp` (512 experts) | 8.42 | 3.92 | 93.9 % |
|
| 77 |
|
| 78 |
Perplexity, windows of 512 tokens on the card's prompt graph: code written after the model's release (16 windows),
|
| 79 |
Rust source (8). HumanEval: 164 problems through `cortiq serve`, greedy, thinking off.
|
| 80 |
|
| 81 |
-
**Long code
|
| 82 |
|
| 83 |
-

|
| 102 |
|
| 103 |
## Server
|
| 104 |
|
| 105 |
```bash
|
| 106 |
-
CMF_GPU=cuda cortiq serve hy4-flash-fast-code.cmf --port 8080 --host 127.0.0.1
|
| 107 |
curl http://localhost:8080/v1/chat/completions -H 'Content-Type: application/json' \
|
| 108 |
-d '{"model":"hy4-fast-code","messages":[{"role":"user","content":"Write a binary search in Python."}],"max_tokens":512}'
|
| 109 |
```
|
|
@@ -113,7 +125,7 @@ port.
|
|
| 113 |
|
| 114 |
## License
|
| 115 |
|
| 116 |
-
The weights are Tencent's, under the [Tencent Hy License](LICENSE) (a copy is in this repository).
|
| 117 |
modified form: converted to CMF, quantized and cut to 256 routed experts a layer as described above.
|
| 118 |
|
| 119 |
---
|
|
@@ -121,13 +133,13 @@ modified form: converted to CMF, quantized and cut to 256 routed experts a layer
|
|
| 121 |
## Документация на русском
|
| 122 |
|
| 123 |
[Tencent Hy4-flash](https://huggingface.co/tencent/Hy4-flash), урезанная под код: 256 из 512 маршрутизируемых
|
| 124 |
-
экспертов каждого слоя,
|
| 125 |
-
|
| 126 |
|
| 127 |
-
- **Скорость, CUDA:**
|
| 128 |
-
памяти карты; полная модель на
|
| 129 |
-
|
| 130 |
-
|
| 131 |
- **Роутер остаётся целым.** Он по-прежнему выбирает 16 из всех 512 экспертов с весами полной модели; выбор
|
| 132 |
выброшенного эксперта ничего не добавляет, а ост��вшиеся выборы сохраняют свои веса.
|
| 133 |
|
|
@@ -135,15 +147,24 @@ modified form: converted to CMF, quantized and cut to 256 routed experts a layer
|
|
| 135 |
|
| 136 |
```bash
|
| 137 |
cargo install cortiq-cli --features cuda
|
| 138 |
-
hf download infosave/Hy4-flash-Fast-Code-cmf hy4-flash-fast-code.cmf hy4-flash-fast-code.cmf.sha256 --local-dir .
|
| 139 |
-
sha256sum -c hy4-flash-fast-code.cmf.sha256
|
| 140 |
-
CMF_GPU=cuda cortiq run hy4-flash-fast-code.cmf --prompt "Напиши на Rust функцию разбора даты ISO 8601." --greedy --no-think
|
| 141 |
```
|
| 142 |
|
| 143 |
-
Нужен cortiq 0
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
### Как урезали
|
| 149 |
|
|
@@ -155,127 +176,142 @@ CUDA 12.x, для сборки CUDA не нужна). Файл работает
|
|
| 155 |
Σ (вес · ‖выход‖)². На отложенных токенах это теряет 5,4 % маршрутизируемого выхода слоя против 8,6 % у 256
|
| 156 |
самых часто выбираемых.
|
| 157 |
3. `CMF_DEFRAG_ABSENT=1 cortiq moe-defrag --keep 256`: остальные эксперты не попадают в файл, оставшиеся сохраняют
|
| 158 |
-
номера, роутер и его смещение выбора остаются целыми.
|
|
|
|
|
|
|
| 159 |
|
| 160 |
Почему роутер целый: обычная нарезка даёт роутеру выбирать только среди оставшихся экспертов — выбор выброшенного
|
| 161 |
переходит к другому, а веса перенормируются. Эксперты Hy4-flash не заменяют друг друга (лучший оставшийся заменитель
|
| 162 |
-
восстанавливает выход выброшенного хуже, чем ноль), и это сильнее бьёт по коду: перплексия на свежем коде
|
| 163 |
-
|
| 164 |
|
| 165 |
### Качество
|
| 166 |
|
| 167 |
| модель | свежий код | код на Rust | HumanEval pass@1 |
|
| 168 |
|---|---:|---:|---:|
|
| 169 |
-
|
|
|
|
|
| 170 |
| обычная нарезка тех ��е экспертов | 9,75 | 4,31 | — |
|
| 171 |
| полная `q4tp` (512 экспертов) | 8,42 | 3,92 | 93,9 % |
|
| 172 |
|
| 173 |
Перплексия, окна по 512 токенов на графе промпта карты: код, написанный после выхода модели (16 окон), исходники на
|
| 174 |
Rust (8). HumanEval: 164 задачи через `cortiq serve`, жадно, без размышлений.
|
| 175 |
|
| 176 |
-
**Длинный код
|
| 177 |
|
| 178 |
-

|
| 197 |
|
| 198 |
### Сервер
|
| 199 |
|
| 200 |
```bash
|
| 201 |
-
CMF_GPU=cuda cortiq serve hy4-flash-fast-code.cmf --port 8080 --host 127.0.0.1
|
| 202 |
```
|
| 203 |
|
| 204 |
OpenAI-совместимый API (`/v1/chat/completions`, `/v1/completions`, потоковый вывод) и веб-панель на том же порту.
|
| 205 |
|
| 206 |
### Лицензия
|
| 207 |
|
| 208 |
-
Веса принадлежат Tencent и распространяются по [Tencent Hy License](LICENSE) (копия в этом репозитории). Эт
|
| 209 |
-
изменённая форма: конвертирован в CMF, квантован и урезан до 256 маршрутизируемых экспертов на слой, как описано
|
|
|
|
| 210 |
|
| 211 |
---
|
| 212 |
|
| 213 |
## 中文说明
|
| 214 |
|
| 215 |
-
为代码裁剪的 [Tencent Hy4-flash](https://huggingface.co/tencent/Hy4-flash):每层 512 个路由专家保留 256 个,
|
| 216 |
-
一个 111.7 GB 的 [CMF](https://github.com/infosave2007/cmf) 文件,供 `cortiq` 使用——一个不依赖 Python 和机器学习框架的 Rust 推理引擎。
|
| 217 |
|
| 218 |
-
- **速度(CUDA):** RTX PRO 6000 上
|
| 219 |
-
- **代码:**
|
| 220 |
- **路由器保持完整。** 它仍以完整模型的权重从全部 512 个专家中选出 16 个;选中被删除的专家时不产生任何贡献,其余选中专家保持原有权重。
|
| 221 |
|
| 222 |
### 快速开始
|
| 223 |
|
| 224 |
```bash
|
| 225 |
cargo install cortiq-cli --features cuda
|
| 226 |
-
hf download infosave/Hy4-flash-Fast-Code-cmf hy4-flash-fast-code.cmf hy4-flash-fast-code.cmf.sha256 --local-dir .
|
| 227 |
-
sha256sum -c hy4-flash-fast-code.cmf.sha256
|
| 228 |
-
CMF_GPU=cuda cortiq run hy4-flash-fast-code.cmf --prompt "用 Rust 写一个解析 ISO 8601 日期的函数。" --greedy --no-think
|
| 229 |
```
|
| 230 |
|
| 231 |
-
需要 cortiq 0.9.
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
### 裁剪方法
|
| 235 |
|
| 236 |
1. 完整的 `q4tp` 模型读取 89 677 个 token:32 768 个 Python 代码 token(Magicoder)、一个较长的编程任务(交互式 three.js 页面)及完整模型的回答,以及裁剪模型对该任务的回答。记录每个路由 FFN 的潜在输入、选择和权重(`cortiq hy4-sfq --capture-only`)。
|
| 237 |
2. 每层计算每个专家在其被选中位置上的输出;保留能量 Σ(权重 · ‖输出‖)² 最大的 256 个专家。在留出的 token 上,这样丢失该层路由输出的 5.4 %,而按选择次数保留 256 个时为 8.6 %。
|
| 238 |
-
3. `CMF_DEFRAG_ABSENT=1 cortiq moe-defrag --keep 256`:其余专家不写入文件,保留的专家保持编号,路由器及其选择偏置保持完整。
|
|
|
|
| 239 |
|
| 240 |
-
为何保持路由器完
|
| 241 |
|
| 242 |
### 质量
|
| 243 |
|
| 244 |
| 模型 | 新代码 | Rust 源码 | HumanEval pass@1 |
|
| 245 |
|---|---:|---:|---:|
|
| 246 |
-
|
|
|
|
|
| 247 |
| 相同专家的普通裁剪 | 9.75 | 4.31 | — |
|
| 248 |
| 完整 `q4tp`(512 专家) | 8.42 | 3.92 | 93.9 % |
|
| 249 |
|
| 250 |
困惑度:显卡提示图上 512 token 窗口,模型发布后编写的代码(16 个窗口),Rust 源码(8 个)。HumanEval:通过 `cortiq serve` 的 164 道题,贪婪解码,关闭思考。
|
| 251 |
|
| 252 |
-
**长代码
|
| 253 |
|
| 254 |
-

|
| 270 |
|
| 271 |
### 服务器
|
| 272 |
|
| 273 |
```bash
|
| 274 |
-
CMF_GPU=cuda cortiq serve hy4-flash-fast-code.cmf --port 8080 --host 127.0.0.1
|
| 275 |
```
|
| 276 |
|
| 277 |
同一端口提供兼容 OpenAI 的 API(`/v1/chat/completions`、`/v1/completions`、流式输出)和网页控制台。
|
| 278 |
|
| 279 |
### 许可证
|
| 280 |
|
| 281 |
-
权重归腾讯所有,遵循 [Tencent Hy License](LICENSE)(本仓库附有副本)。
|
|
|
|
| 25 |
# Hy4-flash Fast Code — CMF
|
| 26 |
|
| 27 |
[Tencent Hy4-flash](https://huggingface.co/tencent/Hy4-flash) cut for code: 256 of the 512 routed experts of every
|
| 28 |
+
layer, in [CMF](https://github.com/infosave2007/cmf) files for `cortiq`, a Rust inference engine with no Python and
|
| 29 |
+
no ML framework.
|
| 30 |
|
| 31 |
+
- **Speed, CUDA:** `hy4-flash-fast-code-q4.cmf` decodes 67.4 tok/s on an RTX PRO 6000, 49.5 tok/s within 24 GB,
|
| 32 |
+
39.8 within 16 GB and 32.6 within 12 GB of card memory; the full 512-expert model 48.0 / 11.9 / 8.9 on the same
|
| 33 |
+
card (cortiq 0.9.7).
|
| 34 |
+
- **Code:** HumanEval pass@1 92.7 % (the full model 93.9 %); perplexity on fresh code 9.63 (8.42).
|
| 35 |
- **The router stays whole.** It still chooses 16 of all 512 experts with the full model's weights; a pick of a
|
| 36 |
dropped expert adds nothing and the kept picks keep their weights.
|
| 37 |
|
|
|
|
| 41 |
|
| 42 |
```bash
|
| 43 |
cargo install cortiq-cli --features cuda
|
| 44 |
+
hf download infosave/Hy4-flash-Fast-Code-cmf hy4-flash-fast-code-q4.cmf hy4-flash-fast-code-q4.cmf.sha256 --local-dir .
|
| 45 |
+
sha256sum -c hy4-flash-fast-code-q4.cmf.sha256
|
| 46 |
+
CMF_GPU=cuda cortiq run hy4-flash-fast-code-q4.cmf --prompt "Write a Rust function that parses an ISO 8601 date." --greedy --no-think
|
| 47 |
```
|
| 48 |
|
| 49 |
+
cortiq 0.9.8 or newer, built with `--features cuda` (CUDA 12.x `libnvrtc` and `libcublas` at run time, no CUDA
|
| 50 |
+
toolkit at build time). The files run on CUDA; Vulkan, DX12 and Metal read them on the host for now (slow). On cards
|
| 51 |
below the whole file the routed experts live in host memory (the RAM tier) and the card keeps the hot ones; the
|
| 52 |
+
Engram tables are read from the page cache.
|
| 53 |
+
|
| 54 |
+
## Files
|
| 55 |
+
|
| 56 |
+
| file | routed experts | attention, shared expert, latent projections | size | use |
|
| 57 |
+
|---|---|---|---:|---|
|
| 58 |
+
| `hy4-flash-fast-code-q4.cmf` | 256 a layer, 4-bit | 4-bit | 108.8 GB | **default**: the fastest |
|
| 59 |
+
| `hy4-flash-fast-code.cmf` | 256 a layer, 4-bit | 8-bit | 111.7 GB | a little more accurate, slower |
|
| 60 |
+
|
| 61 |
+
Both keep the head at 8 bits and the router, the Engram tables and the hyper-connections as released.
|
| 62 |
|
| 63 |
## How it was cut
|
| 64 |
|
|
|
|
| 69 |
Σ (weight · ‖output‖)² were kept. On held-out tokens this leaves 5.4 % of a layer's routed output missing,
|
| 70 |
against 8.6 % for the most often picked 256.
|
| 71 |
3. `CMF_DEFRAG_ABSENT=1 cortiq moe-defrag --keep 256`: the other experts are left out of the file, the kept ones keep
|
| 72 |
+
their numbers, the router and its selection bias stay whole (`hy4-flash-fast-code.cmf`).
|
| 73 |
+
4. `cortiq requant --quant q4tp-dense`: the 8-bit attention, shared expert and latent projections at 4 bits
|
| 74 |
+
(`hy4-flash-fast-code-q4.cmf`): half the bytes of that part a token.
|
| 75 |
|
| 76 |
Why the router stays whole: a plain cut lets the router choose among the kept experts only, so a pick of a dropped
|
| 77 |
expert falls to another one and the weights renormalize over the rest. Hy4-flash's experts do not stand in for
|
|
|
|
| 82 |
|
| 83 |
| model | fresh code | Rust source | HumanEval pass@1 |
|
| 84 |
|---|---:|---:|---:|
|
| 85 |
+
| `hy4-flash-fast-code-q4.cmf` | 9.63 | 4.43 | 92.7 % |
|
| 86 |
+
| `hy4-flash-fast-code.cmf` | **8.97** | **4.22** | **93.3 %** |
|
| 87 |
| plain cut of the same experts | 9.75 | 4.31 | — |
|
| 88 |
| full `q4tp` (512 experts) | 8.42 | 3.92 | 93.9 % |
|
| 89 |
|
| 90 |
Perplexity, windows of 512 tokens on the card's prompt graph: code written after the model's release (16 windows),
|
| 91 |
Rust source (8). HumanEval: 164 problems through `cortiq serve`, greedy, thinking off.
|
| 92 |
|
| 93 |
+
**Long code** (`hy4-flash-fast-code.cmf`). An interactive three.js aquarium as one HTML page (6 400–8 900 tokens): 2 of 4 runs (greedy and three seeds) gave a working page, the full model 6 of 6. The other two are valid JavaScript that misuse three.js (a module import without an importmap; a missing page element).
|
| 94 |
|
| 95 |
+

|
| 96 |
|
| 97 |
## Speed · RTX PRO 6000
|
| 98 |
|
| 99 |
+
Stand: NVIDIA RTX PRO 6000 Blackwell Server Edition (96 GB), 48 CPU cores, 176 GB of RAM, the CUDA backend
|
| 100 |
+
(`CMF_GPU=cuda`), a release build. `cortiq run --greedy --no-think`, 256 tokens after a 1 000-token WikiText-2
|
| 101 |
+
prompt, the file already in the page cache; `CMF_GPU_VRAM_MB` caps the card; the mean of two runs (one within 12 GB).
|
| 102 |
|
| 103 |
+
| limit (`CMF_GPU_VRAM_MB`) | `hy4-flash-fast-code-q4.cmf`, cortiq 0.9.8 | full model (512 experts), cortiq 0.9.7 |
|
| 104 |
+
|---:|---:|---:|
|
| 105 |
+
| 96 GB (whole) | **67.4** tok/s | 48.0 tok/s |
|
| 106 |
+
| 24 GB | **49.5** | 11.9 |
|
| 107 |
+
| 16 GB | **39.8** | 8.9 |
|
| 108 |
+
| 12 GB | **32.6** | — |
|
| 109 |
|
| 110 |
+
Part of the gap within 24 and 16 GB is the host: its page cache holds the 108.8 GB file but not the 150.5 GB full
|
| 111 |
+
model, and there the experts come from host memory. The full model was not measured within 12 GB.
|
|
|
|
| 112 |
|
| 113 |

|
| 114 |
|
| 115 |
## Server
|
| 116 |
|
| 117 |
```bash
|
| 118 |
+
CMF_GPU=cuda cortiq serve hy4-flash-fast-code-q4.cmf --port 8080 --host 127.0.0.1
|
| 119 |
curl http://localhost:8080/v1/chat/completions -H 'Content-Type: application/json' \
|
| 120 |
-d '{"model":"hy4-fast-code","messages":[{"role":"user","content":"Write a binary search in Python."}],"max_tokens":512}'
|
| 121 |
```
|
|
|
|
| 125 |
|
| 126 |
## License
|
| 127 |
|
| 128 |
+
The weights are Tencent's, under the [Tencent Hy License](LICENSE) (a copy is in this repository). These files are a
|
| 129 |
modified form: converted to CMF, quantized and cut to 256 routed experts a layer as described above.
|
| 130 |
|
| 131 |
---
|
|
|
|
| 133 |
## Документация на русском
|
| 134 |
|
| 135 |
[Tencent Hy4-flash](https://huggingface.co/tencent/Hy4-flash), урезанная под код: 256 из 512 маршрутизируемых
|
| 136 |
+
экспертов каждого слоя, файлы [CMF](https://github.com/infosave2007/cmf) для `cortiq` — движка инференса на Rust без
|
| 137 |
+
Python и ML-фреймворков.
|
| 138 |
|
| 139 |
+
- **Скорость, CUDA:** `hy4-flash-fast-code-q4.cmf` декодирует 67,4 ток/с на RTX PRO 6000, 49,5 ток/с в пределах
|
| 140 |
+
24 ГБ, 39,8 — в пределах 16 ГБ и 32,6 — в пределах 12 ГБ памяти карты; полная модель на 512 экспертов на той же
|
| 141 |
+
карте — 48,0 / 11,9 / 8,9 (cortiq 0.9.7).
|
| 142 |
+
- **Код:** HumanEval pass@1 92,7 % (полная модель 93,9 %); перплексия на свежем коде 9,63 (8,42).
|
| 143 |
- **Роутер остаётся целым.** Он по-прежнему выбирает 16 из всех 512 экспертов с весами полной модели; выбор
|
| 144 |
выброшенного эксперта ничего не добавляет, а ост��вшиеся выборы сохраняют свои веса.
|
| 145 |
|
|
|
|
| 147 |
|
| 148 |
```bash
|
| 149 |
cargo install cortiq-cli --features cuda
|
| 150 |
+
hf download infosave/Hy4-flash-Fast-Code-cmf hy4-flash-fast-code-q4.cmf hy4-flash-fast-code-q4.cmf.sha256 --local-dir .
|
| 151 |
+
sha256sum -c hy4-flash-fast-code-q4.cmf.sha256
|
| 152 |
+
CMF_GPU=cuda cortiq run hy4-flash-fast-code-q4.cmf --prompt "Напиши на Rust функцию разбора даты ISO 8601." --greedy --no-think
|
| 153 |
```
|
| 154 |
|
| 155 |
+
Нужен cortiq 0.9.8 или новее, собранный с `--features cuda` (во время работы — `libnvrtc` и `libcublas` из CUDA
|
| 156 |
+
12.x, для сборки CUDA не нужна). Файлы работают на CUDA; Vulkan, DX12 и Metal пока читают их на хосте (медленно). На
|
| 157 |
+
картах меньше файла маршрутизируемые эксперты живут в памяти хоста (RAM-уровень), а карта держит горячих; таблицы
|
| 158 |
+
Engram читаются из страничного кэша.
|
| 159 |
+
|
| 160 |
+
### Файлы
|
| 161 |
+
|
| 162 |
+
| файл | маршрутизируемые эксперты | внимание, общий эксперт, латентные проекции | размер | когда брать |
|
| 163 |
+
|---|---|---|---:|---|
|
| 164 |
+
| `hy4-flash-fast-code-q4.cmf` | 256 на слой, 4 бита | 4 бита | 108,8 ГБ | **по умолчанию**: самый быстрый |
|
| 165 |
+
| `hy4-flash-fast-code.cmf` | 256 на слой, 4 бита | 8 бит | 111,7 ГБ | чуть точнее, медленнее |
|
| 166 |
+
|
| 167 |
+
В обоих голова в 8 битах, роутер, таблицы Engram и гиперсвязи — как в релизе.
|
| 168 |
|
| 169 |
### Как урезали
|
| 170 |
|
|
|
|
| 176 |
Σ (вес · ‖выход‖)². На отложенных токенах это теряет 5,4 % маршрутизируемого выхода слоя против 8,6 % у 256
|
| 177 |
самых часто выбираемых.
|
| 178 |
3. `CMF_DEFRAG_ABSENT=1 cortiq moe-defrag --keep 256`: остальные эксперты не попадают в файл, оставшиеся сохраняют
|
| 179 |
+
номера, роутер и его смещение выбора остаются целыми (`hy4-flash-fast-code.cmf`).
|
| 180 |
+
4. `cortiq requant --quant q4tp-dense`: 8-битные внимание, общий эксперт и латентные проекции — в 4 бита
|
| 181 |
+
(`hy4-flash-fast-code-q4.cmf`): вдвое меньше байт этой части на токен.
|
| 182 |
|
| 183 |
Почему роутер целый: обычная нарезка даёт роутеру выбирать только среди оставшихся экспертов — выбор выброшенного
|
| 184 |
переходит к другому, а веса перенормируются. Эксперты Hy4-flash не заменяют друг друга (лучший оставшийся заменитель
|
| 185 |
+
восстанавливает выход выброшенного хуже, чем ноль), и это сильнее бьёт по коду: перплексия на свежем коде 9,75 у
|
| 186 |
+
обычной нарезки тех же 256 экспертов, 8,97 здесь.
|
| 187 |
|
| 188 |
### Качество
|
| 189 |
|
| 190 |
| модель | свежий код | код на Rust | HumanEval pass@1 |
|
| 191 |
|---|---:|---:|---:|
|
| 192 |
+
| `hy4-flash-fast-code-q4.cmf` | 9,63 | 4,43 | 92,7 % |
|
| 193 |
+
| `hy4-flash-fast-code.cmf` | **8,97** | **4,22** | **93,3 %** |
|
| 194 |
| обычная нарезка тех ��е экспертов | 9,75 | 4,31 | — |
|
| 195 |
| полная `q4tp` (512 экспертов) | 8,42 | 3,92 | 93,9 % |
|
| 196 |
|
| 197 |
Перплексия, окна по 512 токенов на графе промпта карты: код, написанный после выхода модели (16 окон), исходники на
|
| 198 |
Rust (8). HumanEval: 164 задачи через `cortiq serve`, жадно, без размышлений.
|
| 199 |
|
| 200 |
+
**Длинный код** (`hy4-flash-fast-code.cmf`). Интерактивный аквариум на three.js одной HTML-страницей (6 400–8 900 токенов): 2 из 4 запусков (жадный и три сида) дали рабочую страницу, полная модель — 6 из 6. Остальные два — корректный JavaScript с ошибками в использовании three.js (импорт модуля без importmap; обращение к несуществующему элементу страницы).
|
| 201 |
|
| 202 |
+

|
| 203 |
|
| 204 |
### Скорость · RTX PRO 6000
|
| 205 |
|
| 206 |
+
Стенд: NVIDIA RTX PRO 6000 Blackwell Server Edition (96 ГБ), 48 ядер, 176 ГБ памяти, бэкенд CUDA (`CMF_GPU=cuda`),
|
| 207 |
+
релизная сборка. `cortiq run --greedy --no-think`, 256 токенов после промпта WikiText-2 из 1 000 токенов, файл уже
|
| 208 |
+
в страничном кэше; `CMF_GPU_VRAM_MB` ограничивает карту; среднее двух прогонов (в пределах 12 ГБ — один).
|
| 209 |
|
| 210 |
+
| лимит (`CMF_GPU_VRAM_MB`) | `hy4-flash-fast-code-q4.cmf`, cortiq 0.9.8 | полная модель (512 экспертов), cortiq 0.9.7 |
|
| 211 |
+
|---:|---:|---:|
|
| 212 |
+
| 96 ГБ (вся) | **67,4** ток/с | 48,0 ток/с |
|
| 213 |
+
| 24 ГБ | **49,5** | 11,9 |
|
| 214 |
+
| 16 ГБ | **39,8** | 8,9 |
|
| 215 |
+
| 12 ГБ | **32,6** | — |
|
| 216 |
|
| 217 |
+
Часть разрыва в пределах 24 и 16 ГБ — от хоста: его страничный кэш держит файл на 108,8 ГБ, но не полную модель на
|
| 218 |
+
150,5 ГБ, а там эксперты приходят из памяти хоста. Полную модель в пределах 12 ГБ не мерили.
|
|
|
|
| 219 |
|
| 220 |

|
| 221 |
|
| 222 |
### Сервер
|
| 223 |
|
| 224 |
```bash
|
| 225 |
+
CMF_GPU=cuda cortiq serve hy4-flash-fast-code-q4.cmf --port 8080 --host 127.0.0.1
|
| 226 |
```
|
| 227 |
|
| 228 |
OpenAI-совместимый API (`/v1/chat/completions`, `/v1/completions`, потоковый вывод) и веб-панель на том же порту.
|
| 229 |
|
| 230 |
### Лицензия
|
| 231 |
|
| 232 |
+
Веса принадлежат Tencent и распространяются по [Tencent Hy License](LICENSE) (копия в этом репозитории). Эти файлы —
|
| 233 |
+
изменённая форма: конвертированы в CMF, квантованы и урезаны до 256 маршрутизируемых экспертов на слой, как описано
|
| 234 |
+
выше.
|
| 235 |
|
| 236 |
---
|
| 237 |
|
| 238 |
## 中文说明
|
| 239 |
|
| 240 |
+
为代码裁剪的 [Tencent Hy4-flash](https://huggingface.co/tencent/Hy4-flash):每层 512 个路由专家保留 256 个,[CMF](https://github.com/infosave2007/cmf) 文件,供 `cortiq` 使用——一个不依赖 Python 和机器学习框架的 Rust 推理引擎。
|
|
|
|
| 241 |
|
| 242 |
+
- **速度(CUDA):** `hy4-flash-fast-code-q4.cmf` 在 RTX PRO 6000 上解码 67.4 tok/s,显存限制在 24 GB 时 49.5 tok/s,16 GB 时 39.8,12 GB 时 32.6;同一张卡上完整的 512 专家模型为 48.0 / 11.9 / 8.9(cortiq 0.9.7)。
|
| 243 |
+
- **代码:** HumanEval pass@1 92.7 %(完整模型 93.9 %);新代码困惑度 9.63(8.42)。
|
| 244 |
- **路由器保持完整。** 它仍以完整模型的权重从全部 512 个专家中选出 16 个;选中被删除的专家时不产生任何贡献,其余选中专家保持原有权重。
|
| 245 |
|
| 246 |
### 快速开始
|
| 247 |
|
| 248 |
```bash
|
| 249 |
cargo install cortiq-cli --features cuda
|
| 250 |
+
hf download infosave/Hy4-flash-Fast-Code-cmf hy4-flash-fast-code-q4.cmf hy4-flash-fast-code-q4.cmf.sha256 --local-dir .
|
| 251 |
+
sha256sum -c hy4-flash-fast-code-q4.cmf.sha256
|
| 252 |
+
CMF_GPU=cuda cortiq run hy4-flash-fast-code-q4.cmf --prompt "用 Rust 写一个解析 ISO 8601 日期的函数。" --greedy --no-think
|
| 253 |
```
|
| 254 |
|
| 255 |
+
需要 cortiq 0.9.8 或更新版本,并以 `--features cuda` 构建(运行时需要 CUDA 12.x 的 `libnvrtc` 和 `libcublas`,构建时不需要 CUDA)。
|
| 256 |
+
这些文件在 CUDA 上运行;Vulkan、DX12 和 Metal 目前在主机上读取它们(较慢)。显存小于文件时,路由专家放在主机内存(RAM 层),显卡保留热门专家;Engram 表从页缓存读取。
|
| 257 |
+
|
| 258 |
+
### 文件
|
| 259 |
+
|
| 260 |
+
| 文件 | 路由专家 | 注意力、共享专家、潜在投影 | 大小 | 用途 |
|
| 261 |
+
|---|---|---|---:|---|
|
| 262 |
+
| `hy4-flash-fast-code-q4.cmf` | 每层 256 个,4 比特 | 4 比特 | 108.8 GB | **默认**:最快 |
|
| 263 |
+
| `hy4-flash-fast-code.cmf` | 每层 256 个,4 比特 | 8 比特 | 111.7 GB | 略更准确,较慢 |
|
| 264 |
+
|
| 265 |
+
两者的输出头均为 8 比特,路由器、Engram 表和超连接保持原样。
|
| 266 |
|
| 267 |
### 裁剪方法
|
| 268 |
|
| 269 |
1. 完整的 `q4tp` 模型读取 89 677 个 token:32 768 个 Python 代码 token(Magicoder)、一个较长的编程任务(交互式 three.js 页面)及完整模型的回答,以及裁剪模型对该任务的回答。记录每个路由 FFN 的潜在输入、选择和权重(`cortiq hy4-sfq --capture-only`)。
|
| 270 |
2. 每层计算每个专家在其被选中位置上的输出;保留能量 Σ(权重 · ‖输出‖)² 最大的 256 个专家。在留出的 token 上,这样丢失该层路由输出的 5.4 %,而按选择次数保留 256 个时为 8.6 %。
|
| 271 |
+
3. `CMF_DEFRAG_ABSENT=1 cortiq moe-defrag --keep 256`:其余专家不写入文件,保留的专家保持编号,路由器及其选择偏置保持完整(`hy4-flash-fast-code.cmf`)。
|
| 272 |
+
4. `cortiq requant --quant q4tp-dense`:将 8 比特的注意力、共享专家和潜在投影转为 4 比特(`hy4-flash-fast-code-q4.cmf`):这部分每个 token 读取的字节减半。
|
| 273 |
|
| 274 |
+
为何保持路由器完整:普通裁剪让路由器只在保留的专家中选择,被删除专家的选择落到其他专家上,权重在其余专家间重新归一化。Hy4-flash 的专家无法互相替代(最佳替代专家重建被删除专家输出的效果比零还差),这对代码影响更大:同样 256 个专家的普通裁剪新代码困惑度为 9.75,本方法为 8.97。
|
| 275 |
|
| 276 |
### 质量
|
| 277 |
|
| 278 |
| 模型 | 新代码 | Rust 源码 | HumanEval pass@1 |
|
| 279 |
|---|---:|---:|---:|
|
| 280 |
+
| `hy4-flash-fast-code-q4.cmf` | 9.63 | 4.43 | 92.7 % |
|
| 281 |
+
| `hy4-flash-fast-code.cmf` | **8.97** | **4.22** | **93.3 %** |
|
| 282 |
| 相同专家的普通裁剪 | 9.75 | 4.31 | — |
|
| 283 |
| 完整 `q4tp`(512 专家) | 8.42 | 3.92 | 93.9 % |
|
| 284 |
|
| 285 |
困惑度:显卡提示图上 512 token 窗口,模型发布后编写的代码(16 个窗口),Rust 源码(8 个)。HumanEval:通过 `cortiq serve` 的 164 道题,贪婪解码,关闭思考。
|
| 286 |
|
| 287 |
+
**长代码**(`hy4-flash-fast-code.cmf`)。单个 HTML 页面的交互式 three.js 水族箱(6 400–8 900 token):4 次运行(贪婪解码和三个随机种子)中有 2 次生成了可运行的页面,完整模型为 6 次中 6 次。另外两次是语法正确的 JavaScript,但误用了 three.js(没有 importmap 的模块导入;引用了不存在的页面元素)。
|
| 288 |
|
| 289 |
+

|
| 290 |
|
| 291 |
### 速度 · RTX PRO 6000
|
| 292 |
|
| 293 |
+
测试平台:NVIDIA RTX PRO 6000 Blackwell Server Edition(96 GB),48 个 CPU 核心,176 GB 内存,CUDA 后端(`CMF_GPU=cuda`),发布版构建。
|
| 294 |
+
`cortiq run --greedy --no-think`,1000 token 的 WikiText-2 提示后生成 256 token,文件已在页缓存中;`CMF_GPU_VRAM_MB` 限制显存;取两次运行的平均值(12 GB 为一次)。
|
| 295 |
|
| 296 |
+
| 限制(`CMF_GPU_VRAM_MB`) | `hy4-flash-fast-code-q4.cmf`,cortiq 0.9.8 | 完整模型(512 专家),cortiq 0.9.7 |
|
| 297 |
+
|---:|---:|---:|
|
| 298 |
+
| 96 GB(整卡) | **67.4** tok/s | 48.0 tok/s |
|
| 299 |
+
| 24 GB | **49.5** | 11.9 |
|
| 300 |
+
| 16 GB | **39.8** | 8.9 |
|
| 301 |
+
| 12 GB | **32.6** | — |
|
| 302 |
|
| 303 |
+
24 GB 和 16 GB 限制下的差距部分来自主机:其页缓存能容纳 108.8 GB 的文件,但容纳不下 150.5 GB 的完整模型,而此时专家来自主机内存。完整模型未在 12 GB 限制下测量。
|
| 304 |
|
| 305 |

|
| 306 |
|
| 307 |
### 服务器
|
| 308 |
|
| 309 |
```bash
|
| 310 |
+
CMF_GPU=cuda cortiq serve hy4-flash-fast-code-q4.cmf --port 8080 --host 127.0.0.1
|
| 311 |
```
|
| 312 |
|
| 313 |
同一端口提供兼容 OpenAI 的 API(`/v1/chat/completions`、`/v1/completions`、流式输出)和网页控制台。
|
| 314 |
|
| 315 |
### 许可证
|
| 316 |
|
| 317 |
+
权重归腾讯所有,遵循 [Tencent Hy License](LICENSE)(本仓库附有副本)。这些文件为修改形式:转换为 CMF、量化,并按上述方法裁剪为每层 256 个路由专家。
|
assets/fc_cuda_en.png
CHANGED
|
|
assets/fc_cuda_ru.png
CHANGED
|
|
assets/fc_cuda_zh.png
CHANGED
|
|
hy4-flash-fast-code-q4.cmf.sha256
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3203a45512897e77226970314ac6c9a4953f4544318f98effa95f51f1818223c hy4-flash-fast-code-q4.cmf
|