From: Johannes Gäßler Date: Sun, 22 Mar 2026 16:53:33 +0000 (+0100) Subject: CUDA: fix BF16 FA compilation (llama/20865) X-Git-Tag: v0.9.9~24 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=fd4e581b59290cc9ede8e87273580c92030da35d;p=pkg%2Fggml%2Fsources%2Fggml CUDA: fix BF16 FA compilation (llama/20865) --- diff --git a/src/ggml-cuda/convert.cuh b/src/ggml-cuda/convert.cuh index b8caeacf..f5d37c7b 100644 --- a/src/ggml-cuda/convert.cuh +++ b/src/ggml-cuda/convert.cuh @@ -42,11 +42,15 @@ template } else if constexpr(std::is_same_v && std::is_same_v) { return __float22half2_rn(x); } else if constexpr(std::is_same_v && std::is_same_v) { -#if !defined(GGML_USE_HIP) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800 +#ifdef GGML_USE_HIP + return make_float2(__bfloat162float(__low2bfloat16(x)), __bfloat162float(__high2bfloat16(x))); +#else +#if __CUDA_ARCH__ >= 800 return __bfloat1622float2(x); #else - return make_float2(__bfloat162float(__low2bfloat16(x)), __bfloat162float(__high2bfloat16(x))); -#endif // !defined(GGML_USE_HIP) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 800 + return make_float2(__bfloat162float(x.x), __bfloat162float(x.y)); +#endif // __CUDA_ARCH__ >= 800 +#endif // GGML_USE_HIP } else if constexpr(std::is_same_v && std::is_same_v) { // bypass compile error on cuda 12.0.1 #ifdef GGML_USE_HIP