Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.
TypeScript ai-photo-editorcomfyui-alternativegenerative-fillimage-editingimage-generationinpaintinglinuxlocal-aimacosmcpmcp-servernano-banana-alternativeofflinephoto-editorprivacyqwen-imageqwen-image-2-1stable-diffusion-cppvulkanwindows
Q4_K_M as the default image model; earlier installs keep the Q4_K until they accept
Gabriele Lozupone2af83dd3aefe
diff --git a/crates/qls-core/src/catalog.rs b/crates/qls-core/src/catalog.rsindex d5bc3e0..de6c23d 100644--- a/crates/qls-core/src/catalog.rs+++ b/crates/qls-core/src/catalog.rs@@ -379,21 +379,36 @@ pub fn apply_engine_release(m: &EngineManifest, app_version: &str) -> Result<booconst QWEN_TE: &str = "https://huggingface.co/Qwen/Qwen3-VL-8B-Instruct-GGUF/tree/main";-const TURBO_GGUF: &str = "https://huggingface.co/DogukanUrker/Qwen-Image-2.1-Turbo-GGUF";-/// The image model: Qwen's official 8-step distilled Qwen-Image 2.1 (Qwen/Qwen-Image-2.1-Turbo,-/// Qwen Research License like the base model), as a GGUF converted with stable-diffusion.cpp.-/// Same-seed A/B on an RTX 5070 Ti (2026-10-10): ~2x faster than the 20-step base model at-/// equal quality, faithful edits. The base Qwen-Image 2.1 weights were dropped on 2026-10-09.-/// Every preset uses this 4-bit file (user choice, 2026-10-09; the repo's Q4_K was judged-/// almost identical to its Q8_0).+/// Qwen Research License like the base model), as unsloth's GGUF. Same-seed A/B on an RTX 5070 Ti+/// (2026-10-10): ~2x faster than the 20-step base model at equal quality, faithful edits. The+/// base Qwen-Image 2.1 weights were dropped on 2026-10-09. Every preset uses this 4-bit file+/// (0.11.1): a tie with the Q4_K below on a same-seed vote (2026-10-25, RTX 5070 Ti, ~6 % slower+/// per job there), from a widely used source, and the file the Mac engine is checked against.+pub const TURBO_Q4_K_M: Download = Download {+ id: "turbo_q4_k_m",+ label: "Qwen-Image 2.1 Turbo Q4_K_M",+ kind: FileKind::Model,+ url: "https://huggingface.co/unsloth/Qwen-Image-2.1-Turbo-GGUF/resolve/main/qwen-image-2.1-turbo-Q4_K_M.gguf",+ fallback_urls: &[],+ page: "https://huggingface.co/unsloth/Qwen-Image-2.1-Turbo-GGUF",+ size: 4_199_565_120,+ sha256: "8940e8b522af886e0c0f5afddf720e82dd223cb9a43580b5f61c4d740452ac20",+ dest: "models/qwen21/qwen-image-2.1-turbo-Q4_K_M.gguf",+ provides: &[],+ engine_tag: None,+};++/// The image model installed up to 0.11.0 (DogukanUrker's GGUF conversion, made with+/// stable-diffusion.cpp). Kept while its owner has not chosen the Q4_K_M ([`official_dit`]);+/// deleted once they have ([`unused_old_dit`]).pub const TURBO_Q4_K: Download = Download {id: "turbo_q4_k",label: "Qwen-Image 2.1 Turbo Q4_K",kind: FileKind::Model,url: "https://huggingface.co/DogukanUrker/Qwen-Image-2.1-Turbo-GGUF/resolve/main/qwen-image-2.1-turbo-Q4_K.gguf",fallback_urls: &[],- page: TURBO_GGUF,+ page: "https://huggingface.co/DogukanUrker/Qwen-Image-2.1-Turbo-GGUF",size: 4_050_916_384,sha256: "f8d5611b495848b632f8ae14dc7da6525fe2796eb80998f8dee5e04d0a2f69eb",dest: "models/qwen21/qwen-image-2.1-turbo-Q4_K.gguf",@@ -401,6 +416,21 @@ pub const TURBO_Q4_K: Download = Download {engine_tag: None,};+/// The image model the official files of preset `p` use in `sdcpp_dir`: the preset's once it is+/// there, else the Q4_K of an earlier install (its owner has not accepted the new one), else the+/// preset's to download. Like [`official_vae`], nothing here downloads it uninvited.+pub fn official_dit(p: &Preset, sdcpp_dir: &Path) -> Download {+ if p.diffusion.id == TURBO_Q4_K_M.id && !TURBO_Q4_K_M.is_present(sdcpp_dir) && TURBO_Q4_K.is_present(sdcpp_dir) { TURBO_Q4_K } else { p.diffusion }+}++/// The Q4_K in the app's own folder once the Q4_K_M is there and no profile uses it any more,+/// so it can be deleted.+pub fn unused_old_dit(cfg: &crate::config::AppConfig) -> Option<PathBuf> {+ let old = TURBO_Q4_K.path(&cfg.sdcpp_dir);+ let used = cfg.profiles.iter().any(|p| p.diffusion_model == old);+ (TURBO_Q4_K_M.is_present(&cfg.sdcpp_dir) && !used && old.is_file()).then_some(old)+}+/// The VAE of new installs (0.9.3): Qwen's VAE with the decoder fine-tuned by madebyollin/// (author of TAESD) to remove the 2-px checkerboard of the original (#21). Same tensors and/// shapes, Qwen Research License like the model. Same-seed A/B on 5 cases at 1536² (2026-10-16):@@ -451,6 +481,33 @@ pub fn unused_original_vae(cfg: &crate::config::AppConfig) -> Option<PathBuf> {(VAE.is_present(&cfg.sdcpp_dir) && !used && old.is_file()).then_some(old)}+/// What the image-model update (0.11.1) offers for the active model.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]+#[serde(rename_all = "snake_case")]+pub enum DitUpdate {+ /// The official files still use the Q4_K: switch to the Q4_K_M and delete the Q4_K.+ Official,+ /// The user's own image model is that same Q4_K (any name, any folder): a suggestion to use+ /// the Q4_K_M from the app's folder instead. Their file is never touched.+ Own,+}++/// [`DitUpdate`] for the active model; None when it already uses the Q4_K_M or the user chose+/// another file (their choice: no offer).+pub fn dit_update(cfg: &crate::config::AppConfig) -> Option<DitUpdate> {+ dit_update_with(cfg, crate::modelfile::is_old_turbo_q4k)+}++/// [`dit_update`], `is_old` telling whether a file of the user's is the Q4_K.+fn dit_update_with(cfg: &crate::config::AppConfig, is_old: impl Fn(&Path) -> bool) -> Option<DitUpdate> {+ let p = cfg.profile();+ if p.is_official() {+ (p.diffusion_model == TURBO_Q4_K.path(&cfg.sdcpp_dir)).then_some(DitUpdate::Official)+ } else {+ is_old(&p.diffusion_model).then_some(DitUpdate::Own)+ }+}+/// Text encoder from Qwen's own GGUF repository (the one sd.cpp's docs point to).pub const TEXT_ENCODER_Q4_K_M: Download = Download {id: "text_encoder_q4_k_m",@@ -606,7 +663,7 @@ pub const PRESETS: &[Preset] = &[unified_label: "",unified_summary: "",min_vram_mib: 0,- diffusion: TURBO_Q4_K,+ diffusion: TURBO_Q4_K_M,text_encoder: TEXT_ENCODER_Q4_K_M,text_encoder_placement: TextEncoderPlacement::Ram,vram_reserve_gib: 1.5,@@ -619,7 +676,7 @@ pub const PRESETS: &[Preset] = &[unified_label: "16–24 GB Mac",unified_summary: "4-bit image model and text encoder; images of about 1–1.5 megapixels",min_vram_mib: 10 * 1024,- diffusion: TURBO_Q4_K,+ diffusion: TURBO_Q4_K_M,text_encoder: TEXT_ENCODER_Q4_K_M,text_encoder_placement: TextEncoderPlacement::Ram,vram_reserve_gib: 1.0,@@ -632,7 +689,7 @@ pub const PRESETS: &[Preset] = &[unified_label: "32–36 GB Mac",unified_summary: "4-bit image model and text encoder; native 2K for Quality",min_vram_mib: 14 * 1024,- diffusion: TURBO_Q4_K,+ diffusion: TURBO_Q4_K_M,text_encoder: TEXT_ENCODER_Q4_K_M,text_encoder_placement: TextEncoderPlacement::Ram,vram_reserve_gib: 1.0,@@ -645,7 +702,7 @@ pub const PRESETS: &[Preset] = &[unified_label: "48 GB Mac",unified_summary: "4-bit image model and text encoder; larger edits fit",min_vram_mib: 20 * 1024,- diffusion: TURBO_Q4_K,+ diffusion: TURBO_Q4_K_M,text_encoder: TEXT_ENCODER_Q4_K_M,text_encoder_placement: TextEncoderPlacement::Ram,vram_reserve_gib: 1.0,@@ -658,7 +715,7 @@ pub const PRESETS: &[Preset] = &[unified_label: "64 GB+ Mac",unified_summary: "4-bit image model and 8-bit text encoder",min_vram_mib: 28 * 1024,- diffusion: TURBO_Q4_K,+ diffusion: TURBO_Q4_K_M,text_encoder: TEXT_ENCODER_Q8_0,text_encoder_placement: TextEncoderPlacement::Ram,vram_reserve_gib: 1.0,@@ -699,7 +756,7 @@ pub fn downloads_for(p: &Preset, backend: GpuBackend, sdcpp_dir: &Path) -> Vec<Dif backend != GpuBackend::Metal {v.push(SUPERSCALE);}- v.extend([official_vae(sdcpp_dir), VISION_PROJECTOR, p.text_encoder, p.diffusion]);+ v.extend([official_vae(sdcpp_dir), VISION_PROJECTOR, p.text_encoder, official_dit(p, sdcpp_dir)]);v}@@ -707,7 +764,7 @@ pub fn downloads_for(p: &Preset, backend: GpuBackend, sdcpp_dir: &Path) -> Vec<D/// (a piece the user chose to download, or an official file deleted from their folder), each/// saved where the profile expects it. Existing files are never replaced, whatever their name.pub fn profile_model_downloads(profile: &crate::config::ModelProfile) -> Vec<Download> {- let official = [TURBO_Q4_K, VAE, VAE_ORIGINAL, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, VISION_PROJECTOR];+ let official = [TURBO_Q4_K_M, TURBO_Q4_K, VAE, VAE_ORIGINAL, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, VISION_PROJECTOR];profile.files().into_iter()@@ -768,7 +825,7 @@ mod tests {#[test]fn catalog_is_well_formed() {- let all = [ENGINE_CUDA, CUDA_RUNTIME, ENGINE_VULKAN, ENGINE_METAL, TURBO_Q4_K, VAE, VAE_ORIGINAL, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, VISION_PROJECTOR, UPSCALER, SUPERSCALE, ULTRASHARP];+ let all = [ENGINE_CUDA, CUDA_RUNTIME, ENGINE_VULKAN, ENGINE_METAL, TURBO_Q4_K_M, TURBO_Q4_K, VAE, VAE_ORIGINAL, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, VISION_PROJECTOR, UPSCALER, SUPERSCALE, ULTRASHARP];for d in all {assert!(d.urls().all(|u| u.starts_with("https://")), "{}", d.id);assert_eq!(d.sha256.len(), 64, "{}", d.id);@@ -974,6 +1031,82 @@ mod tests {assert_eq!(unused_original_vae(&cfg), Some(VAE_ORIGINAL.path(d)));}+ #[test]+ fn q4_k_m_replaces_the_q4_k_only_once_accepted() {+ use crate::config::{AppConfig, ModelProfile};+ let dir = tempfile::tempdir().unwrap();+ let d = dir.path();+ std::fs::create_dir_all(join_rel(d, MODEL_SUBDIR)).unwrap();+ let fill = |f: Download| std::fs::File::create(f.path(d)).unwrap().set_len(f.size).unwrap();+ let mut cfg = AppConfig { sdcpp_dir: d.to_path_buf(), ..Default::default() };+ cfg.normalize();+ // A new install gets the Q4_K_M on every preset, and nothing is offered.+ for p in PRESETS {+ assert_eq!(official_dit(p, d).id, "turbo_q4_k_m", "{}", p.id);+ assert!(downloads_for(p, GpuBackend::Cuda, d).iter().any(|x| x.id == "turbo_q4_k_m"));+ }+ assert_eq!(cfg.profile().diffusion_model, TURBO_Q4_K_M.path(d));+ assert_eq!(dit_update(&cfg), None);+ // An earlier install keeps its Q4_K until the user accepts (postponing changes nothing),+ // and no preset or engine update downloads the Q4_K_M uninvited.+ fill(TURBO_Q4_K);+ cfg.normalize();+ assert_eq!(cfg.profile().diffusion_model, TURBO_Q4_K.path(d));+ assert_eq!(cfg.profile().display_name, "Qwen-Image 2.1 Turbo Q4_K (official)");+ for p in PRESETS {+ assert!(downloads_for(p, GpuBackend::Vulkan, d).iter().all(|x| x.id != "turbo_q4_k_m"), "{}", p.id);+ }+ assert_eq!(dit_update(&cfg), Some(DitUpdate::Official));+ assert_eq!(unused_old_dit(&cfg), None, "in use");+ // An unfinished download changes nothing and deletes nothing.+ std::fs::write(TURBO_Q4_K_M.path(d), b"part").unwrap();+ cfg.use_new_dit();+ assert_eq!(cfg.profile().diffusion_model, TURBO_Q4_K.path(d));+ assert_eq!(unused_old_dit(&cfg), None);+ // Once downloaded and verified, the official files switch and the Q4_K can go.+ fill(TURBO_Q4_K_M);+ cfg.use_new_dit();+ assert_eq!(cfg.profile().diffusion_model, TURBO_Q4_K_M.path(d));+ assert_eq!(cfg.profile().display_name, "Qwen-Image 2.1 Turbo Q4_K_M (official)");+ assert_eq!(dit_update(&cfg), None);+ assert_eq!(unused_old_dit(&cfg), Some(TURBO_Q4_K.path(d)));+ // ...unless a profile of the user's points to it.+ cfg.set_user_files(ModelProfile::user(TURBO_Q4_K.path(d), VAE.path(d), d.join("te.gguf"), None));+ assert_eq!(unused_old_dit(&cfg), None);+ }++ #[test]+ fn own_files_only_get_a_suggestion() {+ use crate::config::{AppConfig, ModelProfile};+ let dir = tempfile::tempdir().unwrap();+ let d = dir.path().join("sd");+ std::fs::create_dir_all(join_rel(&d, MODEL_SUBDIR)).unwrap();+ let mine = dir.path().join("elsewhere").join("my turbo.gguf");+ std::fs::create_dir_all(mine.parent().unwrap()).unwrap();+ std::fs::write(&mine, b"the user's Q4_K").unwrap();+ let is_old = |p: &Path| p == mine;+ let mut cfg = AppConfig { sdcpp_dir: d.clone(), ..Default::default() };+ let own = |dit: &Path| ModelProfile::user(dit.to_path_buf(), dir.path().join("vae.safetensors"), dir.path().join("te.gguf"), None);+ // Their file is the old Q4_K (any name, any folder): a suggestion.+ cfg.set_user_files(own(&mine));+ assert_eq!(dit_update_with(&cfg, is_old), Some(DitUpdate::Own));+ // Already the Q4_K_M, or any other file: their choice, no offer.+ cfg.set_user_files(own(&dir.path().join("qwen-image-2.1-turbo-Q4_K_M.gguf")));+ assert_eq!(dit_update_with(&cfg, is_old), None);+ cfg.set_user_files(own(&dir.path().join("qwen_image_2.1_turbo-Q8_0.gguf")));+ assert_eq!(dit_update_with(&cfg, is_old), None);+ // Accepted: the profile points to the app's copy; their file stays where it is and is+ // never a candidate for deletion.+ cfg.set_user_files(own(&mine));+ std::fs::File::create(TURBO_Q4_K_M.path(&d)).unwrap().set_len(TURBO_Q4_K_M.size).unwrap();+ cfg.use_new_dit();+ assert_eq!(cfg.active_profile, crate::config::USER_PROFILE_ID);+ assert_eq!(cfg.profile().diffusion_model, TURBO_Q4_K_M.path(&d));+ assert_eq!(dit_update_with(&cfg, is_old), None);+ assert!(mine.is_file());+ assert_eq!(unused_old_dit(&cfg), None);+ }+#[test]fn presence_checks() {let dir = tempfile::tempdir().unwrap();diff --git a/crates/qls-core/src/config.rs b/crates/qls-core/src/config.rsindex d4144ea..5c1a611 100644--- a/crates/qls-core/src/config.rs+++ b/crates/qls-core/src/config.rs@@ -219,15 +219,16 @@ impl ModelProfile {/// The official weights a hardware preset downloads (GGUF of Qwen/Qwen-Image-2.1-Turbo,/// Qwen's own Qwen3-VL GGUF, the 2.1 VAE).pub fn official(sdcpp_dir: &Path, preset: &crate::catalog::Preset) -> Self {- use crate::catalog::{official_vae, VISION_PROJECTOR};- let quant = preset.diffusion.dest.rsplit('-').next().unwrap_or("").trim_end_matches(".gguf");+ use crate::catalog::{official_dit, official_vae, VISION_PROJECTOR};+ let diffusion = official_dit(preset, sdcpp_dir);+ let quant = diffusion.dest.rsplit('-').next().unwrap_or("").trim_end_matches(".gguf");Self {id: OFFICIAL_PROFILE_ID.into(),display_name: format!("Qwen-Image 2.1 Turbo {quant} (official)"),model: QWEN_IMAGE_21.into(),source: ProfileSource::Official,scan_dir: None,- diffusion_model: preset.diffusion.path(sdcpp_dir),+ diffusion_model: diffusion.path(sdcpp_dir),vae: official_vae(sdcpp_dir).path(sdcpp_dir),text_encoder: preset.text_encoder.path(sdcpp_dir),vision_projector: Some(VISION_PROJECTOR.path(sdcpp_dir)),@@ -702,6 +703,18 @@ impl AppConfig {self.normalize();}+ /// Makes the active model use the Q4_K_M image model in the app's folder, once downloaded.+ /// The official files switch by themselves (`catalog::official_dit`); the user's own profile+ /// points to it instead of their file, which stays where it is.+ pub fn use_new_dit(&mut self) {+ let dit = crate::catalog::TURBO_Q4_K_M.path(&self.sdcpp_dir);+ let active = self.active_profile.clone();+ if let Some(p) = self.profiles.iter_mut().find(|p| p.id == active && !p.is_official()) {+ p.diffusion_model = dit;+ }+ self.normalize();+ }+/// Makes the official files the active model (they may still need downloading).pub fn use_official(&mut self) {self.normalize();@@ -922,7 +935,8 @@ impl AppConfig {}/// [`AppConfig::model_vram_extra_mib`] for files of these sizes (bytes; text encoder plus-/// vision projector together). Smaller files give nothing back: the budgets stay as measured.+/// vision projector together). Smaller files give nothing back: the budgets stay as measured+/// (with the Q4_K; the default Q4_K_M counts its extra ~140 MiB).fn extra_weights_mib(diffusion: u64, text_encoder: u64, unified: bool) -> u64 {use crate::catalog::{TEXT_ENCODER_Q4_K_M, TURBO_Q4_K, VISION_PROJECTOR};let mut extra = diffusion.saturating_sub(TURBO_Q4_K.size);@@ -1089,9 +1103,13 @@ mod tests {let c = AppConfig::default();let p = c.profile();assert_eq!(p.id, OFFICIAL_PROFILE_ID);- assert_eq!(p.display_name, "Qwen-Image 2.1 Turbo Q4_K (official)");- assert!(p.diffusion_model.ends_with("qwen-image-2.1-turbo-Q4_K.gguf"));assert!(p.diffusion_model.starts_with(default_sdcpp_dir()));+ // A new install (no earlier model file in the folder) gets the Q4_K_M.+ let dir = tempfile::tempdir().unwrap();+ let mut fresh = AppConfig { sdcpp_dir: dir.path().to_path_buf(), ..AppConfig::default() };+ fresh.normalize();+ assert_eq!(fresh.profile().display_name, "Qwen-Image 2.1 Turbo Q4_K_M (official)");+ assert!(fresh.profile().diffusion_model.ends_with("qwen-image-2.1-turbo-Q4_K_M.gguf"));assert_eq!(c.hardware_preset, "16gb");assert_eq!(c.planning_vram_mib(Some(16303)), Some(16303));assert_eq!(c.device, "cuda0");@@ -1153,14 +1171,14 @@ mod tests {let off = c.profiles.iter().find(|p| p.id == OFFICIAL_PROFILE_ID).unwrap();// Catalog paths are joined per component, so the separator is the platform's own.let sd = |f: &str| crate::catalog::join_rel(Path::new(r"D:\sd"), &format!("models/qwen21/{f}"));- assert_eq!(off.diffusion_model, sd("qwen-image-2.1-turbo-Q4_K.gguf"));+ assert_eq!(off.diffusion_model, sd("qwen-image-2.1-turbo-Q4_K_M.gguf"));// Saved again, nothing is added twice.c.save_to(&p).unwrap();assert_eq!(AppConfig::load_from(&p).profiles.len(), 2);// A file without profiles uses its own folder and preset.std::fs::write(&p, r#"{"sdcppDir":"D:\\sd","hardwarePreset":"24gb"}"#).unwrap();let c = AppConfig::load_from(&p);- assert_eq!(c.profile().diffusion_model, sd("qwen-image-2.1-turbo-Q4_K.gguf"));+ assert_eq!(c.profile().diffusion_model, sd("qwen-image-2.1-turbo-Q4_K_M.gguf"));}#[test]@@ -1188,13 +1206,14 @@ mod tests {#[test]fn presets_switch_weights_and_keep_tuning() {- let mut c = AppConfig::default();+ let dir = tempfile::tempdir().unwrap();+ let mut c = AppConfig { sdcpp_dir: dir.path().to_path_buf(), ..AppConfig::default() };c.profiles[0].recommended_settings.area_fast = 768 * 768;c.apply_preset(crate::catalog::preset("32gb").unwrap());let p = c.profile();- assert!(p.diffusion_model.ends_with("qwen-image-2.1-turbo-Q4_K.gguf"), "4-bit Turbo on every preset");+ assert!(p.diffusion_model.ends_with("qwen-image-2.1-turbo-Q4_K_M.gguf"), "4-bit Turbo on every preset");assert!(p.text_encoder.ends_with("Qwen3VL-8B-Instruct-Q8_0.gguf"));- assert_eq!(p.display_name, "Qwen-Image 2.1 Turbo Q4_K (official)");+ assert_eq!(p.display_name, "Qwen-Image 2.1 Turbo Q4_K_M (official)");assert_eq!(p.recommended_settings.area_fast, 768 * 768);assert_eq!((c.hardware_preset.as_str(), c.profiles.len()), ("32gb", 1));c.vram_override_mib = 12_288;@@ -1234,8 +1253,8 @@ mod tests {std::fs::write(&p, old).unwrap();let c = AppConfig::load_from(&p);let off = c.profile();- assert_eq!(off.diffusion_model, crate::catalog::join_rel(Path::new(r"D:\sd"), "models/qwen21/qwen-image-2.1-turbo-Q4_K.gguf"));- assert_eq!(off.display_name, "Qwen-Image 2.1 Turbo Q4_K (official)");+ assert_eq!(off.diffusion_model, crate::catalog::join_rel(Path::new(r"D:\sd"), "models/qwen21/qwen-image-2.1-turbo-Q4_K_M.gguf"));+ assert_eq!(off.display_name, "Qwen-Image 2.1 Turbo Q4_K_M (official)");assert_eq!(off.backend_args, vec!["--x".to_string()], "launch flags stay");assert_eq!(off.recommended_settings, RecommendedSettings::default());let mine = c.profiles.iter().find(|p| p.id == "mine").unwrap();diff --git a/crates/qls-core/src/engine.rs b/crates/qls-core/src/engine.rsindex 397ba26..f5b82a2 100644--- a/crates/qls-core/src/engine.rs+++ b/crates/qls-core/src/engine.rs@@ -429,6 +429,17 @@ impl Engine {}}+ /// Deletes the Q4_K image model from the app's folder once the Q4_K_M replaced it and no+ /// profile uses it (after the update, and at start in case a busy server held it open).+ /// Files outside the app's folder are never deleted.+ pub fn remove_unused_old_dit(&self) {+ let Some(old) = crate::catalog::unused_old_dit(&self.config()) else { return };+ match std::fs::remove_file(&old) {+ Ok(()) => tracing::info!("deleted the Q4_K image model {} (replaced by the Q4_K_M)", old.display()),+ Err(e) => tracing::warn!("could not delete the Q4_K image model {} yet: {e}", old.display()),+ }+ }+/// The installed engine is from another release than the catalog's (or the engine/// manifest's): Setup offers the update. An engine without a release marker (built by hand,/// an external server) only needs it when it cannot run the upscaler.diff --git a/crates/qls-core/src/modelfile.rs b/crates/qls-core/src/modelfile.rsindex 3d76c03..4816fdf 100644--- a/crates/qls-core/src/modelfile.rs+++ b/crates/qls-core/src/modelfile.rs@@ -17,7 +17,7 @@ use std::path::{Path, PathBuf};use serde::{Deserialize, Serialize};-use crate::catalog::{Download, Preset, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, TURBO_Q4_K, VAE, VAE_ORIGINAL, VISION_PROJECTOR};+use crate::catalog::{Download, Preset, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, TURBO_Q4_K, TURBO_Q4_K_M, VAE, VAE_ORIGINAL, VISION_PROJECTOR};use crate::config::ModelProfile;use crate::error::AppError;@@ -158,10 +158,24 @@ struct Tensor {dtype: String,}+/// Fingerprint of [`TURBO_Q4_K`], the image model installed up to 0.11.0.+const OLD_TURBO_Q4_K_FINGERPRINT: &str = "7fe006396566cac6819c2eb78ef3f01f";++/// `path` is the image model installed up to 0.11.0 (DogukanUrker's Q4_K), under any name and+/// in any folder: same size and fingerprint. Own files like it are offered the Q4_K_M.+pub fn is_old_turbo_q4k(path: &Path) -> bool {+ is_known_file(path, TURBO_Q4_K.size, OLD_TURBO_Q4_K_FINGERPRINT)+}++/// `path` has this size and fingerprint (only a file of that size is read).+fn is_known_file(path: &Path, size: u64, fp: &str) -> bool {+ std::fs::metadata(path).is_ok_and(|m| m.is_file() && m.len() == size) && fingerprint(path, size).is_ok_and(|f| f == fp)+}+/// The catalog download a file with this name and size is (any folder).pub fn official_download(path: &Path, size: u64) -> Option<Download> {let name = path.file_name()?.to_string_lossy().to_ascii_lowercase();- [TURBO_Q4_K, VAE, VAE_ORIGINAL, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, VISION_PROJECTOR]+ [TURBO_Q4_K_M, TURBO_Q4_K, VAE, VAE_ORIGINAL, TEXT_ENCODER_Q4_K_M, TEXT_ENCODER_Q8_0, VISION_PROJECTOR].into_iter().find(|d| d.size == size && d.dest.rsplit('/').next().is_some_and(|f| f.eq_ignore_ascii_case(&name)))}@@ -811,6 +825,19 @@ pub(crate) mod tests {assert_eq!(best(&scan_with(dir.path(), 0), None).text_encoder, None);}+ #[test]+ fn old_q4k_is_known_by_size_and_fingerprint() {+ let dir = tempfile::tempdir().unwrap();+ let f = dir.path().join("any name.gguf");+ std::fs::write(&f, vec![7u8; 200_000]).unwrap();+ let fp = fingerprint(&f, 200_000).unwrap();+ assert!(is_known_file(&f, 200_000, &fp));+ assert!(!is_known_file(&f, 200_001, &fp), "another size is never read");+ assert!(!is_known_file(&f, 200_000, OLD_TURBO_Q4_K_FINGERPRINT), "same size, other content");+ assert!(!is_known_file(&dir.path().join("gone.gguf"), 200_000, &fp));+ assert!(!is_old_turbo_q4k(&f));+ }+#[test]fn warns_about_known_base_files_only() {// Useful_Disaster_7606 (Reddit, 10-24): the base 2.1 GGUF at 8 steps, no warning.diff --git a/crates/qls-core/src/process.rs b/crates/qls-core/src/process.rsindex ec16eae..b7e85b4 100644--- a/crates/qls-core/src/process.rs+++ b/crates/qls-core/src/process.rs@@ -858,7 +858,7 @@ mod tests {let s = a.join(" ");let m = |f: &str| crate::catalog::join_rel(&cfg.sdcpp_dir, &format!("models/qwen21/{f}")).display().to_string();assert!(s.starts_with("--listen-ip 127.0.0.1 --listen-port 39150"));- assert!(s.contains(&format!("--diffusion-model {}", m("qwen-image-2.1-turbo-Q4_K.gguf"))));+ assert!(s.contains(&format!("--diffusion-model {}", m("qwen-image-2.1-turbo-Q4_K_M.gguf"))));assert!(s.contains(&format!("--vae {}", m("texture_fix_vae_for_qwen_image_2.1_bf16.safetensors"))));assert!(s.contains(&format!("--llm {}", m("Qwen3VL-8B-Instruct-Q4_K_M.gguf"))));assert!(s.contains(&format!("--llm_vision {}", m("mmproj-Qwen3VL-8B-Instruct-F16.gguf"))));diff --git a/crates/qls-core/src/remote.rs b/crates/qls-core/src/remote.rsindex fd253cd..1b3ef8b 100644--- a/crates/qls-core/src/remote.rs+++ b/crates/qls-core/src/remote.rs@@ -273,7 +273,7 @@ pub fn browser_allowed(method: &str, path: &str) -> bool {("GET" | "PUT" | "DELETE", ["projects", _]) => true,("PUT", ["config"]) => true,("POST", ["setup", "install" | "gpu"] | ["setup", "install", "cancel"]) => true,- ("POST", ["models", "use" | "vae"]) => true,+ ("POST", ["models", "use" | "vae" | "dit"]) => true,("POST", ["upscalers", _, "download"]) => true,("POST", ["backend", "start" | "stop" | "restart"]) => true,("POST", ["plan" | "jobs" | "inputs" | "examples"] | ["projects", "import"]) => true,diff --git a/crates/qls-service/src/api.rs b/crates/qls-service/src/api.rsindex 94e56d7..733704c 100644--- a/crates/qls-service/src/api.rs+++ b/crates/qls-service/src/api.rs@@ -77,6 +77,7 @@ pub fn router(state: Arc<AppState>, lan: bool) -> Router {.route("/models/user", post(models_set_user)).route("/models/use", post(models_use)).route("/models/vae", post(models_improve_vae))+ .route("/models/dit", post(models_new_dit)).route("/upscalers", get(list_upscalers)).route("/upscalers/{name}/download", post(download_upscaler)).route("/config", get(get_config).put(put_config))@@ -1459,6 +1460,43 @@ async fn models_improve_vae(State(s): St) -> ApiResult<Json<Value>> {Ok(Json(serde_json::to_value(s.engine.installer.status()).unwrap()))}+/// Downloads the Q4_K_M image model into the app's folder and makes the active model use it+/// (progress in `/setup/install`), like [`models_improve_vae`]: the server restarts once idle,+/// then the Q4_K in the app's folder is deleted if no profile uses it. The user's own files are+/// never deleted.+async fn models_new_dit(State(s): St) -> ApiResult<Json<Value>> {+ let dir = s.engine.config().sdcpp_dir;+ let engine = s.engine.clone();+ let on_finish = Box::new(move |complete: bool| {+ if !complete {+ return;+ }+ let mut c = engine.config();+ c.use_new_dit();+ let restart = match engine.set_config(c) {+ Ok(r) => r,+ Err(e) => return tracing::error!("could not switch to the Q4_K_M image model: {}", e.message),+ };+ tracing::info!("switched to the Q4_K_M image model");+ tokio::spawn(async move {+ if restart {+ while engine.has_pending_work() {+ tokio::time::sleep(Duration::from_secs(2)).await;+ }+ let st = engine.server.status();+ if st.owned && st.state != qls_core::process::ServerState::Stopped {+ engine.server.stop().await;+ engine.emit_server();+ }+ }+ let e = engine.clone();+ let _ = tokio::task::spawn_blocking(move || e.remove_unused_old_dit()).await;+ });+ });+ s.engine.installer.start(dir, "dit", vec![catalog::TURBO_Q4_K_M], on_finish)?;+ Ok(Json(serde_json::to_value(s.engine.installer.status()).unwrap()))+}+fn role_of(label: &str) -> Option<Role> {Role::ALL.into_iter().find(|r| r.label() == label)}@@ -1501,6 +1539,12 @@ async fn models_status(State(s): St) -> ApiResult<Json<Value>> {"download_bytes": if catalog::VAE.is_present(&cfg.sdcpp_dir) { 0 } else { catalog::VAE.size },"page": catalog::VAE.page,},+ // The Q4_K_M image model (0.11.1): what is offered, and what switching downloads.+ "dit": {+ "update": catalog::dit_update(&cfg),+ "download_bytes": if catalog::TURBO_Q4_K_M.is_present(&cfg.sdcpp_dir) { 0 } else { catalog::TURBO_Q4_K_M.size },+ "page": catalog::TURBO_Q4_K_M.page,+ },})}).awaitdiff --git a/crates/qls-service/src/main.rs b/crates/qls-service/src/main.rsindex 2aa9d2e..38ce0a0 100644--- a/crates/qls-service/src/main.rs+++ b/crates/qls-service/src/main.rs@@ -296,8 +296,9 @@ async fn run(args: Vec<String>) {// The upscaler ships with the app: put it where sd-server looks (no download needed).let e = engine.clone();let _ = tokio::task::spawn_blocking(move || e.place_bundled_upscaler()).await;- // The original VAE left behind when a busy server held it open during the update.+ // The original VAE or Q4_K model left behind when a busy server held it open during the update.engine.remove_unused_original_vae();+ engine.remove_unused_old_dit();let token = load_or_create_token(&dir);let info = ServiceInfo { port, token: token.clone(), pid: std::process::id(), version: APP_VERSION.into() };let _ = std::fs::write(service_info_path(), serde_json::to_string_pretty(&info).unwrap());@@ -355,6 +356,7 @@ async fn run(args: Vec<String>) {tracing::info!("stopped sd-server on exit");}engine.remove_unused_original_vae();+ engine.remove_unused_old_dit();} else {tracing::info!("leaving sd-server running (keep_server_running)");}diff --git a/docs/http-api.md b/docs/http-api.mdindex b7e94fc..0c7bf6e 100644--- a/docs/http-api.md+++ b/docs/http-api.md@@ -139,6 +139,7 @@ result (`"kind": "gen"`, `genId`) or an imported image (`"kind": "input"`, `inpu| POST | `/models/scan`, `/models/inspect` | List the model files in a folder (sub-folders included) with the suggested file for each role; inspect one file by `{"path": "..."}` || POST | `/models/user`, `/models/use` | Save your own model files as a profile; switch between the official files and yours || POST | `/models/vae` | Download the texture-fix VAE and make the active model use it (progress in `/setup/install`) |+| POST | `/models/dit` | Download the Q4_K_M image model and make the active model use it (progress in `/setup/install`) || GET | `/upscalers` | The upscalers Settings offers and whether each is installed || POST | `/upscalers/{name}/download` | Download one upscaler (progress in `/setup/install`) || GET, POST | `/loras` | List LoRAs; add one from a path: `{"path": "..."}` (copied into Kokon's LoRA folder) |diff --git a/src/components/OwnModels.tsx b/src/components/OwnModels.tsxindex fcb3d42..4eab995 100644--- a/src/components/OwnModels.tsx+++ b/src/components/OwnModels.tsx@@ -135,7 +135,8 @@ export function OwnModels(props: {const teHasVision = !!teInfo?.has_vision;const officialSize = (role: ModelRole) => {const id = ROLES.find((r) => r.role === role)!.official;- return props.officialFiles.find((f) => f.id === id || (id === "text_encoder" && f.id.startsWith("text_encoder")))?.size ?? 0;+ // By family: the text encoder of the preset, the image model the official files use.+ return props.officialFiles.find((f) => f.id === id || f.id.startsWith(`${id}_`))?.size ?? 0;};// What each row says, and whether the set can be used.