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
Mac engine on by default on Macs with 16 GB or more
Gabriele Lozuponec1d2df24bbb4
diff --git a/README.md b/README.mdindex e5a866f..132a17d 100644--- a/README.md+++ b/README.md@@ -615,9 +615,10 @@ image at Balanced in about 80 s (first image, model loading included); Intel Arcuntested, and integrated graphics are not supported. Please[open an issue](https://github.com/GabrieleLozupone/kokon/issues) with your card and how it went.-Mac: yes, in beta, on Apple Silicon (M1 or newer) with macOS 15 Sequoia or newer. It runs on a-16 GB Mac in a lighter mode, but slowly (about 4 minutes per 1-megapixel image on an M2 Pro);-32 GB or more and a Pro, Max or Ultra chip are recommended. See the [requirements](#requirements)+Mac: yes, in beta, on Apple Silicon (M1 or newer) with macOS 15 Sequoia or newer. Since 0.12 Kokon runs its own+Mac engine by default on Macs with 16 GB or more: about a minute per new 1-megapixel image on an M2 Pro (about 106 s+for an edit), four times faster than before. LoRAs and the upscaler model still use the standard engine (Settings →+Performance). 32 GB or more and a Pro, Max or Ultra chip are recommended. See the [requirements](#requirements)and [docs/platforms.md](docs/platforms.md).Linux: yes, in beta, on x86-64 with a `.deb` (Ubuntu, Debian, Mint) or an `.rpm` (Fedora). NVIDIAdiff --git a/crates/qls-core/src/config.rs b/crates/qls-core/src/config.rsindex f0d3fe2..9edf520 100644--- a/crates/qls-core/src/config.rs+++ b/crates/qls-core/src/config.rs@@ -338,10 +338,11 @@ pub struct AppConfig {pub upscale_prescale: bool,pub extra_server_args: Vec<String>,/// Kokon's own engine for Apple Silicon (`engine-mac/`, `kokon-engine-mac serve`) instead of sd.cpp's Metal build:- /// the GPU, the CPU's matrix unit and the Neural Engine together, ~4x faster text to image on an M2 Pro. Experimental- /// and off by default (Settings → Performance). Text to image, edits with references, brushed edits, extending an- /// image and Prompt+; no LoRAs or second passes yet (`Capabilities::mac_engine_unsupported`). sd.cpp stays the default,- /// the fallback, and the engine on Windows and Linux.+ /// the GPU, the CPU's matrix unit and the Neural Engine together, ~4x faster text to image on an M2 Pro. Experimental;+ /// false in a new config, but the default on Macs with 16 GB+ since 0.12: the desktop app switches it on once at+ /// start (`macEngineDefaultDue` in src/lib/logic.ts) unless the user already chose (Settings → Performance). Text to image, edits with references, brushed edits, extending an+ /// image and Prompt+; no LoRAs or second passes yet (`Capabilities::mac_engine_unsupported`). sd.cpp stays the fallback,+ /// the engine on Windows and Linux and on smaller Macs.pub mac_engine: bool,pub output_dir: PathBuf,pub keep_server_running: bool,diff --git a/engine-mac/README.md b/engine-mac/README.mdindex 8809260..5f9e05b 100644--- a/engine-mac/README.md+++ b/engine-mac/README.md@@ -31,9 +31,10 @@ python3 -I tools/compare_bench.py baseline-report.json kokon-bench-report.jsonIn the app: Kokon.app carries the engine (1.7 MB: `Contents/MacOS/kokon-engine-mac`, the kernels in`Contents/Resources/engine-mac/`; `tools/stage-app.sh`, called by `scripts/dev/mac-dev.sh` and-`scripts/build-release-mac.sh`), and Settings → Performance → "Kokon's Mac engine (experimental)" turns it on. Off by-default; at the first start on a Mac with 16 GB or more Kokon offers it once, before the model loads. sd.cpp stays the-default, the fallback, and the engine on Windows and Linux. Without the app's copy (a service run with `cargo run`),+`scripts/build-release-mac.sh`), and Settings → Performance → "Kokon's Mac engine (experimental)" switches it. Since 0.12 it+is the default on Macs with 16 GB or more: at the first start Kokon switches it on once, before the model loads, unless+the user already chose (0.11's "Not now", or Settings). sd.cpp stays the fallback (LoRAs, the upscaler model) and the+engine on Windows and Linux and on smaller Macs. Without the app's copy (a service run with `cargo run`),`bash tools/install-dev.sh` puts the build in the stable-diffusion.cpp folder; `kokon-engine-mac kernels` prints wherethe kernels were found.diff --git a/src/App.tsx b/src/App.tsxindex 45aa2e4..c837d77 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -4,9 +4,9 @@ import { useEffect, useRef, useState } from "react";import { api, ApiError, configure, setSignedOutHandler } from "./lib/api";import { native } from "./lib/native";import { inBrowser, isNarrow, useNarrow } from "./lib/platform";-import { macEngineOfferDue } from "./lib/logic";+import { macEngineDefaultDue } from "./lib/logic";import {- addExampleProjects, closeStarPrompt, loadProjects, dismissToast, getState, initStarPrompt, redoVersion, refreshLoras, refreshStatus, selectItem, setState, startEvents, startTour, submitComposer, toastError, toastInfo, undoVersion, useStore,+ addExampleProjects, closeStarPrompt, loadProjects, dismissToast, getState, initStarPrompt, redoVersion, refreshLoras, refreshStatus, selectItem, setState, startEvents, startTour, submitComposer, toastError, toastInfo, turnOnMacEngine, undoVersion, useStore,} from "./lib/store";import { Composer, importPaths, uploadFiles } from "./components/Composer";import { Login } from "./components/Login";@@ -23,7 +23,6 @@ import { PromptTips } from "./components/PromptTips";import { Shortcuts } from "./components/Shortcuts";import { AiCheck } from "./components/AiCheck";import { WhatsNew, whatsNewDue } from "./components/WhatsNew";-import { MacEngineOffer } from "./components/MacEngineOffer";import { UpscalerCompare } from "./components/Upscalers";import { KokonMark, Welcome } from "./components/Welcome";import { PhoneApp } from "./components/PhoneApp";@@ -171,9 +170,10 @@ export default function App() {// After an app update: what's new, with the engine and model downloads the release offers// (they can be postponed there). Closing it goes on with afterStartScreens.const whatsNew = cfg.setupComplete && whatsNewDue(ui, st?.engine);- // Otherwise, once on a Mac: Kokon's Mac engine (before the model loads, on the engine chosen).- const macOffer = !inBrowser && welcomeSeen && !whatsNew && macEngineOfferDue(st, ui, cfg.setupComplete);- setState({ needsSetup: !cfg.setupComplete, ...(!welcomeSeen ? { overlay: "welcome" } : whatsNew ? { overlay: "whats-new" } : macOffer ? { overlay: "mac-engine" } : {}) });+ // Otherwise, once on a Mac: Kokon's Mac engine switched on (the default there since 0.12), before the model loads.+ const macOn = !inBrowser && welcomeSeen && !whatsNew && macEngineDefaultDue(st, ui, cfg.setupComplete);+ setState({ needsSetup: !cfg.setupComplete, ...(!welcomeSeen ? { overlay: "welcome" } : whatsNew ? { overlay: "whats-new" } : {}) });+ if (macOn) await turnOnMacEngine();setBoot("ok");if (!inBrowser) autoCheckForUpdate();// Own model files that run but don't suit Kokon's 8 steps (the base model instead of Turbo).@@ -182,9 +182,9 @@ export default function App() {const w = m.active.source === "user" ? m.slots.find((x) => x.role === "diffusion")?.info?.warning : null;if (w) toastError(new ApiError({ code: "model_warning", message: w, suggestion: "Settings → Models: download the official files, or use other files of your own." }, 200));}, () => {});- // Preload the model so the first generation starts immediately. After What's new or the Mac offer instead- // (afterStartScreens): not a file or engine about to be replaced, and on the engine the user picks.- if (cfg.setupComplete && !whatsNew && !macOffer && st && st.server.state === "stopped") api.startBackend().then(refreshStatus, () => refreshStatus());+ // Preload the model so the first generation starts immediately (on the Mac engine when it was just switched+ // on). After What's new instead (afterStartScreens): not a file or engine about to be replaced.+ if (cfg.setupComplete && !whatsNew && st && st.server.state === "stopped") api.startBackend().then(refreshStatus, () => refreshStatus());} catch (e) {setBoot(String(e));}@@ -352,7 +352,6 @@ export default function App() {{overlay === "settings" && <SettingsDialog />}{overlay === "welcome" && <Welcome />}{overlay === "whats-new" && <WhatsNew />}- {overlay === "mac-engine" && <MacEngineOffer />}{overlay === "prompt-tips" && <PromptTips />}{overlay === "shortcuts" && <Shortcuts />}{overlay === "ai-check" && <AiCheck />}diff --git a/src/components/MacEngineOffer.tsx b/src/components/MacEngineOffer.tsxdeleted file mode 100644index 3500029..0000000--- a/src/components/MacEngineOffer.tsx+++ /dev/null@@ -1,72 +0,0 @@-import { Activity, RotateCcw, Zap } from "lucide-react";-import { useEffect } from "react";-import { api } from "../lib/api";-import { refreshStatus, setState, toastError, toastInfo } from "../lib/store";-import { KokonMark } from "./Welcome";--const POINTS = [- {- icon: Zap,- title: "About 4 times faster",- text: "The GPU, the CPU's matrix unit and the Neural Engine work together: a new 1024 × 1024 image takes about a minute on an M2 Pro instead of four. Edits, brushed edits, extending and Prompt+ work too.",- },- {- icon: RotateCcw,- title: "Switch back any time",- text: "Settings → Performance → Kokon's Mac engine. LoRAs and the upscaler model still need the standard engine.",- },- {- icon: Activity,- title: "Help us tune it",- text: "Settings → Performance → Benchmark this Mac measures it in about 10 minutes and gives a report to paste on GitHub. Reports from M1, M3, M4 and M5 Macs help most.",- },-];--/** Once, at start on a Mac (after Setup or What's new): Kokon's own engine, experimental and off by default. The- * model loads after the answer, on the engine chosen. */-export function MacEngineOffer() {- const answer = async (on: boolean) => {- setState({ overlay: null });- try {- const cfg = await api.config();- const ui = { ...((cfg.ui ?? {}) as Record<string, unknown>), macEngineOffered: true };- await api.saveConfig({ ...cfg, macEngine: on || !!cfg.macEngine, ui });- if (on) toastInfo("Kokon's Mac engine is on. Switch back any time in Settings → Performance.");- } catch (e) {- toastError(e);- }- api.startBackend().then(refreshStatus, () => refreshStatus());- };- useEffect(() => {- const onKey = (e: KeyboardEvent) => e.key === "Escape" && answer(false);- window.addEventListener("keydown", onKey);- return () => window.removeEventListener("keydown", onKey);- }, []);- return (- <div className="modal-scrim">- <div className="welcome" role="dialog" aria-label="Try Kokon's Mac engine">- <KokonMark size={44} />- <h1>Try Kokon's Mac engine</h1>- <p className="welcome-lead">Kokon now has its own engine for Apple Silicon. It's experimental, so it stays off until you turn it on.</p>- <div className="welcome-grid">- {POINTS.map(({ icon: Icon, title, text }) => (- <div className="welcome-item" key={title}>- <Icon size={20} />- <strong>{title}</strong>- <span>{text}</span>- </div>- ))}- </div>- <div style={{ display: "flex", gap: 10, justifyContent: "center", flexWrap: "wrap" }}>- <button className="btn primary big" onClick={() => answer(true)}>- Try it- </button>- <button className="btn big" onClick={() => answer(false)}>- Not now- </button>- </div>- <span className="muted welcome-foot">Your images, models and settings stay as they are.</span>- </div>- </div>- );-}diff --git a/src/lib/logic.test.ts b/src/lib/logic.test.tsindex 94af112..85a30f4 100644--- a/src/lib/logic.test.ts+++ b/src/lib/logic.test.ts@@ -3,7 +3,7 @@ import {cutoutText,downloadIsFor,jobStepText,- macEngineOfferDue,+ macEngineDefaultDue,modelChoiceUi,modelOfferDue,whatsNewDue,@@ -700,19 +700,19 @@ describe("macBenchProgress", () => {});});-describe("macEngineOfferDue", () => {+describe("macEngineDefaultDue", () => {const gpu = (gb: number) => ({ name: "Apple M2 Pro", vendor: "apple", unified: true, memory_total_mib: gb * 1024, memory_used_mib: 0, memory_free_mib: 0, driver_version: "" });const st = (available: boolean, on: boolean, gb = 16) => ({ gpu: gpu(gb), mac_engine: { available, on } });- it("offers it once on a set-up Mac with the engine in the app", () => {- expect(macEngineOfferDue(st(true, false), {}, true)).toBe(true);- expect(macEngineOfferDue(st(true, false), { macEngineOffered: true }, true)).toBe(false);+ it("switches it on once on a set-up Mac with the engine in the app", () => {+ expect(macEngineDefaultDue(st(true, false), {}, true)).toBe(true);+ expect(macEngineDefaultDue(st(true, false), { macEngineOffered: true }, true)).toBe(false);});it("not before setup, without the engine, when it is on, or below 16 GB", () => {- expect(macEngineOfferDue(st(true, false), {}, false)).toBe(false);- expect(macEngineOfferDue(st(false, false), {}, true)).toBe(false);- expect(macEngineOfferDue(st(true, true), {}, true)).toBe(false);- expect(macEngineOfferDue(st(true, false, 8), {}, true)).toBe(false);- expect(macEngineOfferDue({ gpu: null, mac_engine: undefined }, {}, true)).toBe(false);+ expect(macEngineDefaultDue(st(true, false), {}, false)).toBe(false);+ expect(macEngineDefaultDue(st(false, false), {}, true)).toBe(false);+ expect(macEngineDefaultDue(st(true, true), {}, true)).toBe(false);+ expect(macEngineDefaultDue(st(true, false, 8), {}, true)).toBe(false);+ expect(macEngineDefaultDue({ gpu: null, mac_engine: undefined }, {}, true)).toBe(false);});});diff --git a/src/lib/logic.ts b/src/lib/logic.tsindex 1764404..287ceb5 100644--- a/src/lib/logic.ts+++ b/src/lib/logic.ts@@ -723,9 +723,10 @@ export function modelChoiceUi(choice: "later" | "keep", version: string): Recordreturn choice === "keep" ? { ownModelKept: true } : { modelUpdateSkipped: version };}-/** Offer Kokon's Mac engine once, at start: set up, the engine in the app, off, never asked. Not below 16 GB: the- * engine peaks at ~9 GB during a 1024² decode (M2 Pro, Benchmark button 2026-10-26) and was never run on 8 GB. */-export function macEngineOfferDue(st: Pick<StatusResponse, "gpu" | "mac_engine"> | null, ui: Record<string, unknown>, setupComplete: boolean): boolean {+/** Kokon's Mac engine is the default on Macs since 0.12: switch it on once, at start, when set up, the engine is in+ * the app, it is off and nobody chose yet (`macEngineOffered`: the 0.11 offer's "Not now" or this switch). Not below+ * 16 GB: the engine peaks at ~9 GB during a 1024² decode (M2 Pro, Benchmark button 2026-10-26) and was never run on 8 GB. */+export function macEngineDefaultDue(st: Pick<StatusResponse, "gpu" | "mac_engine"> | null, ui: Record<string, unknown>, setupComplete: boolean): boolean {const engine = st?.mac_engine;return setupComplete && !!engine?.available && !engine.on && !ui.macEngineOffered && (st?.gpu?.memory_total_mib ?? 0) >= 15 * 1024;}diff --git a/src/lib/store.ts b/src/lib/store.tsindex c6a3723..4c57c5c 100644--- a/src/lib/store.ts+++ b/src/lib/store.ts@@ -9,11 +9,11 @@ import { inBrowser, isNarrow } from "./platform";import { useSyncExternalStore } from "react";import { markFresh } from "../components/Cocoon";import { api, ApiError, setPrivateInputs, subscribe, urls } from "./api";-import { activeLoras, buildRequest, composing, emptyComposer, goneVersions, isGenericName, macEngineOfferDue, needsPrompt, newKey, pageOutdated, persistentAdvanced, refFromGen, refFromInput, reviewRequest, stageFitsPreview, starPromptDue, timelineLinks, typedWords, undoTarget, versionLabels, wantsPromptReview, type CompareMode, type Composer, type Ref } from "./logic";+import { activeLoras, buildRequest, composing, emptyComposer, goneVersions, isGenericName, macEngineDefaultDue, needsPrompt, newKey, pageOutdated, persistentAdvanced, refFromGen, refFromInput, reviewRequest, stageFitsPreview, starPromptDue, timelineLinks, typedWords, undoTarget, versionLabels, wantsPromptReview, type CompareMode, type Composer, type Ref } from "./logic";import { keepLabsIn, labsChanged, labSources, loadLab, type LabStore } from "./layerDoc";import type { AppErrorBody, GenerationRecord, GenerationRequest, InputRecord, JobView, LoraItem, MacBenchState, ServerState, StatusResponse } from "./types";-export type Overlay = null | "gallery" | "settings" | "inpaint" | "expand" | "layers" | "welcome" | "whats-new" | "mac-engine" | "prompt-tips" | "shortcuts" | "ai-check";+export type Overlay = null | "gallery" | "settings" | "inpaint" | "expand" | "layers" | "welcome" | "whats-new" | "prompt-tips" | "shortcuts" | "ai-check";export interface SessionItem {key: string;@@ -560,17 +560,27 @@ export function dismissToast(id: string) {let unsub: (() => void) | null = null;-/** After Setup or What's new: the Mac engine offer when it is due (the answer decides which engine loads), else the- * model loads in the background so the first image starts at once. */+/** Kokon's Mac engine, the default on Macs it suits since 0.12: switched on once (`macEngineDefaultDue`), with a note+ * on how to go back. Remembered like the 0.11 offer's answer, so a later "off" in Settings stays off. */+export async function turnOnMacEngine(): Promise<void> {+ try {+ const cfg = await api.config();+ const ui = { ...((cfg.ui ?? {}) as Record<string, unknown>), macEngineOffered: true };+ await api.saveConfig({ ...cfg, macEngine: true, ui });+ toastInfo("Kokon's Mac engine is on: about 4 times faster. LoRAs and the upscaler model need the standard engine (Settings → Performance).");+ } catch (e) {+ toastError(e);+ }+}++/** After Setup or What's new: Kokon's Mac engine switched on when it is due (before the model loads, so it loads on+ * it), then the model loads in the background so the first image starts at once. */export async function afterStartScreens() {try {const [cfg, st] = await Promise.all([api.config(), api.status()]);- if (!inBrowser && macEngineOfferDue(st, (cfg.ui ?? {}) as Record<string, unknown>, cfg.setupComplete)) {- setState({ overlay: "mac-engine" });- return;- }+ if (!inBrowser && macEngineDefaultDue(st, (cfg.ui ?? {}) as Record<string, unknown>, cfg.setupComplete)) await turnOnMacEngine();} catch {- // The offer can wait for the next start; the model still loads.+ // It can wait for the next start; the model still loads.}api.startBackend().then(refreshStatus, () => refreshStatus());}