From fa794d3d0416efe7d0fb30b907887423e9769a8b Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Thu, 11 Dec 2025 21:52:46 -0300 Subject: [PATCH] fix: avoid crash loading LoRAs with bf16 weights fixes #1076 --- ggml_extend.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ggml_extend.hpp b/ggml_extend.hpp index 5024eb911..07b9bfbf0 100644 --- a/ggml_extend.hpp +++ b/ggml_extend.hpp @@ -1400,10 +1400,14 @@ __STATIC_INLINE__ void ggml_ext_backend_tensor_get_and_sync(ggml_backend_t backe } __STATIC_INLINE__ float ggml_ext_backend_tensor_get_f32(ggml_tensor* tensor) { - GGML_ASSERT(tensor->type == GGML_TYPE_F32 || tensor->type == GGML_TYPE_F16 || tensor->type == GGML_TYPE_I32); + GGML_ASSERT(tensor->type == GGML_TYPE_F32 || tensor->type == GGML_TYPE_F16 || tensor->type == GGML_TYPE_I32 || tensor->type == GGML_TYPE_BF16); float value; if (tensor->type == GGML_TYPE_F32) { ggml_backend_tensor_get(tensor, &value, 0, sizeof(value)); + } else if (tensor->type == GGML_TYPE_BF16) { + ggml_bf16_t bf16_value; + ggml_backend_tensor_get(tensor, &bf16_value, 0, sizeof(bf16_value)); + value = ggml_bf16_to_fp32(bf16_value); } else if (tensor->type == GGML_TYPE_F16) { ggml_fp16_t f16_value; ggml_backend_tensor_get(tensor, &f16_value, 0, sizeof(f16_value));