Guard against sumq2 being 0 in IQ4_NL resulting in nan values#20460
Open
bartowski1182 wants to merge 1 commit intoggml-org:masterfrom
Open
Guard against sumq2 being 0 in IQ4_NL resulting in nan values#20460bartowski1182 wants to merge 1 commit intoggml-org:masterfrom
bartowski1182 wants to merge 1 commit intoggml-org:masterfrom
Conversation
compilade
approved these changes
Mar 12, 2026
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.
With
IQ4_NLon several recent models there have been issues where during quantization NaN blocks are being found which crashes the quantIt seems to be stemming from a scenario where
sumq2is 0 for a given block, likely from not having imatrix data for some obscure expert, or the weights themselves being 0 as we've seen with some recent Qwen modelsThis change guards against dividing by 0, instead setting
dto 0, which would then just set the block of weights to 0, which seems appropriateMost recently observed in nvidia's Nemotron-3-Super-120B-A12B,
blk.3.ffn_down_expshas a block that never sees imatrix data, and that results insumq2being 0I added some debug information to look at what those weights are like (to ensure that setting them to 0 wouldn't present a new issue) and the
amaxat this time is in the order of 1e-11 so they're likely rounding down to 0 during imatrix calculations anyways