[GPU] Derive LoRA MAX_GEMMA_SGK from actual rank to bound opt-kernel SLM#36552
Closed
allnes wants to merge 2 commits into
Closed
[GPU] Derive LoRA MAX_GEMMA_SGK from actual rank to bound opt-kernel SLM#36552allnes wants to merge 2 commits into
allnes wants to merge 2 commits into
Conversation
4d725a5 to
4ff8630
Compare
4ff8630 to
fe2e0c5
Compare
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.
Problem: The second-token opt kernel (
lora_opt.cl,second_token_a) allocatesfma_buff[MAX_GEMMA_SGK * MAX_LORA_RANK]in SLM.MAX_GEMMA_SGKwas computed asmax_work_group_size / min_lora_rank / lora_count(min_lora_rank = 16), independent of the actual rank, while the realGEMMA_SGKnever exceedsmax_work_group_size / (lora_rank * lora_count). For ranks above 16 this over-allocates the buffer bylora_rank / 16rows and overflows the 64KB SLM budget: at rank 256 in f32,fma_buff = 64 * 256 * 4 = 64KB, soclBuildProgramfails withCL_OUT_OF_RESOURCES(f16 fits at 32KB).Solution: In
LoraOptBase::get_max_gemma_sgk, derive the bound from the actual rank (max_work_group_size / max(lora_rank, min_lora_rank) / lora_count), sofma_buffstays at ~max_work_group_size * sizeof(acc)regardless of rank. Numerics unchanged; identical to before for rank <= 16.