@@ -86,10 +86,6 @@ class StableDiffusionGGML {
8686 ggml_backend_t clip_backend = NULL ;
8787 ggml_backend_t control_net_backend = NULL ;
8888 ggml_backend_t vae_backend = NULL ;
89- ggml_type model_wtype = GGML_TYPE_COUNT;
90- ggml_type conditioner_wtype = GGML_TYPE_COUNT;
91- ggml_type diffusion_model_wtype = GGML_TYPE_COUNT;
92- ggml_type vae_wtype = GGML_TYPE_COUNT;
9389
9490 SDVersion version;
9591 bool vae_decode_only = false ;
@@ -294,37 +290,33 @@ class StableDiffusionGGML {
294290 ggml_type wtype = (int )sd_ctx_params->wtype < std::min<int >(SD_TYPE_COUNT, GGML_TYPE_COUNT)
295291 ? (ggml_type)sd_ctx_params->wtype
296292 : GGML_TYPE_COUNT;
297- if (wtype == GGML_TYPE_COUNT) {
298- model_wtype = model_loader.get_sd_wtype ();
299- if (model_wtype == GGML_TYPE_COUNT) {
300- model_wtype = GGML_TYPE_F32;
301- LOG_WARN (" can not get mode wtype frome weight, use f32" );
302- }
303- conditioner_wtype = model_loader.get_conditioner_wtype ();
304- if (conditioner_wtype == GGML_TYPE_COUNT) {
305- conditioner_wtype = wtype;
306- }
307- diffusion_model_wtype = model_loader.get_diffusion_model_wtype ();
308- if (diffusion_model_wtype == GGML_TYPE_COUNT) {
309- diffusion_model_wtype = wtype;
310- }
311- vae_wtype = model_loader.get_vae_wtype ();
312-
313- if (vae_wtype == GGML_TYPE_COUNT) {
314- vae_wtype = wtype;
315- }
316- } else {
317- model_wtype = wtype;
318- conditioner_wtype = wtype;
319- diffusion_model_wtype = wtype;
320- vae_wtype = wtype;
293+ if (wtype != GGML_TYPE_COUNT) {
321294 model_loader.set_wtype_override (wtype);
322295 }
323296
324- LOG_INFO (" Weight type: %s" , ggml_type_name (model_wtype));
325- LOG_INFO (" Conditioner weight type: %s" , ggml_type_name (conditioner_wtype));
326- LOG_INFO (" Diffusion model weight type: %s" , ggml_type_name (diffusion_model_wtype));
327- LOG_INFO (" VAE weight type: %s" , ggml_type_name (vae_wtype));
297+ std::map<ggml_type, uint32_t > wtype_stat = model_loader.get_wtype_stat ();
298+ std::map<ggml_type, uint32_t > conditioner_wtype_stat = model_loader.get_conditioner_wtype_stat ();
299+ std::map<ggml_type, uint32_t > diffusion_model_wtype_stat = model_loader.get_diffusion_model_wtype_stat ();
300+ std::map<ggml_type, uint32_t > vae_wtype_stat = model_loader.get_vae_wtype_stat ();
301+
302+ auto wtype_stat_to_str = [](const std::map<ggml_type, uint32_t >& m, int key_width = 8 , int value_width = 5 ) -> std::string {
303+ std::ostringstream oss;
304+ bool first = true ;
305+ for (const auto & [type, count] : m) {
306+ if (!first)
307+ oss << " |" ;
308+ first = false ;
309+ oss << std::right << std::setw (key_width) << ggml_type_name (type)
310+ << " : "
311+ << std::left << std::setw (value_width) << count;
312+ }
313+ return oss.str ();
314+ };
315+
316+ LOG_INFO (" Weight type stat: %s" , wtype_stat_to_str (wtype_stat).c_str ());
317+ LOG_INFO (" Conditioner weight type stat: %s" , wtype_stat_to_str (conditioner_wtype_stat).c_str ());
318+ LOG_INFO (" Diffusion model weight type stat: %s" , wtype_stat_to_str (diffusion_model_wtype_stat).c_str ());
319+ LOG_INFO (" VAE weight type stat: %s" , wtype_stat_to_str (vae_wtype_stat).c_str ());
328320
329321 LOG_DEBUG (" ggml tensor size = %d bytes" , (int )sizeof (ggml_tensor));
330322
@@ -938,9 +930,6 @@ class StableDiffusionGGML {
938930 }
939931
940932 void apply_loras (const std::unordered_map<std::string, float >& lora_state) {
941- if (lora_state.size () > 0 && model_wtype != GGML_TYPE_F16 && model_wtype != GGML_TYPE_F32) {
942- LOG_WARN (" In quantized models when applying LoRA, the images have poor quality." );
943- }
944933 std::unordered_map<std::string, float > lora_state_diff;
945934 for (auto & kv : lora_state) {
946935 const std::string& lora_name = kv.first ;
0 commit comments