Ludovico commited on
Commit
f96283f
·
verified ·
1 Parent(s): 40f9271

README: fixed files table, usage with colibri, integrity checks, measured results

Browse files
Files changed (1) hide show
  1. README.md +73 -58
README.md CHANGED
@@ -1,100 +1,115 @@
1
  ---
2
- pipeline_tag: text-generation
 
 
 
3
  tags:
4
  - wex4
 
5
  - mixture-of-experts
6
  - mxfp4
7
  - expert-weights
 
 
 
 
8
  ---
9
  # WEX4 Expert Containers
10
 
11
- These are expert-weight containers for compatible Mixture-of-Experts (MoE) runtimes, not complete model checkpoints. They do not include the full model, tokenizer, chat template, or inference runtime, and are not loadable with `transformers.from_pretrained()`.
12
 
13
- The container format and the per-record codec are separate layers: WEX4 provides indexed access and integrity checking; WNR3 is an optional custom codec for MXFP4 expert records.
14
 
15
- ## Files
 
16
 
17
- | Path | Model and layout | Expert count | Size | Upstream model license |
18
- |---|---|---:|---:|
19
- | `qwen38-mxfp4/q38_experts.wex` | [Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next), routed MXFP4, WEX4 with RAW records | 24,576 (48 × 512) | 64,251,047,936 bytes (64.25 GB) | [Qwen Community License v1.0](https://huggingface.co/Qwen/Qwen3.8-Flash-Next/blob/main/LICENSE) (`qwen-community-1.0`) |
20
- | `v41-reap/v4_flash_experts.nr3.wex` | [DeepSeek V4.1 Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash), REAP-192, WEX4 with WNR3-CZ records | 7,680 (40 × 192) | 123,312,910,336 bytes (123.31 GB) | [MIT License](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash/blob/main/LICENSE) (`mit`) |
21
- | `provenance/q38_experts.wex.verified.pre-wex4` | Supplied Qwen source-copy SHA-256 note | — | 123 bytes | — |
22
- | `provenance/v4_flash_experts.nr3.wex.verified.pre-wex4` | Supplied V4.1 build/read-back note | — | 177 bytes | — |
23
 
24
- The two containers total about 187.6 GB decimal (174.7 GiB). Allow additional disk space for the runtime, cache, and any local mirrors.
 
 
 
 
 
25
 
26
- ## Container evolution
27
 
28
- | Format | What it adds |
29
- |---|---|
30
- | **WEX1** | Original layout: raw expert records aligned to 4 KiB for direct per-expert reads. |
31
- | **WEX2** | Lossless tiled coding for MXFP4 scale values; FP4 weight bytes stay raw. |
32
- | **WEX3** | Per-record codec support, including WNR2 and WNR3, with the metadata those codecs require. |
33
- | **WEX4** | Self-describing tensor index, a SHA-256 container root, and hashes for records and blobs. It can hold either raw or encoded records; WEX4 is not itself a compression codec. |
34
 
35
- WNR2 and WNR3 are different codecs. WNR2 is the earlier codec 4 used in WEX3; these published containers do not use WNR2. The Qwen file contains RAW records. The V4.1 file contains WNR3-CZ records (codec 5) inside WEX4.
 
 
 
36
 
37
- ## WNR3 codec and size results
38
 
39
- WNR3 is a custom entropy codec designed for MXFP4 expert weights and scales. It uses context-based rANS coding and has a purpose-built GPU decoder. It is not a general-purpose archive format. The WNR3-CZ production variant maps negative zero to positive zero: represented numeric values are preserved, but those zero sign bits are not byte-identical to the source.
 
 
 
 
40
 
41
- Compression figures below compare expert containers for the same DeepSeek V4.1 REAP-192 experts:
42
 
43
- | Encoding | Result relative to raw | Evidence and qualification |
44
- |---|---:|---|
45
- | WNR2, bit-exact | 0.8997×, about 10.03% smaller | Measured full container: 129,905,360,896 B vs 144,389,472,256 B raw. This is historical and is not used by the files in this repository. |
46
- | WNR3, strict bit-lossless | About 0.8819×, about 11.81% smaller | Estimate from held-out experts; not a full-model non-CZ container measurement. |
47
- | WNR3-CZ, value-exact | 0.8540×, about 14.60% smaller | Production container: 123,306,192,896 B before the WEX4 index; the published WEX4 file is 123,312,910,336 B. CZ normalizes the FP4 sign of zero. |
48
 
49
- The Qwen3.8 file is intentionally RAW MXFP4, so it claims no codec compression benefit. Its WEX4 index adds about 26 MB over the prior WEX1 file and supplies integrity metadata and indexed expert records.
50
 
51
- ## Download
 
 
 
 
52
 
53
- Install the Hugging Face CLI and download the full repository:
54
 
55
- ```powershell
56
- hf download Kaira666/Kaira-WEX4-Experts --repo-type model --local-dir .\WEX4-Experts
57
- ```
58
 
59
- You can download either container separately:
60
 
61
- ```powershell
62
- hf download Kaira666/Kaira-WEX4-Experts qwen38-mxfp4/q38_experts.wex --repo-type model --local-dir .\WEX4-Experts
63
- hf download Kaira666/Kaira-WEX4-Experts v41-reap/v4_flash_experts.nr3.wex --repo-type model --local-dir .\WEX4-Experts
 
 
64
  ```
65
 
66
- ## Runtime compatibility and integrity
67
 
68
- Use a runtime that explicitly supports WEX4 version 4.0 and the codec/model family in the selected file. An older WEX/WNR2-only build or a generic Transformers loader cannot read these assets. The Qwen3.8 file needs a WEX4 loader for RAW MXFP4 experts. The DeepSeek V4.1 file also needs WNR3-CZ decoding support and its matching GPU helper.
69
 
70
- In compatible runtimes that expose these settings, set `COLI_WEX_PATH` to the selected file and `COLI_WEX_ROOT` to its verified root. `COLI_WEX_VERIFY=1` enables first-read record hashing where supported. These settings do not add WEX4 support to an incompatible runtime.
 
 
 
 
71
 
72
- A WEX4 whole-file verification checks the header, index, exact file layout, padding, every blob, and every record; encoded records are decoded as part of the check. The root is the SHA-256 of the first 4,064 bytes of the header page. The content digest below is SHA-256 over decoded tensor content and tensor metadata in table order.
73
 
74
- | File | Verified WEX4 root | Content digest | Verification result |
75
- |---|---|---|---|
76
- | `q38_experts.wex` | `db5389f699abb49a164a9e73d925b5b629b0ce6de430a553388ba3e1cae5c0df` | `0d752bbf2d169b611ac79b005f07d0b9152c0591b23b65cbd12e06ea8300ec77` | 24,576 records decoded; all indexed hashes matched |
77
- | `v4_flash_experts.nr3.wex` | `f0f78a84d040a3b336f3abef3cf8b0a36c649deb38586c813e94d35dea3beeb1` | `fb085e127ba980214f106313e9af578b18e5ebac4cde7ecb9730b1a0f78ae512` | 7,680 records decoded; all indexed hashes matched |
78
 
79
- The `.verified.pre-wex4` files are included as supplied provenance notes. The roots and results above apply to the final published WEX4 files.
80
 
81
- ## WEX source and integration
 
 
 
 
82
 
83
- The WEX format, codec implementation, specifications, and reference tools are open source under the [Apache License 2.0](https://github.com/KairaCode/Wex-WRN2/blob/main/LICENSE). The public source repository includes:
84
 
85
- - [WEX4 specification](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/WEX4-SPEC.md)
86
- - [WNR3 codec specification](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/WNR3-SPEC.md)
87
- - [Colibri integration and usage guide](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/COLIBRI-INTEGRATION.md)
88
- - [WEX source repository](https://github.com/KairaCode/Wex-WRN2)
89
 
90
- The Apache-2.0 license applies to the WEX software and documentation in that source repository; it does not replace the upstream licenses of the model weights distributed here.
 
 
91
 
92
  ## Licenses
93
 
94
- This repository contains assets with separate license terms, so no single license is asserted for all files:
95
 
96
- - WEX format, codec implementation, specifications, and reference tools: [Apache License 2.0](https://github.com/KairaCode/Wex-WRN2/blob/main/LICENSE).
97
- - Qwen3.8-Flash-Next model weights: [Qwen Community License v1.0](https://huggingface.co/Qwen/Qwen3.8-Flash-Next/blob/main/LICENSE) (`qwen-community-1.0`).
98
- - DeepSeek V4.1 Flash model weights: [MIT License](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash/blob/main/LICENSE) (`mit`).
99
 
100
- Follow the applicable license for each component.
 
1
  ---
2
+ license: other
3
+ license_name: per-file-see-readme
4
+ license_link: https://huggingface.co/Kaira666/Kaira-WEX4-Experts/blob/main/README.md#licenses
5
+ library_name: wex4
6
  tags:
7
  - wex4
8
+ - wnr3
9
  - mixture-of-experts
10
  - mxfp4
11
  - expert-weights
12
+ - colibri
13
+ base_model:
14
+ - Qwen/Qwen3.8-Flash-Next
15
+ - deepseek-ai/DeepSeek-V4.1-Flash
16
  ---
17
  # WEX4 Expert Containers
18
 
19
+ Routed-expert weights of two Mixture-of-Experts models, packed as **WEX4** containers for runtimes that read experts from disk one at a time (for example [colibri](https://github.com/JustVugg/colibri) with the WEX4 series). These are **not** complete model checkpoints: no trunk, tokenizer or chat template, and they do not load with `transformers.from_pretrained()`. A runtime takes the trunk from the original checkpoint and the routed experts from the container.
20
 
21
+ WEX4 and WNR3 are separate layers:
22
 
23
+ - **WEX4** is the container: one record per (layer, expert), 4096-byte aligned, so a miss is one aligned read; a self-describing tensor index; a SHA-256 for every record and blob; and a **root** (SHA-256 of the header page) that names the whole file. WEX4 does not compress by itself.
24
+ - **WNR3** is an optional lossless codec for MXFP4 expert records (context-modelled rANS), with a CPU decoder and an NVIDIA GPU decoder.
25
 
26
+ ## Files
 
 
 
 
 
27
 
28
+ | Path | Model and layout | Experts | Size | Upstream license |
29
+ |---|---|---:|---:|---|
30
+ | `qwen38-mxfp4/q38_experts.wex` | [Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next), routed MXFP4 experts, WEX4 with RAW records | 24,576 (48 × 512) | 64,251,047,936 B (64.25 GB) | [Qwen Community License v1.0](https://huggingface.co/Qwen/Qwen3.8-Flash-Next/blob/main/LICENSE) |
31
+ | `v41-reap/v4_flash_experts.nr3.wex` | [DeepSeek V4.1 Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash), REAP-192 (192 of the routed experts kept per layer), WEX4 with WNR3-CZ records | 7,680 (40 × 192) | 123,312,910,336 B (123.31 GB) | [MIT](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash/blob/main/LICENSE) |
32
+ | `provenance/q38_experts.wex.verified.pre-wex4` | SHA-256 note of the source copy the Qwen file was built from | — | 123 B | — |
33
+ | `provenance/v4_flash_experts.nr3.wex.verified.pre-wex4` | Build and read-back note of the V4.1 file | — | 177 B | — |
34
 
35
+ The two containers total about 187.6 GB (174.7 GiB).
36
 
37
+ ## Integrity
 
 
 
 
 
38
 
39
+ | File | WEX4 root (`COLI_WEX_ROOT`) | Content digest | Checked |
40
+ |---|---|---|---|
41
+ | `q38_experts.wex` | `db5389f699abb49a164a9e73d925b5b629b0ce6de430a553388ba3e1cae5c0df` | `0d752bbf2d169b611ac79b005f07d0b9152c0591b23b65cbd12e06ea8300ec77` | 24,576 records, every hash matches the index |
42
+ | `v4_flash_experts.nr3.wex` | `f0f78a84d040a3b336f3abef3cf8b0a36c649deb38586c813e94d35dea3beeb1` | `fb085e127ba980214f106313e9af578b18e5ebac4cde7ecb9730b1a0f78ae512` | 7,680 records decoded, every hash matches the index |
43
 
44
+ The root is the SHA-256 of the first 4,064 bytes of the header page; the content digest is the SHA-256 of the decoded tensor content and metadata in table order (WEX4-SPEC section 5). To check a download yourself, with [Wex-WRN2](https://github.com/KairaCode/Wex-WRN2):
45
 
46
+ ```sh
47
+ gcc -O2 -fopenmp c/tools/wex4_verify.c -o wex4_verify # every record and blob against the index, prints the root
48
+ ./wex4_verify v4_flash_experts.nr3.wex
49
+ python -I wex4/wex4.py verify v4_flash_experts.nr3.wex # also decodes every record (slower)
50
+ ```
51
 
52
+ `wex4_verify` read the V4.1 file in about 150 s from an NVMe SSD and about 260 s from a SATA SSD (8 threads, i7-7700K).
53
 
54
+ ## Size: what WNR3 gives
 
 
 
 
55
 
56
+ Same DeepSeek V4.1 REAP-192 experts:
57
 
58
+ | Encoding | Size relative to RAW | Note |
59
+ |---|---:|---|
60
+ | RAW (WEX1/WEX4) | 1.000 (144.4 GB) | |
61
+ | WNR3, byte-exact | about 0.882 | measured on held-out experts, not on a full container |
62
+ | **WNR3-CZ, value-exact (this file)** | **0.854** (123.3 GB) | FP4 negative zero is stored as positive zero: every value is the same, those sign bits are not |
63
 
64
+ On other MXFP4 models WNR3 measured 0.878 (one Qwen3.8 layer) and 0.890 (all experts of GLM-5.3-Flash, value-exact). The Qwen3.8 file here is RAW on purpose.
65
 
66
+ ## Use with colibri
 
 
67
 
68
+ The WEX4 series for colibri lives on the fork [KairaCode/colibri](https://github.com/KairaCode/colibri) (`main`) and is proposed upstream in [JustVugg/colibri#2920](https://github.com/JustVugg/colibri/pull/2920). Everything is opt-in: with `COLI_WEX_PATH` unset an engine behaves as before.
69
 
70
+ ```sh
71
+ # DeepSeek V4.1: trunk from the original checkpoint, routed experts from the container
72
+ export COLI_WEX_PATH=/models/v4_flash_experts.nr3.wex
73
+ export COLI_WEX_ROOT=f0f78a84d040a3b336f3abef3cf8b0a36c649deb38586c813e94d35dea3beeb1 # refuse any other file
74
+ export COLI_WEX_CUDA_LIB=/path/to/kaira_wex_cuda.so # optional: decode WNR3 on an NVIDIA GPU (make wex-cuda-helper)
75
  ```
76
 
77
+ WNR3 records decode on the CPU (a fast AVX2/NEON decoder, `COLI_WEX_FAST_DECODE`, on by default) or, when `COLI_WEX_CUDA_LIB` names the helper, on the GPU. `COLI_WEX_VERIFY` (on when a root is pinned) checks each record's SHA-256 the first time it is read.
78
 
79
+ Measured with `deepseek_v41` on one desktop (i7-7700K 4C/8T, 32 GB RAM, RTX 3070 8 GB, Windows 10), this V4.1 file on NVMe, trunk from the shards on a SATA SSD, 8 expert slots, prompt "The three primary colors of light are", 8 greedy tokens: **the same tokens in every arm**.
80
 
81
+ | Arm | 8 tokens | tok/s |
82
+ |---|---:|---:|
83
+ | shards only (no container) | 62.5-91.6 s | 0.09-0.13 |
84
+ | container, fast CPU decoder | 71.1 s | 0.11 |
85
+ | container, CUDA helper on the RTX 3070 | 35.2 s | 0.23 |
86
 
87
+ One V4.1 record decodes in about 101 ms on one CPU thread with the fast decoder (742 ms with the reference decoder) and in about 6 ms on the RTX 3070.
88
 
89
+ **Help wanted:** runs on other machines (ARM, Apple silicon, other GPUs, 16 GB RAM, two NVMe drives) with the one-command bench `c/tools/wex_bench.py`: the list and how to report are in [KairaCode/colibri#1](https://github.com/KairaCode/colibri/issues/1).
 
 
 
90
 
91
+ ## Download
92
 
93
+ ```sh
94
+ hf download Kaira666/Kaira-WEX4-Experts --local-dir WEX4-Experts # everything
95
+ hf download Kaira666/Kaira-WEX4-Experts v41-reap/v4_flash_experts.nr3.wex --local-dir WEX4-Experts # one file
96
+ hf download Kaira666/Kaira-WEX4-Experts qwen38-mxfp4/q38_experts.wex --local-dir WEX4-Experts
97
+ ```
98
 
99
+ ## Source and specifications
100
 
101
+ The format, the codec, the specifications, conformance vectors, four independent readers (C, Python, Go, Rust) and the converters are open source under Apache-2.0 in [KairaCode/Wex-WRN2](https://github.com/KairaCode/Wex-WRN2):
 
 
 
102
 
103
+ - [WEX4-SPEC](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/WEX4-SPEC.md) and [WNR3-SPEC](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/WNR3-SPEC.md)
104
+ - [Colibri integration guide](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/COLIBRI-INTEGRATION.md)
105
+ - `wex4/wex4_convert.py`: `pack` a safetensors checkpoint into WEX4 (RAW or WNR3 experts), `unpack` it back byte for byte
106
 
107
  ## Licenses
108
 
109
+ The files here carry different terms, so no single license is asserted for the repository:
110
 
111
+ - Qwen3.8-Flash-Next expert weights: [Qwen Community License v1.0](https://huggingface.co/Qwen/Qwen3.8-Flash-Next/blob/main/LICENSE).
112
+ - DeepSeek V4.1 Flash expert weights: [MIT](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash/blob/main/LICENSE).
113
+ - The WEX format, codec, specifications and tools (not stored here): [Apache-2.0](https://github.com/KairaCode/Wex-WRN2/blob/main/LICENSE).
114
 
115
+ Follow the license of each component.