context : fix index overflow on huge outputs #15080
Merged
+8
−8
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.
This fixes a problem I've noticed when working on #15060 and running
llama-imatrix
with-ub 32768 -b 32768
to compute 64 chunks (of 512 tokens) at once with https://huggingface.co/Qwen/Qwen3-30B-A3B-Instruct-2507. (I think any model with a vocab size of at least 131073 tokens should trigger this problem (since2**32 == 32768 * 132072
). That one has a vocab size of 151936)At least two places can overflow on big batches, which are
llama.cpp/src/llama-context.cpp
Line 1132 in ec428b0
and
llama.cpp/src/llama-context.cpp
Line 1340 in ec428b0
This PR should fix that.
Before (notice the high perplexity of later chunks in the huge batch):
After (looks more normal):
Make sure to read the contributing guidelines before submitting a PR