feat(ggml): add Q3_K and Q5_K dequantization (types 11 and 13)#103
Open
mvkorobkov wants to merge 2 commits into
Open
feat(ggml): add Q3_K and Q5_K dequantization (types 11 and 13)#103mvkorobkov wants to merge 2 commits into
mvkorobkov wants to merge 2 commits into
Conversation
added 2 commits
May 15, 2026 11:57
Implements scalar dequantize for Q3_K (110 B/block) and Q5_K (176 B/block) so that DeepSeek-R1-0528-Qwen3-8B-Q3_K_L and similar models can be converted via larql gguf-to-vindex. - q3_k.rs: unpack_q3k_scales (kmask1/kmask2 per llama.cpp), two-half-block loop with m-bitmask for high bits, signed-scale centred at 32. - q5_k.rs: reuses pub(super) unpack_q4k_scales from q4_k; u1/u2 mask walk for high bits, 4 iterations of 64 elements each. - mod.rs: Q3_K_BLOCK_BYTES=110, Q5_K_BLOCK_BYTES=176, dispatch in tensor_data_size() and dequantize(). - q4_k.rs: unpack_q4k_scales promoted to pub(super) for Q5_K reuse.
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.
What
Implements scalar dequantization for two missing K-quant formats:
Both
tensor_data_size()anddequantize()inmod.rsare wired up.Why
Without these,
larql convert gguf-to-vindexfails withunsupported type id 11/13on any model that uses Q3_K or Q5_K tensors. This includes:Implementation
q3_k.rs—dequantize_q3_k()hmask[0..32]·qs[32..96]·scales[96..108]·d[108..110]unpack_q3k_scales(): 12 bytes → 16 six-bit signed values using thekmask1=0x03030303/kmask2=0x0F0F0F0Fshuffle fromdequantize_row_q3_Kin llama.cppmbitmask walks throughhmask; clear bit → subtract 4 from q2 valueq5_k.rs—dequantize_q5_k()d[0..2]·dmin[2..4]·scales[4..16]·qh[16..48]·qs[48..176]pub(super) unpack_q4k_scales()fromq4_k.rs(same 12-byte format as Q4_K)u1/u2bitmask pair walks throughqh; set bit → add 16 to 4-bit nibbledequantize_row_q5_Kin llama.cppq4_k.rs—unpack_q4k_scalesvisibility changedfn→pub(super)so Q5_K can share it without duplication.Testing
Unit tests in each module:
q3_k: zero-scale all-zero output, hmask-clear subtracts 4, wrong-size errorq5_k: zero-scale all-zero output, high-bit adds 16, wrong-size errorEnd-to-end:
larql convert gguf-to-vindexonDeepSeek-R1-0528-Qwen3-8B-Q3_K_L.ggufcompletes through dequantization without errors (145 Q3_K + 108 Q5_K tensors dequantized cleanly).All 82 existing larql-models tests continue to pass.