Avoid division-by-zero on 0-weights#7825
Closed
CISC wants to merge 2 commits intoggml-org:masterfrom
Closed
Conversation
Contributor
Member
|
Try using #7833 instead |
Member
Author
|
That helps with the NaNs, but not the 0-weights in |
Contributor
|
Does it work for you? I tried but still found NaN. |
Member
Author
It doesn't really fix the Qwen2 issues, no, I mainly found these because BF16->BF16 flushed weights to 0, however once you fix that |
vignesh1507
approved these changes
Oct 7, 2024
vignesh1507
left a comment
There was a problem hiding this comment.
wow, didn't noticed that...thx for updating the code. appreciate the effort.
compilade
approved these changes
Aug 17, 2025
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.




Converting the new
Qwen2-57B-A14BBF16->BF16 caused a lot of 0-weights (fixed in another PR) which together with an imatrix triggered NaN output on quantization due to division-by-zero.IQ1_S crashes with this assert, fixed by #7955:
https://github.com/ggerganov/llama.cpp/blob/0c27e6f62eea80140daf152d7b6c154466614e5c/ggml-quants.c#L13358
This PR merely fixes the division-by-zero, it does not fix Qwen2 issues as it has subnormal weights (once converted properly) that will cause NaNs on multiplication.