Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Enable SDPA microkernels on Xe3P (#38030)

Wilson Seok6f6a72093139
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp
index a70bd60d836..fab882f8284 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/paged_attention_opt.cpp
@@ -1403,13 +1403,7 @@ public:
if (params.get_device_info().arch < gpu_arch::xe_hpg || !supports_microkernels) {
return false;
}
- // WA: Disable micro SDPA on xe3p due to oneDNN micro-kernel accuracy / determinism
- // issues (inf/nan, run-to-run nondeterminism in the generated systolic ugemm). Falls back to
- // the OCL paged_attention path for all stages where micro SDPA is selectable (PREFILL / MIXED)
- // and for all KV dtypes.
- if (params.get_device_info().arch == gpu_arch::xe3p) {
- return false;
- }
+
} else {
return false;
}
diff --git a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp
index 68e37576e56..ebebe2b1d6d 100644
--- a/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp
+++ b/src/plugins/intel_gpu/src/graph/impls/ocl_v2/sdpa/sdpa_gen_micro.cpp
@@ -463,12 +463,35 @@ sdpa_config_t xe2_q_h256_s768_2nd_integrated = {64, 16, 16, 16, 16, 1, 16, 1};
sdpa_config_t xe2_q_h256_s512_2nd_integrated = {32, 32, 32, 16, 16, 1, 8, 2};
sdpa_config_t xe2_q_h256_s384_2nd_integrated = {16, 16, 16, 16, 16, 1, 16, 1};
-sdpa_config_t xe3_h128 = {32, 16, 32, 16, 16, 2, 16, 2};
-sdpa_config_t xe3_h256 = {32, 16, 32, 16, 16, 2, 16, 2};
+// Native Xe3p configurations from oneDNN SDPA's config catalog. OpenVINO does
+// not distinguish FMA and systolic configurations during config selection, so
+// FMA/f32 labels below preserve source catalog provenance.
+sdpa_config_t xe3_fma_h32 = {16, 16, 16, 16, 2, 2, 2, 2};
+sdpa_config_t xe3_fma_h64_2nd = {16, 16, 16, 16, 8, 4, 8, 4};
+sdpa_config_t xe3_fma_q_h32_2nd = {16, 16, 16, 16, 2, 2, 2, 2};
+sdpa_config_t xe3_fma_q_h64_2nd = {16, 16, 16, 16, 8, 4, 8, 4};
+sdpa_config_t xe3_fma_h32_pa = {16, 16, 16, 16, 2, 2, 2, 2};
+
+// PagedAttention generate_mixed block-size-16 records.
+sdpa_config_t xe3_h64_pa = {16, 16, 16, 16, 4, 4, 4, 4};
+
+sdpa_config_t xe3_h128 = {32, 32, 32, 32, 4, 4, 4, 4};
+sdpa_config_t xe3_h128_pa_sw0 = {16, 16, 16, 16, 8, 1, 8, 1};
+sdpa_config_t xe3_h128_pa = {16, 16, 16, 16, 16, 4, 16, 4};
+sdpa_config_t xe3_h128_2nd = {32, 32, 32, 32, 4, 1, 4, 1};
+sdpa_config_t xe3_q_h128 = {32, 32, 32, 32, 4, 4, 4, 4};
+sdpa_config_t xe3_q_h128_2nd = {32, 32, 32, 32, 4, 1, 4, 1};
+
+sdpa_config_t xe3_h256_2nd = {32, 32, 32, 32, 8, 1, 8, 1};
+sdpa_config_t xe3_h256_pa = {16, 16, 16, 16, 16, 1, 16, 1};
+sdpa_config_t xe3_q_h256 = {32, 32, 32, 32, 8, 2, 8, 2};
+sdpa_config_t xe3_q_h256_2nd = {32, 32, 32, 32, 8, 1, 8, 1};
sdpa_config_t xe3_h512 = {32, 16, 32, 16, 16, 2, 16, 2};
+sdpa_config_t xe3_h512_pa = {16, 16, 16, 16, 16, 2, 16, 2};
sdpa_config_t xe3_h512_2nd = {32, 16, 32, 16, 16, 1, 16, 1};
-sdpa_config_t xe3_q_h512_2nd = {32, 16, 32, 16, 16, 1, 16, 1};
+sdpa_config_t xe3_fma_q_h512 = {16, 16, 32, 16, 16, 1, 16, 1};
+sdpa_config_t xe3_fma_f32_q_h512_2nd = {16, 16, 32, 16, 16, 1, 16, 1};
sdpa_config_t* choose_config_xehpg(int head_size, int seq, bool thin_q, bool quantized, bool is_pa, bool is_prefill) {
if (head_size <= 32) {
@@ -927,22 +950,62 @@ sdpa_config_t* choose_config_xe2(int head_size, int seq, bool thin_q, bool quant
}
return choose_config_xehpc(head_size, seq, thin_q, quantized, is_integrated, is_pa, is_prefill);
}
-sdpa_config_t* choose_config_xe3p(int head_size, int seq, bool thin_q, bool quantized, bool is_integrated, bool is_pa, bool is_prefill) {
+
+sdpa_config_t* choose_config_xe3p(int head_size, int seq, bool thin_q, bool quantized, bool is_integrated, bool is_pa, bool is_prefill, int sliding_window) {
+ if (is_pa && !is_prefill && !thin_q) {
+ if (head_size > 32 && head_size <= 64) {
+ return &xe3_h64_pa;
+ }
+ if (head_size <= 32) {
+ return &xe3_fma_h32_pa;
+ }
+ if (head_size <= 128) {
+ return sliding_window == 0 ? &xe3_h128_pa_sw0 : &xe3_h128_pa;
+ }
+ if (head_size <= 256) {
+ return &xe3_h256_pa;
+ }
+ if (head_size <= 512) {
+ return &xe3_h512_pa;
+ }
+ }
+ if (head_size <= 32) {
+ if (thin_q) {
+ return quantized ? &xe3_fma_q_h32_2nd : &xe3_fma_h64_2nd;
+ }
+ if (!quantized) {
+ return &xe3_fma_h32;
+ }
+ }
+ if (head_size <= 64 && thin_q) {
+ return quantized ? &xe3_fma_q_h64_2nd : &xe3_fma_h64_2nd;
+ }
if (head_size <= 128) {
- return &xe3_h128;
+ if (thin_q) {
+ return quantized ? &xe3_q_h128_2nd : &xe3_h128_2nd;
+ }
+ return quantized ? &xe3_q_h128 : &xe3_h128;
}
if (head_size <= 256) {
- return &xe3_h256;
+ if (thin_q) {
+ return quantized ? &xe3_q_h256_2nd : &xe3_h256_2nd;
+ }
+ if (quantized) {
+ return &xe3_q_h256;
+ }
return choose_config_xe2(head_size, seq, thin_q, quantized, is_integrated, is_pa, is_prefill);
}
if (head_size <= 512) {
if (thin_q) {
if (quantized) {
- return &xe3_q_h512_2nd;
+ return &xe3_fma_f32_q_h512_2nd;
}
return &xe3_h512_2nd;
}
- return &xe3_h512;
+ if (!quantized) {
+ return &xe3_h512;
+ }
+ return &xe3_fma_q_h512;
}
return choose_config_xe2(head_size, seq, thin_q, quantized, is_integrated, is_pa, is_prefill);
}
@@ -1782,7 +1845,14 @@ void SDPAMicroGenerator::init_microkernels(const kernel_impl_params& params,
config = choose_config_xe2(static_cast<int32_t>(k_head_size), nkeys_v, thin_q, is_quantized, is_integrated, is_paged_attention, is_prefill);
break;
case gpu_arch::xe3p:
- config = choose_config_xe3p(static_cast<int32_t>(k_head_size), nkeys_v, thin_q, is_quantized, is_integrated, is_paged_attention, is_prefill);
+ config = choose_config_xe3p(static_cast<int32_t>(k_head_size),
+ nkeys_v,
+ thin_q,
+ is_quantized,
+ is_integrated,
+ is_paged_attention,
+ is_prefill,
+ static_cast<int32_t>(configuration.paged_attention_sliding_window));
break;
default: {
config = choose_config_xe2(static_cast<int32_t>(k_head_size), nkeys_v, thin_q, is_quantized, is_integrated, is_paged_attention, is_prefill);
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.cpp
index 1be10207b4d..035fae71644 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
@@ -202,13 +202,6 @@ bool SDPAOpt::supports_micro_sdpa(const RuntimeParams& params) {
if (device_info.arch < gpu_arch::xe_hpg || !supports_microkernels) {
return false;
}
- // WA: Disable micro SDPA on xe3p for head_size <= 64 due to oneDNN micro-kernel
- // accuracy issues (produces inf/nan) after oneDNN main branch integration.
- auto extended_input_k_transpose_order = extend_order_in_num_heads_dim(desc->input_k_transpose_order);
- const auto k_head_size = get_head_size(params.get_input_layout(1), extended_input_k_transpose_order);
- if (device_info.arch == gpu_arch::xe3p && k_head_size <= 64) {
- return false;
- }
} else {
return false;
}