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 / docs / models / MXFP4.md
| 1 | <!-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception --> |
| 2 | # MXFP4 dequantisation unit |
| 3 | |
| 4 | `native/models/mxfp4.om` turns one MXFP4 element into exact IEEE binary32 bits. An MXFP4 element is an E2M1 nibble together with the E8M0 scale of its 32-element block. This is the format gpt-oss stores its MoE expert weights in. |
| 5 | |
| 6 | - `mxfp4bits nib scale` takes a nibble (0..15) and a biased scale (0..254) and returns the float bits. |
| 7 | - `mxfp4byte packed lane scale` takes a packed byte and selects the low nibble (lane 0) or the high nibble (lane 1). The low nibble comes first, as in gpt-oss. |
| 8 | - The functions return integer bits, not floats, so the same integer code can be lowered by every Omega back end. |
| 9 | - Refusals trap 5, which gives process exit 105. They cover a nibble above 15, a lane above 1, a packed value above 255 and the reserved E8M0 scale 255 (a NaN block). |
| 10 | - Results the format cannot represent finitely become signed infinity. Signed zero is preserved. Results below the normal range become subnormals. |
| 11 | |
| 12 | It is a scalar primitive, not a GEMM and not an inference engine, and it does not touch any device. |
| 13 | |
| 14 | ## Check |
| 15 | |
| 16 | ``` |
| 17 | python3 tests/models/mxfp4-check.py <omc> |
| 18 | ``` |
| 19 | |
| 20 | `<omc>` must be the seed-built compiler with sha256 `189ada82e00bb440cb41351bd252cc68c54a1b1050051cc42a1df700081c3b54` (omega-mv `91b3c932`); the script refuses any other. |
| 21 | |
| 22 | What the script does: |
| 23 | - Compiles the unit with `tests/models/mxfp4-driver.om` to a native AArch64 program. |
| 24 | - Compares every input (255 scales × 256 bytes × 2 lanes = 130560 records) byte for byte against an oracle. The oracle uses `FP4_VALUES` from `openai/gpt-oss` `gpt_oss/torch/weights.py`, `math.ldexp` and `struct.pack('<f')`. |
| 25 | - Checks six refusals. |
| 26 | - Requires a sign-dropping mutant to run to completion with a mismatching result. |
| 27 | |
| 28 | The Python oracle is used only for verification. It is never part of the runtime. |
| 29 | |
| 30 | Observed on the DGX Spark host (aarch64), 2026-10-26: |
| 31 | |
| 32 | ``` |
| 33 | compiler_sha256=189ada82e00bb440cb41351bd252cc68c54a1b1050051cc42a1df700081c3b54 |
| 34 | source_sha256=993b83945a854b3fa2eeba8f9fe4452f7468c7d0f6a349a11cc655dc7302bbf9 |
| 35 | candidate_sha256=794c329c1c5db695717f7ccec12e28bd0554f9417a0d58e03146c24641e7d8ff |
| 36 | oracle_sha256=665ce3b50c419456c447dc8eabf300d79f20d38dfdbd6e5b3fd6b97308f0bf04 |
| 37 | MXFP4 native CPU exact matches=130560; refusals=6; sign mutant rejected |
| 38 | NVIDIA/Intel/AMD GPU: NOT_RUN; model logits: NOT_RUN |
| 39 | ``` |
| 40 | |
| 41 | ## Not run |
| 42 | |
| 43 | - SPIR-V through `irspirv` on PoCL. That gate pins a different compiler (`befb8199…`), and this host had neither PoCL nor `spirv-val`. |
| 44 | - Any GPU. |
| 45 | - gpt-oss weights or logits. |