From ee7098e437ea64cf92f6c862b4aeab8869e9b5f0 Mon Sep 17 00:00:00 2001 From: akleine Date: Sun, 18 Oct 2026 12:03:03 +0200 Subject: [PATCH 1/2] feat: enhance decision in --lora-apply-mode auto If runnnig LoRAs using default --lora-apply-mode auto the automatic decision between modes "immediately" and "at_runtime" works very well, but there is still a minor gap if using command line options like --type q4_0 etc. --- src/pipeline/diffusion_engine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pipeline/diffusion_engine.cpp b/src/pipeline/diffusion_engine.cpp index 70338bd99..5a6b2e336 100644 --- a/src/pipeline/diffusion_engine.cpp +++ b/src/pipeline/diffusion_engine.cpp @@ -1077,6 +1077,12 @@ void StableDiffusionGGML::configure_weight_loading() { const bool params_offloaded = params_backend_for(SDBackendModule::DIFFUSION) != backend_for(SDBackendModule::DIFFUSION); const bool streaming_constrained = params_offloaded || backend_manager.params_backend_is_disk(SDBackendModule::DIFFUSION); + const ggml_type wtype_param = (int)sd_ctx_params->wtype < std::min(SD_TYPE_COUNT, GGML_TYPE_COUNT) + ? (ggml_type)sd_ctx_params->wtype + : GGML_TYPE_COUNT; + if (wtype_param < GGML_TYPE_COUNT) { + have_quantized_weight = have_quantized_weight || ggml_is_quantized(wtype_param); + } if (have_quantized_weight || streaming_constrained || row_split_active()) { apply_lora_immediately = false; } else { From a1ce56f37dfae0541c429fd0be63a4351bc44c53 Mon Sep 17 00:00:00 2001 From: akleine Date: Mon, 19 Oct 2026 14:35:52 +0200 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20decide=20LoRA=20mode=20by=20checkin?= =?UTF-8?q?g=20each=20tensor=E2=80=99s=20effective=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pipeline/diffusion_engine.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pipeline/diffusion_engine.cpp b/src/pipeline/diffusion_engine.cpp index 5a6b2e336..22ef3ac45 100644 --- a/src/pipeline/diffusion_engine.cpp +++ b/src/pipeline/diffusion_engine.cpp @@ -1058,9 +1058,15 @@ void StableDiffusionGGML::configure_weight_loading() { const auto& model_loader = model_manager->loader(); const auto wtype_stat = model_loader.get_wtype_stat(); bool have_int8_tensorwise = false; + bool have_quant_type_rule = false; for (const auto& [_, tensor_storage] : model_loader.get_tensor_storage_map()) { if (tensor_storage.is_int8_tensorwise) { have_int8_tensorwise = true; + } + if (tensor_storage.expected_type < GGML_TYPE_COUNT && ggml_is_quantized(tensor_storage.expected_type)) { + have_quant_type_rule = true; + } + if (have_int8_tensorwise && have_quant_type_rule) { break; } } @@ -1077,13 +1083,8 @@ void StableDiffusionGGML::configure_weight_loading() { const bool params_offloaded = params_backend_for(SDBackendModule::DIFFUSION) != backend_for(SDBackendModule::DIFFUSION); const bool streaming_constrained = params_offloaded || backend_manager.params_backend_is_disk(SDBackendModule::DIFFUSION); - const ggml_type wtype_param = (int)sd_ctx_params->wtype < std::min(SD_TYPE_COUNT, GGML_TYPE_COUNT) - ? (ggml_type)sd_ctx_params->wtype - : GGML_TYPE_COUNT; - if (wtype_param < GGML_TYPE_COUNT) { - have_quantized_weight = have_quantized_weight || ggml_is_quantized(wtype_param); - } - if (have_quantized_weight || streaming_constrained || row_split_active()) { + + if (have_quant_type_rule || have_quantized_weight || streaming_constrained || row_split_active()) { apply_lora_immediately = false; } else { apply_lora_immediately = true;