enum ADRENO_CL_COMPILER_TYPE {
E031,
+ E17,
DX,
};
}
if (strstr(device_name, "830") ||
- strstr(device_name, "840")) {
+ strstr(device_name, "840") ||
+ strstr(device_name, "850")) {
return ADRENO_GPU_GEN::A8X;
}
size_t compiler_minor_offset = 8;
size_t compiler_patch_offset = 11;
+ if (compiler_ver_pos == std::string::npos) {
+ compiler_ver_pos = driver_ver_str.find("E17");
+ if (compiler_ver_pos != std::string::npos) {
+ type = ADRENO_CL_COMPILER_TYPE::E17;
+ compiler_ver_len = 12;
+ compiler_major_offset = 4;
+ compiler_minor_offset = 7;
+ compiler_patch_offset = 10;
+ }
+ }
+
if (compiler_ver_pos == std::string::npos) {
compiler_ver_pos = driver_ver_str.find("DX");
if (compiler_ver_pos == std::string::npos) {
type = ADRENO_CL_COMPILER_TYPE::DX;
compiler_ver_len = 11;
compiler_major_offset = 3;
+ compiler_minor_offset = 6;
+ compiler_patch_offset = 9;
}
std::string compiler_ver_str = driver_ver_str.substr(compiler_ver_pos, compiler_ver_len);
// those compiler versions since it is anyway not used for Adreno.
if (backend_ctx->gpu_family != ADRENO ||
backend_ctx->adreno_cl_compiler_version.newer_than_or_same(E031, 38, 11, 0) ||
+ backend_ctx->adreno_cl_compiler_version.type == E17 ||
backend_ctx->adreno_cl_compiler_version.type == DX) {
#ifdef GGML_OPENCL_EMBED_KERNELS
const std::string kernel_src {
return threashold_ok;
}
+static bool adreno_e17_compiler_quirks(const ggml_backend_opencl_context *backend_ctx) {
+ if (!backend_ctx || backend_ctx->gpu_family != GPU_FAMILY::ADRENO ||
+ backend_ctx->adreno_cl_compiler_version.type != ADRENO_CL_COMPILER_TYPE::E17) {
+ return false;
+ }
+ const char * env = getenv("GGML_OPENCL_ADRENO_E17_QUIRKS");
+ return !(env && env[0] == '0');
+}
+
inline bool use_adreno_moe_kernels(const ggml_backend_opencl_context *backend_ctx, const ggml_tensor *tensor) {
// The moe weight repack kernels *_trans4_ns alias a private ushort8 through a uchar*.
// Certain compilers (found with some A7x and A6x) miscompiles this, corrupting the weights.
backend_ctx->adreno_gen == ADRENO_GPU_GEN::ADRENO_UNKNOWN)) {
return false;
}
+
+ if (adreno_e17_compiler_quirks(backend_ctx)) {
+ return false;
+ }
+
int ne01 = tensor->ne[1];
return (((strstr(tensor->name, "ffn") != NULL) && (strstr(tensor->name, "exps") != NULL)) || (strstr(tensor->name, "as") != NULL)) && (ne01 % 32 == 0);
}
case GGML_OP_MEAN:
return op->src[0]->type == GGML_TYPE_F32;
case GGML_OP_FLASH_ATTN_EXT: {
+ // The E17 compilers segfault while building FA kernels, skip E17 for now
+ if (adreno_e17_compiler_quirks(backend_ctx)) {
+ return false;
+ }
const ggml_tensor * q = op->src[0];
const ggml_tensor * k = op->src[1];
const ggml_tensor * v = op->src[2];
shared_b[b_local_offset.y] = bx8_f16.hi;
// Dequantization
- reg_a.lo = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.lo)) * s;
- reg_a.hi = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.hi)) * s;
+ // Cast the e8m0 scale to half to satisfy E17 compilers
+ reg_a.lo = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.lo)) * (half)s;
+ reg_a.hi = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.hi)) * (half)s;
sub_group_barrier(CLK_LOCAL_MEM_FENCE);
shared_b[b_local_offset.y] = bx8_f16.hi;
// Dequantization
- reg_a.lo = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.lo)) * s;
- reg_a.hi = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.hi)) * s;
+ // Cast the e8m0 scale to half to satisfy E17 compilers
+ reg_a.lo = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.lo)) * (half)s;
+ reg_a.hi = mxfp4_to_fp16_packed8(as_ushort2(mxfp4x16.hi)) * (half)s;
sub_group_barrier(CLK_LOCAL_MEM_FENCE);