Ludovico commited on
README: fixed files table, usage with colibri, integrity checks, measured results
Browse files12234567891011121314151617181119201321221523242517181920212226272428293031323334263536282930313233373835394041424337444539464748495051415253434445464754554956575158596061626353646555565766675968696162637071727374757666777868798070818283848586728788747576778990799192819394959697988399100858687881011029010310410510610710894109110969798111112113114100115---pipeline_tag: text-generationlicense: otherlicense_name: per-file-see-readmelicense_link: https://huggingface.co/Kaira666/Kaira-WEX4-Experts/blob/main/README.md#licenseslibrary_name: wex4tags:- wex4- wnr3- mixture-of-experts- mxfp4- expert-weights- colibribase_model:- Qwen/Qwen3.8-Flash-Next- deepseek-ai/DeepSeek-V4.1-Flash---# WEX4 Expert Containers
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()`.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.
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.WEX4 and WNR3 are separate layers:
## Files- **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.- **WNR3** is an optional lossless codec for MXFP4 expert records (context-modelled rANS), with a CPU decoder and an NVIDIA GPU decoder.
| Path | Model and layout | Expert count | Size | Upstream model license ||---|---|---:|---:|| `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`) || `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`) || `provenance/q38_experts.wex.verified.pre-wex4` | Supplied Qwen source-copy SHA-256 note | — | 123 bytes | — || `provenance/v4_flash_experts.nr3.wex.verified.pre-wex4` | Supplied V4.1 build/read-back note | — | 177 bytes | — |## Files
The two containers total about 187.6 GB decimal (174.7 GiB). Allow additional disk space for the runtime, cache, and any local mirrors.| Path | Model and layout | Experts | Size | Upstream license ||---|---|---:|---:|---|| `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) || `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) || `provenance/q38_experts.wex.verified.pre-wex4` | SHA-256 note of the source copy the Qwen file was built from | — | 123 B | — || `provenance/v4_flash_experts.nr3.wex.verified.pre-wex4` | Build and read-back note of the V4.1 file | — | 177 B | — |
## Container evolutionThe two containers total about 187.6 GB (174.7 GiB).
| Format | What it adds ||---|---|| **WEX1** | Original layout: raw expert records aligned to 4 KiB for direct per-expert reads. || **WEX2** | Lossless tiled coding for MXFP4 scale values; FP4 weight bytes stay raw. || **WEX3** | Per-record codec support, including WNR2 and WNR3, with the metadata those codecs require. || **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. |## Integrity
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.| File | WEX4 root (`COLI_WEX_ROOT`) | Content digest | Checked ||---|---|---|---|| `q38_experts.wex` | `db5389f699abb49a164a9e73d925b5b629b0ce6de430a553388ba3e1cae5c0df` | `0d752bbf2d169b611ac79b005f07d0b9152c0591b23b65cbd12e06ea8300ec77` | 24,576 records, every hash matches the index || `v4_flash_experts.nr3.wex` | `f0f78a84d040a3b336f3abef3cf8b0a36c649deb38586c813e94d35dea3beeb1` | `fb085e127ba980214f106313e9af578b18e5ebac4cde7ecb9730b1a0f78ae512` | 7,680 records decoded, every hash matches the index |
## WNR3 codec and size resultsThe 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):
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.```shgcc -O2 -fopenmp c/tools/wex4_verify.c -o wex4_verify # every record and blob against the index, prints the root./wex4_verify v4_flash_experts.nr3.wexpython -I wex4/wex4.py verify v4_flash_experts.nr3.wex # also decodes every record (slower)```
Compression figures below compare expert containers for the same DeepSeek V4.1 REAP-192 experts:`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).
| Encoding | Result relative to raw | Evidence and qualification ||---|---:|---|| 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. || WNR3, strict bit-lossless | About 0.8819×, about 11.81% smaller | Estimate from held-out experts; not a full-model non-CZ container measurement. || 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. |## Size: what WNR3 gives
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.Same DeepSeek V4.1 REAP-192 experts:
## Download| Encoding | Size relative to RAW | Note ||---|---:|---|| RAW (WEX1/WEX4) | 1.000 (144.4 GB) | || WNR3, byte-exact | about 0.882 | measured on held-out experts, not on a full container || **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 |
Install the Hugging Face CLI and download the full repository: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.
```powershellhf download Kaira666/Kaira-WEX4-Experts --repo-type model --local-dir .\WEX4-Experts```## Use with colibri
You can download either container separately: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.
```powershellhf download Kaira666/Kaira-WEX4-Experts qwen38-mxfp4/q38_experts.wex --repo-type model --local-dir .\WEX4-Expertshf download Kaira666/Kaira-WEX4-Experts v41-reap/v4_flash_experts.nr3.wex --repo-type model --local-dir .\WEX4-Experts```sh# DeepSeek V4.1: trunk from the original checkpoint, routed experts from the containerexport COLI_WEX_PATH=/models/v4_flash_experts.nr3.wexexport COLI_WEX_ROOT=f0f78a84d040a3b336f3abef3cf8b0a36c649deb38586c813e94d35dea3beeb1 # refuse any other fileexport COLI_WEX_CUDA_LIB=/path/to/kaira_wex_cuda.so # optional: decode WNR3 on an NVIDIA GPU (make wex-cuda-helper)```
## Runtime compatibility and integrityWNR3 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.
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.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**.
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.| Arm | 8 tokens | tok/s ||---|---:|---:|| shards only (no container) | 62.5-91.6 s | 0.09-0.13 || container, fast CPU decoder | 71.1 s | 0.11 || container, CUDA helper on the RTX 3070 | 35.2 s | 0.23 |
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.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.
| File | Verified WEX4 root | Content digest | Verification result ||---|---|---|---|| `q38_experts.wex` | `db5389f699abb49a164a9e73d925b5b629b0ce6de430a553388ba3e1cae5c0df` | `0d752bbf2d169b611ac79b005f07d0b9152c0591b23b65cbd12e06ea8300ec77` | 24,576 records decoded; all indexed hashes matched || `v4_flash_experts.nr3.wex` | `f0f78a84d040a3b336f3abef3cf8b0a36c649deb38586c813e94d35dea3beeb1` | `fb085e127ba980214f106313e9af578b18e5ebac4cde7ecb9730b1a0f78ae512` | 7,680 records decoded; all indexed hashes matched |**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).
The `.verified.pre-wex4` files are included as supplied provenance notes. The roots and results above apply to the final published WEX4 files.## Download
## WEX source and integration```shhf download Kaira666/Kaira-WEX4-Experts --local-dir WEX4-Experts # everythinghf download Kaira666/Kaira-WEX4-Experts v41-reap/v4_flash_experts.nr3.wex --local-dir WEX4-Experts # one filehf download Kaira666/Kaira-WEX4-Experts qwen38-mxfp4/q38_experts.wex --local-dir WEX4-Experts```
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:## Source and specifications
- [WEX4 specification](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/WEX4-SPEC.md)- [WNR3 codec specification](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/WNR3-SPEC.md)- [Colibri integration and usage guide](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/COLIBRI-INTEGRATION.md)- [WEX source repository](https://github.com/KairaCode/Wex-WRN2)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):
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.- [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)- [Colibri integration guide](https://github.com/KairaCode/Wex-WRN2/blob/main/docs/COLIBRI-INTEGRATION.md)- `wex4/wex4_convert.py`: `pack` a safetensors checkpoint into WEX4 (RAW or WNR3 experts), `unpack` it back byte for byte
## Licenses
This repository contains assets with separate license terms, so no single license is asserted for all files:The files here carry different terms, so no single license is asserted for the repository:
- WEX format, codec implementation, specifications, and reference tools: [Apache License 2.0](https://github.com/KairaCode/Wex-WRN2/blob/main/LICENSE).- 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`).- DeepSeek V4.1 Flash model weights: [MIT License](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash/blob/main/LICENSE) (`mit`).- Qwen3.8-Flash-Next expert weights: [Qwen Community License v1.0](https://huggingface.co/Qwen/Qwen3.8-Flash-Next/blob/main/LICENSE).- DeepSeek V4.1 Flash expert weights: [MIT](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash/blob/main/LICENSE).- The WEX format, codec, specifications and tools (not stored here): [Apache-2.0](https://github.com/KairaCode/Wex-WRN2/blob/main/LICENSE).
Follow the applicable license for each component.Follow the license of each component.README.md+73-58