Fix Gemma4-E4B compute graph#1855
Merged
Merged
Conversation
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.
The issue was that the per layer token embedding tensor was loaded into the output context, so onto a GPU when present. But if this tensor was quantized with a type that does not have CUDA support for
ggml_get_rowson CUDA (i.e., all quants exceptQ4_0, Q4_1, Q5_0, Q5_1, Q8_0), this required a copy of the per layer embedding tensor to the CPU, computingggml_get_rowsthere, and copying back the result to the GPU. As the per layer embedding tensor is giant (2.8 billion elements!), this totally kills performance.There is PR #1830, which adds CUDA support for
ggml_get_rowsfor some k-quants. But this does not solve the actual root cause of the per layer embedding tensor being loaded into the wrong context.With this PR CUDA performance for Gemma4-E4B is recovered to expected levels independently of the quantization type of the per layer embedding tensor.