fix(lora): add in F32 when the backend rejects mixed-type addition (#2383)

This commit is contained in:
Eugene Veretennikov 2026-11-24 16:49:27 +03:00 • committed by GitHub
parent 3b12781fac
commit 20e2b79f14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1053,6 +1053,12 @@ struct LoraModel : public GGMLRunner {
final_tensor = ggml_cpy(compute_ctx, final_tensor, model_tensor);
} else {
final_tensor = ggml_add_inplace(compute_ctx, model_tensor, diff);
if (diff->type != model_tensor->type && !ggml_backend_supports_op(runtime_backend, final_tensor)) {
// Rounding the delta before adding can erase a representable result.
final_tensor = ggml_cast(compute_ctx, model_tensor, GGML_TYPE_F32);
final_tensor = ggml_add_inplace(compute_ctx, final_tensor, diff);
final_tensor = ggml_cpy(compute_ctx, final_tensor, model_tensor);
}
}
ggml_build_forward_expand(gf, final_tensor);
if (!sd_backend_is_cpu(runtime_backend) && ggml_backend_buffer_is_host(original_tensor->buffer)) {