Repository navigation
ggml-hrx: NVFP4 weights (shared dequantizer, decode lanes, bit-exact GET_ROWS test) [rebased] - #98
Merged
Conversation
NVFP4 (ggml type 40) is 64-value blocks of four UE4M3 scales, one per 16 values, and 32 bytes of E2M1 codes. The shared dequantizer walks 32-value blocks, so a block is half of an NVFP4 block: row bytes are 18 per 32 values and a 256-value tile is 144 bytes (both set, see #74). The decoder in dequant_1bit.loom reuses the MXFP4 code table and nibble unpacking; the scale is ggml_ue4m3_to_fp32 built from its f32 bits, exact for every byte (0x7F reads as 0, bit 7 is ignored). The HRX format code is 43, not the ggml type id: HRX format 40 is Q4_0. Input sizes are multiples of 64. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An NVFP4 scale group is 16 consecutive values, so NVFP4 joins packed ternary, TQ1_0, TQ2_0 and MXFP4 on the 16-value lanes of kquant_decode_f32: lane l reads block l / 4, sub-block l % 4 (scale d[s], codes qs[8 s..8 s + 7], low nibbles first). 144 bytes per 256 values. Decode projections, SwiGLU pairs and projection + residual ADD on NVFP4 weights now take the kquant decode kernels instead of the generic path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…WS on HRX Sixteen rows of 256 values hold all 256 UE4M3 scale bytes and every E2M1 code in both nibbles. GET_ROWS on HRX must equal ggml's dequantize_row_nvfp4 bit for bit (every NVFP4 value is exact in f32), on the HRX device with no scheduler, and the dispatch plan must contain the get_rows kernel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2880 and 2048, from one token The NVFP4 format admits input sizes that are a multiple of 64, the kquant decode lanes only multiples of 256. At 320, 1152 and 2880 one token takes the generic ggml_mul_mat_f32_f32_decode_wave64, 2..8 tokens ggml_mul_mat_f32_f32_wmma and MUL_MAT_ID ggml_mul_mat_id_decode_f32_wave64; at 2048 the kquant lanes. All 36 NVFP4 cases match the CPU backend (normalized MSE about 1e-5); 108 cases, 0 failures. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebase of #75 onto the current tip e44c9d0 (AMD's corpus taken wholesale on 6 Oct). All four patches applied with no textual conflict;
git range-diffshows every commit unchanged. The tip has no NVFP4 handling of its own and HRX format code 43 is still free, so nothing was dropped.Verified on strixhalo 2026-10-09 (power mode performance, hrx-system 98d05d94, built with the engine's HRX configuration, every GPU step under box.lock):
Full test-backend-ops at the stack tip: 27 of 28 runs 1141/1141; the one failure (MUL_MAT f32 m=1 n=1 k=2048, common.mul_mat.f32_f32_decode) also occurs on the unmodified base (1 in 40 MUL_MAT runs), so it is pre-existing and reported separately.
Supersedes #75.
🤖 Generated with Claude Code