From 27c2c8d4fcd3f29027fcd66d5915eba6af9dbf3b Mon Sep 17 00:00:00 2001 From: "romain.biessy" Date: Mon, 30 Jun 2025 12:03:20 +0100 Subject: [PATCH 1/2] ggml-cpu: sycl: Enable exp f16 --- ggml/src/ggml-cpu/CMakeLists.txt | 5 +++++ ggml/src/ggml-sycl/ggml-sycl.cpp | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ggml/src/ggml-cpu/CMakeLists.txt b/ggml/src/ggml-cpu/CMakeLists.txt index 46f678b8525e7..bae8e967e8d9a 100644 --- a/ggml/src/ggml-cpu/CMakeLists.txt +++ b/ggml/src/ggml-cpu/CMakeLists.txt @@ -589,4 +589,9 @@ function(ggml_add_cpu_backend_variant_impl tag_name) if (EMSCRIPTEN) set_target_properties(${GGML_CPU_NAME} PROPERTIES COMPILE_FLAGS "-msimd128") endif() + + if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + # The compiler automatically enables "-ffast-math" which can cause NaNs in tests due to "fassociative-math" + target_compile_options(${GGML_CPU_NAME} PRIVATE "-fno-associative-math") + endif() endfunction() diff --git a/ggml/src/ggml-sycl/ggml-sycl.cpp b/ggml/src/ggml-sycl/ggml-sycl.cpp index 4ecca4165bee3..ae5e062572e32 100644 --- a/ggml/src/ggml-sycl/ggml-sycl.cpp +++ b/ggml/src/ggml-sycl/ggml-sycl.cpp @@ -4215,6 +4215,7 @@ static bool ggml_backend_sycl_device_supports_op(ggml_backend_dev_t dev, const g case GGML_UNARY_OP_GELU_QUICK: case GGML_UNARY_OP_GELU_ERF: case GGML_UNARY_OP_TANH: + case GGML_UNARY_OP_EXP: case GGML_UNARY_OP_SGN: case GGML_UNARY_OP_ABS: case GGML_UNARY_OP_ELU: @@ -4223,9 +4224,6 @@ static bool ggml_backend_sycl_device_supports_op(ggml_backend_dev_t dev, const g #else return ggml_is_contiguous(op->src[0]) && (op->src[0]->type == GGML_TYPE_F32 && op->type == GGML_TYPE_F32) && (op->type == op->src[0]->type); #endif - case GGML_UNARY_OP_EXP: - // Disable FP16 until we find out the root cause of failing fp16 sycl::exp - return ggml_is_contiguous(op->src[0]) && (op->type == op->src[0]->type) && op->src[0]->type == GGML_TYPE_F32; default: return false; } From 2129770490d9553196fbda1b2090c647b43e38be Mon Sep 17 00:00:00 2001 From: Romain Biessy Date: Mon, 30 Jun 2025 13:36:29 +0200 Subject: [PATCH 2/2] Fix comment --- ggml/src/ggml-cpu/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-cpu/CMakeLists.txt b/ggml/src/ggml-cpu/CMakeLists.txt index bae8e967e8d9a..66a5ad8d2eddc 100644 --- a/ggml/src/ggml-cpu/CMakeLists.txt +++ b/ggml/src/ggml-cpu/CMakeLists.txt @@ -591,7 +591,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name) endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") - # The compiler automatically enables "-ffast-math" which can cause NaNs in tests due to "fassociative-math" + # The compiler automatically enables "-ffast-math" which can cause NaNs in tests due to "-fassociative-math" target_compile_options(${GGML_CPU_NAME} PRIVATE "-fno-associative-math") endif() endfunction()