fix: avoid f16 overflow in Z-Image quantized matmuls on ROCm (#1771)

This commit is contained in:
Piotr Wilkin (ilintar)
2026-07-10 17:22:15 +02:00
committed by GitHub
parent 12b6fbff28
commit 9beb6aca69

View File

@@ -150,6 +150,8 @@ namespace ZImage {
if (sd_backend_is(ctx->backend, "ROCm")) {
out_proj->set_scale(1.f / 16.f);
out_proj->set_force_prec_f32(true);
qkv_proj->set_force_prec_f32(true);
}
auto qkv = qkv_proj->forward(ctx, x); // [N, n_token, (num_heads + num_kv_heads*2)*head_dim]
@@ -227,7 +229,7 @@ namespace ZImage {
auto w2 = std::dynamic_pointer_cast<Linear>(blocks["w2"]);
auto w3 = std::dynamic_pointer_cast<Linear>(blocks["w3"]);
if (sd_backend_is(ctx->backend, "Vulkan")) {
if (sd_backend_is(ctx->backend, "Vulkan") || sd_backend_is(ctx->backend, "ROCm")) {
w2->set_force_prec_f32(true);
}