OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Fix ScaledAttnStatic3D test failure on A770 (#31637)
River Liac145e02313e
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cppindex f4d4e747ed1..94eecd7e009 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_opt.cpp@@ -231,7 +231,7 @@ Arguments SDPAOptGeneratorFinalization::get_arguments_desc(const kernel_impl_par}JitConstants SDPAOptGeneratorFinalization::get_jit_constants(const kernel_impl_params& params) const {- auto jit = SDPAOptGeneratorBase::get_jit_constants_base(params, SDPAStage::SINGLE_TOKEN);+ auto jit = SDPAOptGeneratorBase::get_jit_constants_base(params, SDPAStage::FINALIZATION);jit.make("SDPA_STAGE_1", 1);jit.make("TARGET_SEQ_LEN_BLOCK_SIZE", get_target_seq_len_block_size());return jit;@@ -255,7 +255,7 @@ DispatchDataFunc SDPAOptGeneratorFinalization::get_dispatch_data_func() const {const size_t batch_size = get_batch_size(params.get_output_layout(0), extended_output_transpose_order);const size_t target_seq_len = get_seq_length(params.get_input_layout(0), extended_input_q_transpose_order);const size_t heads_num = get_num_heads(params.get_output_layout(0), extended_output_transpose_order);- const size_t num_of_partitions = get_partitions_num(params, SDPAStage::SINGLE_TOKEN);+ const size_t num_of_partitions = get_partitions_num(params, SDPAStage::FINALIZATION);const size_t head_size = get_head_size(params.get_input_layout(2), extended_input_v_transpose_order);GPU_DEBUG_TRACE_DETAIL << "batch_size = " << batch_size << ", target_seq_len = " << target_seq_len << ", heads_num = " << heads_num << "\n";diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cppindex 261e5892392..7a70112ab1b 100644--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_opt.cpp@@ -75,9 +75,14 @@ public:add_stage(indirect_multi_tokens, params);#ifdef ENABLE_ONEDNN_FOR_GPU} else if (SDPAOpt::supports_micro_sdpa(params)) {- GPU_DEBUG_TRACE_DETAIL << "add stage for micro_sdpa non-dynamic with prefill_stage \n";+ GPU_DEBUG_TRACE_DETAIL << "add stage for micro_sdpa non-dynamic with prefill_stage \n";add_stage(regular_micro_multi_tokens, params);- add_stage(regular_micro_single_token, params);+ // Sometimes micro kernel will fail due to "Insufficient registers in requested bundle",+ // In this case, fallback to opt kernel.+ if (!has_stage(regular_micro_multi_tokens)) {+ GPU_DEBUG_TRACE_DETAIL << "fail to create micro kernel, fallback to regular_multi_tokens for prefill \n";+ add_stage(regular_multi_tokens, params);+ }#endif} else {GPU_DEBUG_TRACE_DETAIL << "add stage regular_multi_tokens kernels with prefill_stage \n";@@ -85,19 +90,17 @@ public:}} else {GPU_DEBUG_TRACE_DETAIL << "add stage single_tokens \n";+#ifdef ENABLE_ONEDNN_FOR_GPUconst auto& gfx_ver = params.get_program().get_engine().get_device_info().gfx_ver;bool is_ARL_H = (gfx_ver.major == 12 && gfx_ver.minor == 74);- if (!SDPAOpt::supports_micro_sdpa(params) || is_ARL_H) {- add_stage(is_indirect ? indirect_single_token : regular_single_token, params);-- if (get_partitions_num(params, SDPAStage::SINGLE_TOKEN) > 1) {- add_stage(is_indirect ? indirect_finalization : regular_finalization, params);- }-#ifdef ENABLE_ONEDNN_FOR_GPU- } else {+ bool can_use_micro_sdpa = SDPAOpt::supports_micro_sdpa(params) && !is_ARL_H && !is_indirect;+ if (can_use_micro_sdpa) {add_stage(regular_micro_single_token, params);- add_stage(regular_micro_multi_tokens, params);+ }#endif+ add_stage(is_indirect ? indirect_single_token : regular_single_token, params);+ if (get_partitions_num(params, SDPAStage::SINGLE_TOKEN) > 1) {+ add_stage(is_indirect ? indirect_finalization : regular_finalization, params);}}}@@ -111,8 +114,7 @@ public:GPU_DEBUG_TRACE_DETAIL << "execute indirect = " << is_indirect << ", prefill = " << is_prefill << "\n";update_rt_params(instance);#ifdef ENABLE_ONEDNN_FOR_GPU- bool run_micro_sdpa = has_stage(regular_micro_multi_tokens) && has_stage(regular_micro_single_token) && is_prefill && !is_indirect;- if (run_micro_sdpa) {+ if (has_stage(regular_micro_multi_tokens) && is_prefill && !is_indirect) {GPU_DEBUG_TRACE_DETAIL << "execute regular_micro_multi_tokens for prefill \n";return execute_stage(events, instance, regular_micro_multi_tokens);}@@ -125,6 +127,11 @@ public:GPU_DEBUG_TRACE_DETAIL << "execute multi_tokens for prefill with indirect = " << is_indirect << "\n";return execute_stage(events, instance, is_indirect ? indirect_multi_tokens : regular_multi_tokens);}+#ifdef ENABLE_ONEDNN_FOR_GPU+ if (has_stage(regular_micro_single_token) && !is_indirect) {+ return execute_stage(events, instance, regular_micro_single_token);+ }+#endifconst auto num_of_partitions = get_partitions_num(new_params, SDPAStage::SINGLE_TOKEN);GPU_DEBUG_TRACE_DETAIL << "execute single_tokens with indirect = " << is_indirect << "\n";auto ev = execute_stage(events, instance, is_indirect ? indirect_single_token : regular_single_token);