Repository navigation
Description
Completion — 2026-10-03
The original images-only v1 scope shipped in merged #786 (420b7b135): opt-in native runtime, experimental public engine, basic CLI and chat-app image screen. The delivery is confirmed in the October 1 maintainer comment.
This issue is closed for v1 delivery. Remaining validation #779/#789, native sync #783, Web #780, audio #781, mobile defaults #805, module placement #806 and native-owner follow-ups remain open. The later roadmap is retained below and indexed in #922. Closing v1 does not claim completion of those acceptance criteria.
Original proposal and prototype evidence
Add experimental on-device text-to-image generation, backed by stable-diffusion.cpp through a new opt-in native runtime. Version 1 is images only; video, audio/music and web come later.
Findings from the prototype (2026-09-29)
Prototype: Dart FFI engine over stable-diffusion.cpp 3f8527a46c, measured on a Mac and on Firebase Test Lab devices. Reference-only branch: llamadart-media-generation-1efede (not for merging).
512x512, seed 42, warm run:
| Device | Backend | SDXS-512 Q8, 1 step (651 MB) | SD-Turbo Q8 + TAESD, 1 step (1.9 GB) | Peak RSS (SDXS) |
|---|---|---|---|---|
| M4 Max | Metal | 1.5 s | 1.2 s | 1.2 GB |
| iPhone 16 Pro | Metal | 1.7 s | 4.1 s | 1.06 GB |
| Galaxy S24 | CPU, 4 threads | 5.9 s | 11.8 s | 1.55 GB |
| Galaxy A53 | CPU, 4 threads | 26–29 s | killed by lowmemorykiller | 1.35 GB |
- SDXS output is pixel-identical across Mac and Android for the same seed.
- iOS: first load takes 19 s (Metal shader compilation). A second SD-Turbo 4-step run aborted with a Metal command-buffer error ("victim of GPU error/recovery").
- Android GPU: ggml Vulkan crashed on both phones (Adreno 750 driver shader compiler; null
vkGetBufferDeviceAddresson Mali-G68). OpenCL on Adreno 750 ran SDXS slower than the CPU (8.2 s) and aborted on SD-Turbo. Android ships CPU-only for now. - llama.cpp (llamadart) and stable-diffusion.cpp ran text and image generation concurrently in one process on macOS; other platforms untested.
- iPhone SE 3 (4 GB) was not measured: one run hit a Hugging Face CDN drop, the rerun hit a Test Lab asset error.
Decisions
- Core
llamadart, opt-in runtime.stable_diffusionjoinsllama_cppandlitert_lmin thellamadart_native_runtimesuser define. Never on by default (adds 40–70 MB per platform). - Native owner: new repo leehack/stable-diffusion-native, following the
litert-lm-nativepattern. It exports only thestable-diffusion.hAPI (66 symbols, down from 2,723) so its ggml cannot collide with llama.cpp's. - Version 1 scope: text-to-image, SD 1.x/2.x-family models (SDXS mobile default, SD-Turbo flagship/desktop). Metal on Apple, CPU on Android, CPU or Vulkan on Linux and Windows. Web throws
LlamaUnsupportedException.
Proposed API (experimental)
Mirrors TextToSpeechEngine: capabilities probe, task with events, done and cancel(), typed completion.
final engine = await ImageGenerationEngine.load(
ImageGenerationModel.sdxs('sdxs-512_Q8_0.gguf'),
options: const ImageGenerationOptions(device: ImageGenerationDevice.auto),
);
final task = engine.generate(const ImageGenerationRequest(
prompt: 'a red fox in autumn leaves', width: 512, height: 512, seed: 42));
await for (final event in task.events) {
switch (event) {
case ImageGenerationProgressEvent(:final phase, :final step, :final steps):
case ImageGenerationFinalEvent(:final result):
final png = result.images.first.toPng();
}
}
await engine.dispose();Plus a one-call Future<GeneratedImage> generateImage(request) shortcut.
Plan
- Native runtime: leehack/stable-diffusion-native first release; desktop Vulkan variants Vulkan variants for Linux and Windows stable-diffusion-native#1; async-safe logs Async-safe log forwarding for FFI consumers stable-diffusion-native#3
- Add opt-in stable_diffusion native runtime (hook, pins, bindings) #777 opt-in
stable_diffusionruntime (hook, pins, bindings) - Experimental ImageGenerationEngine public API #778 experimental
ImageGenerationEngineAPI, with docs - Image validation: Firebase harness, Android coexistence and remaining device checks #779 v1 test baseline and recorded device results; remaining harness/coexistence qualification stays open in Image validation: Firebase harness, Android coexistence and remaining device checks #779/Re-run the chat app image E2E test on a physical iPhone #789
Later:
- Spike: web image generation on ggml WebGPU #780 web spike on ggml WebGPU
- Evaluate non-speech audio generation runtimes (music, sound effects) #781 non-speech audio generation evaluation
- Larger desktop image-model presets including Z-Image and FLUX delivered by feat: add SDXL-Lightning, FLUX.1-schnell, SD 3.5 Large Turbo and Z-Image-Turbo presets #810
- Video generation (Wan, LTX): future evaluation, not shipped capability
- Android GPU acceleration: Android GPU acceleration (currently CPU-only) stable-diffusion-native#2
- Share llama.cpp's ggml: Evaluate building against llama.cpp's ggml (SD_USE_UPSTREAM_GGML) stable-diffusion-native#4
- Upstream crash reports: Report device crashes upstream (Mali Vulkan, Adreno Vulkan, iOS Metal abort) stable-diffusion-native#5
Related: #782 may affect the existing llama.cpp Vulkan backend.
Activity
leehack commentedon Sep 29, 2026
Native runtime stable-diffusion-native v0.1.0 is published as a prerelease (stable-diffusion.cpp
3f8527a46c): 11 targets, 13–26 MB per archive, each exporting only the 66stable-diffusion.hsymbols. Metal on Apple, CPU on Android, CPU and Vulkan variants on Linux and Windows (Vulkan checked on Mesa lavapipe only). Next: #777.feat: experimental on-device image generation (stable_diffusion runti…
leehack commentedon Oct 1, 2026
Version 1 shipped in #786 (
420b7b135): opt-instable_diffusionruntime (stable-diffusion-native v0.1.1), experimentalImageGenerationEngine,basic_appimage CLI and a chat app image screen. Validated on macOS, Android, iOS, Linux x64 and Windows x64 with real models (#779). Remaining work is in the "Later" items and #787–#793.[-]Experimental on-device image generation (stable-diffusion.cpp runtime)[/-][+]Image generation v1 shipped — later work tracked separately[/+]