Skip to content

armgit / kokon

Public Imported from GitHub
0

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.

Mac: use the device name the Metal build reports (mtl0)

Gabriele Lozupone855ad90e182f
diff --git a/crates/qls-core/src/config.rs b/crates/qls-core/src/config.rs
index 97470d8..365cc51 100644
--- a/crates/qls-core/src/config.rs
+++ b/crates/qls-core/src/config.rs
@@ -82,7 +82,8 @@ impl GpuBackend {
match self {
GpuBackend::Cuda => "cuda",
GpuBackend::Vulkan => "vulkan",
- GpuBackend::Metal => "metal",
+ // ggml registers the Mac GPU as "MTL0" (`--list-devices`, seen on an M2 Pro).
+ GpuBackend::Metal => "mtl",
}
}
@@ -599,10 +600,6 @@ impl AppConfig {
/// The configured device when it belongs to the active engine, else its first GPU.
pub fn effective_device(&self) -> String {
let dev = self.device.trim().to_ascii_lowercase();
- if self.gpu_backend == GpuBackend::Metal {
- // sd-server resolves "metal" to the Mac's GPU (ggml names it MTL0).
- return "metal".into();
- }
let prefix = self.gpu_backend.device_prefix();
match dev.strip_prefix(prefix) {
Some(i) if !i.is_empty() && i.chars().all(|c| c.is_ascii_digit()) => dev,
@@ -706,7 +703,7 @@ mod tests {
assert_eq!(GpuBackend::for_vendor("apple"), GpuBackend::Metal);
c.gpu_backend = GpuBackend::Metal;
c.device = "cuda0".into();
- assert_eq!(c.effective_device(), "metal");
+ assert_eq!(c.effective_device(), "mtl0", "matches MTL0 in --list-devices");
assert_eq!(c.engine_dir(), c.sdcpp_dir.join("engine-metal"));
assert!(!c.uses_sage_attention());
// Configs written before the field existed keep this platform's engine.
diff --git a/crates/qls-core/src/process.rs b/crates/qls-core/src/process.rs
index f85e54d..fe11c40 100644
--- a/crates/qls-core/src/process.rs
+++ b/crates/qls-core/src/process.rs
@@ -860,12 +860,12 @@ mod tests {
let mut cfg = AppConfig::default();
cfg.gpu_backend = crate::config::GpuBackend::Metal;
let s = build_server_args(&cfg, cfg.profile()).join(" ");
- assert!(s.contains("--backend metal --auto-fit off --mmap --fa"), "RAM placement runs everything on the GPU: {s}");
+ assert!(s.contains("--backend mtl0 --auto-fit off --mmap --fa"), "RAM placement runs everything on the GPU: {s}");
assert!(!s.contains("--params-backend") && !s.contains("--sage-attn"));
assert!(s.contains("--mmap") && s.contains("--eager-load"));
cfg.text_encoder_placement = TextEncoderPlacement::Disk;
let s = build_server_args(&cfg, cfg.profile()).join(" ");
- assert!(s.contains("--backend metal --params-backend disk"), "{s}");
+ assert!(s.contains("--backend mtl0 --params-backend disk"), "{s}");
assert!(!s.contains("--eager-load"), "nothing to preload when weights stream from disk");
}
@@ -938,6 +938,15 @@ mod tests {
vec![("CUDA0".into(), "NVIDIA GeForce RTX 5070 Ti".into()), ("CPU".into(), "AMD Ryzen 7 7700 8-Core Processor".into())]
);
// ggml's Vulkan backend (device names as ggml registers them; not yet captured from a real run).
+ // Device names reported by the Metal build on an M2 Pro (2026-10-09); descriptions illustrative.
+ let out = "MTL0 Apple M2 Pro
+BLAS Accelerate
+CPU Apple M2 Pro
+";
+ assert_eq!(parse_device_list(out)[0].0, "MTL0");
+ let mut cfg = AppConfig::default();
+ cfg.gpu_backend = crate::config::GpuBackend::Metal;
+ assert!(parse_device_list(out).iter().any(|(n, _)| n.to_ascii_lowercase() == cfg.effective_device()));
let out = "ggml_vulkan: Found 1 Vulkan devices:\nggml_vulkan: 0 = AMD Radeon RX 7800 XT (AMD proprietary driver) | uma: 0 | fp16: 1\nVulkan0\tAMD Radeon RX 7800 XT\nCPU\tAMD Ryzen 7 7700\n";
assert_eq!(parse_device_list(out)[0], ("Vulkan0".into(), "AMD Radeon RX 7800 XT".into()));
}