Repository navigation
ggml-hrx: Q2_0 weights (shared dequantizer, decode lanes, bit-exact GET_ROWS test) - #76
Closed
bong-water-water-bong wants to merge 3 commits into
Closed
bong-water-water-bong wants to merge 3 commits into
bong-water-water-bong wants to merge 3 commits into
Conversation
Q2_0 (ggml type 42) is 64-value blocks of an f16 scale d and 16 bytes of 2-bit codes; value j is ((qs[j / 4] >> 2 (j % 4)) & 3) - 1 times d (dequantize_row_q2_0). Four aligned values are the four fields of one byte. The decoder takes the value index k like Q1_0 and lives in our motifs/dequant_1bit.loom; row bytes are 18 per 64 values and a 256-value tile is 72 bytes. Input sizes are multiples of 64. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Q2_0 lane of 16 values is four code bytes under one scale, so Q2_0 joins the 16-value lanes of kquant_decode_f32: lane l reads block l / 4 (d at its first 16-bit word) and the two 16-bit words of qs bytes 4 (l % 4)..+4 (blocks are 18 bytes, 2-byte aligned). 72 bytes per 256 values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… on HRX Eight rows of 256 values with f16 scales 1, 0.1, -1, the smallest subnormal, a negative subnormal, 0, 65504 and 2^-10, and every byte value in the codes. HRX's GET_ROWS must equal dequantize_row_q2_0 bit for bit, on the HRX device with no scheduler, through the get_rows kernel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
|
Review (PR-Agent duty): approved, merging after Sunday's release (stacked on #75). Checked: HRX format 42; row bytes (K/64 x 18) and tile bytes (72 per 256 values) both present; the known-answer test covers subnormal, negative, zero and 65504 f16 scales. sdkyuan/qwen3.8-27B-qat-q2_0: KLD 0.00106 vs CPU, top-1 97.9%, one graph split, decode on the kquant lanes, tg128 19.8. NVFP4 and Q2_0 now also share the decode-stride test at widths that are not multiples of 256. Our full Apache header is on test-hrx-q2_0.cpp. |
This was referenced Oct 2, 2026
Author
|
Kept: format support in the shared dequantizer / GET_ROWS is plumbing, not a new kernel (Q2_0 is the 2-bit format the ternary goal uses). Waits for the release hold like everything else; needs a rebase onto f95f2db before merge. |
Author
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.
Q2_0 weights (ggml type 42) on HRX0. Stacked on #75 (NVFP4), which touches the same dequantizer anchors; review and merge after it. Before this branch, HRX supported none of the Q2_0 cases in test-backend-ops.
Commits
901a7829: Q2_0 in the shared dequantizer, HRX format code 42 (not a ggml type id; checked againstcommon_mul_mat_format_config_value). The decoder is in ourmotifs/dequant_1bit.loom, value((qs[j/4] >> 2(j%4)) & 3) - 1times the f16d. Row bytes are 18 per 64 values and tile bytes 72 per 256; both are set, per ggml-hrx: PrismML tile bytes for the low-token SwiGLU (PQ2_0 1.7B decode) #74. Input sizes must be multiples of 64.0d32570a: Q2_0 on the 16-value kquant decode lanes, reading 16-bit words (blocks are 18 bytes, 2-byte aligned).c2a1beb9:tests/test-hrx-q2_0, GET_ROWS bit-exact againstdequantize_row_q2_0. The f16 scales cover normal, subnormal, negative, zero and 65504, and every byte value appears in the codes.Validation on this branch plus the GET_ROWS PR on top (
97fcffe5), gfx1151, balanced power mode:kquant.{mul_mat,swiglu,mul_mat_add}.decode_f32Prefill (156 tok/s) runs on the generic f16 WMMA kernels, as with NVFP4 in #75.
Not every file named "Q2_0" uses ggml's Q2_0.
darkstarinitiative/AJAN-SIMIT-Ternary-Bonsai-Q2_0-GGUFfails to load on the CPU too (tensor 'blk.0.attn_k.weight' has offset 82516128, expected 87369536), so it was written with another fork's block layout. That is not an HRX gap.Not for the release pin.
🤖 Generated with Claude Code