CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / evidence / FLASH-NEXT-WEIGHT-WASTE-20261118 / README.md
| 1 | # Qwen3.8-Flash-Next FP8: where the bytes are, and what can be removed exactly |
| 2 | |
| 3 | Date 2026-11-18. CUDApp commit `ce03c88fb13b7eec798efa9a2953f6e3ed5c72fd`. Machine: x86-64 cloud container, 4 cores, |
| 4 | 15 GB RAM, no GPU, gcc 13.3.0, numpy 2.5.3. Nothing here ran on a DGX Spark. Chip status: NOT_RUN. |
| 5 | |
| 6 | Source: `Qwen/Qwen3.8-Flash-Next-FP8` on Hugging Face, revision `7fb48d708ca6cd8eeed8f4db0433be18af96984f`. |
| 7 | No weights are committed. The scripts fetch byte ranges and record SHA-256 of what they read. |
| 8 | |
| 9 | ## Question |
| 10 | |
| 11 | The official FP8 checkpoint is 172.76 GiB. A DGX Spark has 128 GB of unified memory. Is there waste in the weights |
| 12 | that can be removed without changing the model's output? |
| 13 | |
| 14 | ## Measured |
| 15 | |
| 16 | 1. **Inventory** (`inventory.py`, `inventory.log`): all 131 safetensors headers, 152089 tensors. Headers SHA-256 |
| 17 | `0c1a0ab6e4a93e85f4ad7226e4a60a3f106c2be10214f4be99585ebdac6b1584`. |
| 18 | |
| 19 | | Part | GiB | Type | Text serving | |
| 20 | |---|---|---|---| |
| 21 | | Routed experts (48 x 512 x 3 matrices) | 112.500 | E4M3 | resident | |
| 22 | | N-gram table | 47.684 | E4M3 | 16 rows of 160 bytes per token: read from disk | |
| 23 | | GDN | 3.886 | BF16 | resident | |
| 24 | | MTP head | 2.513 | mixed | not needed for plain decoding | |
| 25 | | Gated residual | 1.193 | BF16 | resident | |
| 26 | | Token embedding, lm_head | 1.184 each | BF16 | resident | |
| 27 | | QSA attention and indexer | 1.150 | BF16 | resident | |
| 28 | | Vision tower | 0.836 | BF16 | not needed for text | |
| 29 | | Router and shared expert | 0.557 | BF16 | resident | |
| 30 | | PLE projections, expert scales | 0.075 | BF16 | resident | |
| 31 | |
| 32 | 2. **Structure of the expert weights** (`fetch_layer0.py`, `analyze.py`, `analyze-layer0.log`): 12 experts of |
| 33 | layer 0, 58,982,400 weight bytes, sample file SHA-256 |
| 34 | `7579317a9c4d236b08ac0be7bd379040b9cbaa57b113d9c693a8cbd53a2a8991`. |
| 35 | - Order-0 entropy 6.56 to 6.60 bits per weight byte; 254 of 256 codes used; no zero codes, no NaN codes. |
| 36 | - zlib -9 and xz reach 6.64 to 6.67 bits: there is no sequence structure beyond the code histogram. |
| 37 | - No dead neurons: the weakest of 640 intermediate neurons carries 0.69 to 0.88 of the median importance. |
| 38 | - Full rank: 610 to 617 of 640 singular values are needed for 99% of the energy. |
| 39 | - Experts are unrelated: cosine between down projections of different experts has mean 0.0001, max 0.0023. |
| 40 | |
| 41 | Layers 11, 24 and 47, 3 experts each (`fetch_layers.py`, sample SHA-256 |
| 42 | `ffb4b7f41736b2c7ec76b6ab334dc85e564240a752da943bc6ae4de1f3832c90`): order-0 entropy 6.503, 6.487, 6.603. |
| 43 | |
| 44 | 3. **A real lossless coder** (`rowrans.c`, SHA-256 |
| 45 | `777d3612db721f0dae1dcbf00558d038511f34ef80948661132e60201662ba80`; `run.py`; `rowrans.log`). One static 14-bit |
| 46 | rANS model per matrix, one independent stream per matrix row, so rows can be decoded in parallel. The coded size |
| 47 | counts the frequency table, the row offsets and the streams. |
| 48 | |
| 49 | ``` |
| 50 | gcc -O2 -Wall -Wextra -Werror -o rowrans rowrans.c |
| 51 | python3 -I run.py l0.npz lx.npz |
| 52 | tensors=63 raw=103219200 coded=85069628 bits/weight=6.5933 ratio=0.8242 all_roundtrip_bit_exact=True flipped_bit_detected=63/63 |
| 53 | ``` |
| 54 | |
| 55 | All 63 matrices decode to the identical bytes. Negative control: one flipped bit in the coded stream breaks the |
| 56 | round trip in 63 of 63 matrices. |
| 57 | |
| 58 | ## Derived (arithmetic on the numbers above, not measured) |
| 59 | |
| 60 | - Coded experts: 112.500 x 0.8242 = 92.72 GiB, if the 63-matrix sample ratio holds for all 73,728 matrices. |
| 61 | - Text-serving resident set: 92.72 + 9.23 (all other resident parts, as shipped) = 101.95 GiB, against 121.73 GiB |
| 62 | uncoded. 128 GB is 119.2 GiB. |
| 63 | |
| 64 | ## What this does and does not show |
| 65 | |
| 66 | - The expert weights have no structural waste in this sample. Pruning neurons, low-rank factoring or sharing between |
| 67 | experts would each remove information. They are not free. |
| 68 | - The removable waste is coding redundancy: E4M3 spends 8 bits where the weights carry about 6.5. Removing it is |
| 69 | bit-exact, so the model's output cannot change. |
| 70 | - Not shown: decode speed. The GEMV kernels read FP8 bytes directly today. A coded store needs either a decoded cache |
| 71 | of hot experts or a decoder inside the kernel. Neither exists yet. Status: PROPOSED. |
| 72 | - Not shown: the true free memory on the Spark, the routing skew of the experts, or any token-per-second number. |
| 73 | - `rowrans.c` is a host measurement tool, not runtime code. The runtime decoder belongs in `.om`. |