Skip to content

gguf : fix division by zero#20716

Open
ggerganov wants to merge 1 commit into
masterfrom
gg/gguf-fix-division-by-zero
Open

gguf : fix division by zero#20716
ggerganov wants to merge 1 commit into
masterfrom
gg/gguf-fix-division-by-zero

Conversation

@ggerganov
Copy link
Copy Markdown
Member

Prevent malformed data causing divisions by zero and crashes.

@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Mar 18, 2026
@Green-Sky
Copy link
Copy Markdown
Collaborator

While I am for this change, to explicitly not support zero sized tensors, safetensors does support this. And over at sd.cpp there are some models that currently use this.
I do agree though that one really should use metadata instead, or a one dim tensor as a workaround.

@JohannesGaessler
Copy link
Copy Markdown
Contributor

Also more generally: right now the ggml API does allow the user to create zero-sized tensors. I think preferably we would either allow or disallow these consistently for ggml and GGUF.

@ngxson
Copy link
Copy Markdown
Contributor

ngxson commented Mar 18, 2026

I think disallowing 0-element tensors everywhere is more preferable (which can be follow-up PRs), as we don't have any use cases for that.

I suspect that safetensors support it because they also have scalar tensors. I have no ideas how they are stored at byte level, but it make more sense (and it is indeed a common practice) to convert pytorch scalar tensor into GGML 1-element tensor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants