File tree Expand file tree Collapse file tree
src/plugins/intel_gpu/src/graph/impls/ocl_v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -193,8 +193,18 @@ class LoraOptBase : public LoraRefBase<LT> {
193193 [[nodiscard]] static size_t get_max_gemma_sgk (const RuntimeParams& params) {
194194 size_t max_workgroup_size = params.get_device_info ().max_work_group_size ;
195195 size_t lora_count = LoraRefBase<LT >::get_lora_count (params);
196- size_t max_gemma_sgk = max_workgroup_size / min_lora_rank / lora_count;
197- return max_gemma_sgk;
196+ // MAX_GEMMA_SGK is the compile-time upper bound of GEMMA_SGK and sets the row count
197+ // of the second-token fma_buff[MAX_GEMMA_SGK * MAX_LORA_RANK] SLM buffer. GEMMA_SGK
198+ // itself never exceeds max_work_group_size / (lora_rank * lora_count), so deriving the
199+ // bound from min_lora_rank (16) over-allocates the buffer by lora_rank / 16 rows and,
200+ // for large ranks with wider accumulators (e.g. rank 256 in f32), overflows the 64KB
201+ // local-memory budget => clBuildProgram CL_OUT_OF_RESOURCES. Use the actual rank so the
202+ // SLM footprint stays ~max_work_group_size elements regardless of rank.
203+ const auto & state_alpha_lo = params.input_layouts [3 ];
204+ size_t lora_rank = extract_channel (ChannelName::FEATURE , state_alpha_lo);
205+ size_t rank_divisor = std::max<size_t >(lora_rank, min_lora_rank);
206+ size_t max_gemma_sgk = max_workgroup_size / rank_divisor / lora_count;
207+ return std::max<size_t >(max_gemma_sgk, 1ul );
198208 }
199209
200210 [[nodiscard]] static size_t is_first_token (const RuntimeParams& params) {
You can’t perform that action at this time.
0 commit comments