From 203d0539fe6e745b4d5fb2b7ccc1ab384a71ba45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20du=20Hamel?= Date: Sat, 6 Dec 2025 03:47:52 +0100 Subject: [PATCH] Fix diffusers_style detection --- flux.hpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/flux.hpp b/flux.hpp index d0be65b..c500302 100644 --- a/flux.hpp +++ b/flux.hpp @@ -88,19 +88,19 @@ namespace Flux { public: SelfAttention(int64_t dim, - int64_t num_heads = 8, - bool qkv_bias = false, - bool proj_bias = true, - bool diffusers_style = false) + int64_t num_heads = 8, + bool qkv_bias = false, + bool proj_bias = true, + bool diffusers_style = false) : num_heads(num_heads) { int64_t head_dim = dim / num_heads; - if(diffusers_style) { - blocks["qkv"] = std::shared_ptr(new SplitLinear(dim, {dim, dim, dim}, qkv_bias)); + if (diffusers_style) { + blocks["qkv"] = std::shared_ptr(new SplitLinear(dim, {dim, dim, dim}, qkv_bias)); } else { - blocks["qkv"] = std::shared_ptr(new Linear(dim, dim * 3, qkv_bias)); + blocks["qkv"] = std::shared_ptr(new Linear(dim, dim * 3, qkv_bias)); } - blocks["norm"] = std::shared_ptr(new QKNorm(head_dim)); - blocks["proj"] = std::shared_ptr(new Linear(dim, dim, proj_bias)); + blocks["norm"] = std::shared_ptr(new QKNorm(head_dim)); + blocks["proj"] = std::shared_ptr(new Linear(dim, dim, proj_bias)); } std::vector pre_attention(GGMLRunnerContext* ctx, struct ggml_tensor* x) { @@ -782,8 +782,8 @@ namespace Flux { bool use_yak_mlp = false; bool use_mlp_silu_act = false; float ref_index_scale = 1.f; + bool diffusers_style = false; ChromaRadianceParams chroma_radiance_params; - bool diffusers_style = false; }; struct Flux : public GGMLBlock { @@ -1308,7 +1308,7 @@ namespace Flux { // not schnell flux_params.guidance_embed = true; } - if (tensor_name.find("model.diffusion_model.single_blocks.0.linear1.weight.1") == std::string::npos) { + if (tensor_name.find("model.diffusion_model.single_blocks.0.linear1.weight.1") != std::string::npos) { flux_params.diffusers_style = true; } if (tensor_name.find("distilled_guidance_layer.in_proj.weight") != std::string::npos) { @@ -1466,9 +1466,9 @@ namespace Flux { flux_params.ref_index_scale, flux_params.theta, flux_params.axes_dim, - sd_version_is_longcat(version)); + sd_version_is_longcat(version)); int pos_len = pe_vec.size() / flux_params.axes_dim_sum / 2; - auto pe = ggml_new_tensor_4d(compute_ctx, GGML_TYPE_F32, 2, 2, flux_params.axes_dim_sum / 2, pos_len); + auto pe = ggml_new_tensor_4d(compute_ctx, GGML_TYPE_F32, 2, 2, flux_params.axes_dim_sum / 2, pos_len); // pe->data = pe_vec.data(); // print_ggml_tensor(pe); // pe->data = nullptr;