From 541436c91243334f198b2ef6a40084c3eaacb199 Mon Sep 17 00:00:00 2001 From: Gallagher Donovan Pryor <75991366+pv-pterab-s@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:54:44 -0500 Subject: [PATCH] fix: if mask not present, opencl kernel fails with divide by 0 If utilizing micro kernel version of sdpa without an attention mask, the opencl kernel will fail to compile with a divide by zero error. This remove the `msk` index computation in the absence of the mask to avoid the error and allow micro kernel sdpa to function w/o the mask as intended. --- src/gpu/intel/ocl/micro_sdpa.cl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gpu/intel/ocl/micro_sdpa.cl b/src/gpu/intel/ocl/micro_sdpa.cl index 206b28d5617..929e0c48117 100644 --- a/src/gpu/intel/ocl/micro_sdpa.cl +++ b/src/gpu/intel/ocl/micro_sdpa.cl @@ -202,7 +202,9 @@ micro_sdpa(const global half *K, const global half *Q, const global half *V, Q += QRY_OFF(b1, b0, 0, 0); V += VAL_OFF(b1, b0 / KV_GROUP_SIZE, 0, 0); A += DST_OFF(b1, b0, 0, 0, 0); +#if WITH_ATTN_MASK msk += MSK_OFF(b1 % MSK_D0, b0 % MSK_D1, 0, 0); +#endif /* Load Q tile, destined for SLM */ q_tile_type Q_tile;