Skip to content

[GPU] Derive LoRA MAX_GEMMA_SGK from actual rank to bound opt-kernel SLM#36552

Closed
allnes wants to merge 2 commits into
openvinotoolkit:masterfrom
allnes:an/gpu-lora-slm-rank-sizing
Closed

[GPU] Derive LoRA MAX_GEMMA_SGK from actual rank to bound opt-kernel SLM#36552
allnes wants to merge 2 commits into
openvinotoolkit:masterfrom
allnes:an/gpu-lora-slm-rank-sizing

Conversation

@allnes

@allnes allnes commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Problem: The second-token opt kernel (lora_opt.cl, second_token_a) allocates fma_buff[MAX_GEMMA_SGK * MAX_LORA_RANK] in SLM. MAX_GEMMA_SGK was computed as max_work_group_size / min_lora_rank / lora_count (min_lora_rank = 16), independent of the actual rank, while the real GEMMA_SGK never exceeds max_work_group_size / (lora_rank * lora_count). For ranks above 16 this over-allocates the buffer by lora_rank / 16 rows and overflows the 64KB SLM budget: at rank 256 in f32, fma_buff = 64 * 256 * 4 = 64KB, so clBuildProgram fails with CL_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), so fma_buff stays at ~max_work_group_size * sizeof(acc) regardless of rank. Numerics unchanged; identical to before for rank <= 16.

@allnes allnes requested review from a team as code owners June 24, 2026 14:29
@github-actions github-actions Bot added the category: GPU OpenVINO GPU plugin label Jun 24, 2026
@allnes allnes requested a review from maxnick June 24, 2026 14:34
@allnes allnes force-pushed the an/gpu-lora-slm-rank-sizing branch from 4d725a5 to 4ff8630 Compare June 24, 2026 14:40
@allnes allnes force-pushed the an/gpu-lora-slm-rank-sizing branch from 4ff8630 to fe2e0c5 Compare June 24, 2026 16:30
@allnes allnes changed the title [GPU] Size LoRA opt SLM buffers to actual rank instead of hardcoded 256 [GPU] Derive LoRA MAX_GEMMA_SGK from actual rank to bound opt-kernel SLM Jun 24, 2026
@allnes allnes marked this pull request as draft June 24, 2026 17:52
@allnes allnes closed this Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: GPU OpenVINO GPU plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants