feat: add torch dequantization for IQ1_S, IQ1_M, IQ2_XXS, IQ2_S, IQ3_XXS, IQ3_S - #433
Open
octo-patch wants to merge 1 commit into
Open
feat: add torch dequantization for IQ1_S, IQ1_M, IQ2_XXS, IQ2_S, IQ3_XXS, IQ3_S#433octo-patch wants to merge 1 commit into
octo-patch wants to merge 1 commit into
Conversation
…XXS, IQ3_S Implements native PyTorch dequantization functions for lower IQ quant types, replacing the slow numpy fallback path for models quantized with these formats (e.g. Unsloth UD quants used as text encoders). All six new functions are verified against gguf.quants.dequantize() reference.
|
Tested this and it works well for IQ3_S in my setup. |
Author
|
Thanks for testing @SSJGabraham! Great to hear IQ3_S is working well. If you get a chance to try any of the other quant types (IQ1_S, IQ1_M, IQ2_XXS, IQ2_S, IQ3_XXS), would love to hear how those work for you too. |
|
@octo-patch One thing I noticed is that when I first ran a test, I thought I was using a IQ3_S, but it was actually IQ3_M, which if I am not mistaken was not listed in your new methods or in your summary above, but it still worked without reverting to the slow numpy path. I didn't notice a slowdown and I did not get a stream of messages in my console about it. When I switched to the proper IQ3_S model I intended to use, performance was identical. Was this expected? |
ChrisColeTech
added a commit
to ChrisColeTech/ComfyUI-GGUF-Loader
that referenced
this pull request
Aug 12, 2026
Cherry-pick production fixes from city96/ComfyUI-GGUF open PRs: - city96#472 dequant device-constant cache (major LTX/sampling speedup) - city96#433 IQ1/IQ2/IQ3 torch dequant (extra TE quants) - city96#470 QK-norm .scale→.weight (silent NaN/black Flux-compat) - city96#467 dequant bare nn.Parameters (LTX learnable_registers) - city96#392 lumina2/zimage pad token shape fix - city96#456/city96#468 GGMLTensor dtype + dequantize() for core cast path - city96#461 WeightAdapter-aware move_patch_to_device - city96#469 force_patch on partial load/unload - city96#440/city96#436 mistral3 TE, city96#438 qwen35, qwen2 allowlist - city96#473 partial: Qwen3-VL deepstack mmproj map for MiniMax H3 TE Skipped mega/draft rewrites (city96#459, full city96#473 LazyGGUFReader, city96#336 Triton). See PR_BACKPORT.md for the full matrix.
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.
Closes #405
Problem
Lower IQ quant types (IQ1_S, IQ1_M, IQ2_XXS, IQ2_S, IQ3_XXS, IQ3_S) currently fall back to the slow numpy path in
dequantize_tensor:This makes loading models quantized with these formats (e.g. Unsloth UD quants used as text encoders) very slow.
Solution
Implements native PyTorch dequantization functions for all six missing IQ quant types, using the quantization grids already provided by the
ggufPython package.The implementations follow the same pattern as the existing
IQ4_NLandIQ4_XSdequantizers and were cross-referenced against the numpy reference implementation ingguf.quants.Testing
All new functions are verified against
gguf.quants.dequantize()(the numpy reference):