Skip to content

Image generation v1 shipped — later work tracked separately #776

Closed

Description

@leehack

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 vkGetBufferDeviceAddress on 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_diffusion joins llama_cpp and litert_lm in the llamadart_native_runtimes user define. Never on by default (adds 40–70 MB per platform).
  • Native owner: new repo leehack/stable-diffusion-native, following the litert-lm-native pattern. It exports only the stable-diffusion.h API (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

Later:

Related: #782 may affect the existing llama.cpp Vulkan backend.

Activity

  1. added
    enhancement
    priority:P2
    on Sep 29, 2026
  2. leehack commented on Sep 29, 2026

    @leehack
    OwnerAuthor

    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 66 stable-diffusion.h symbols. Metal on Apple, CPU on Android, CPU and Vulkan variants on Linux and Windows (Vulkan checked on Mesa lavapipe only). Next: #777.

  3. leehack commented on Oct 1, 2026

    @leehack
    OwnerAuthor

    Version 1 shipped in #786 (420b7b135): opt-in stable_diffusion runtime (stable-diffusion-native v0.1.1), experimental ImageGenerationEngine, basic_app image 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.

  4. changed the title [-]Experimental on-device image generation (stable-diffusion.cpp runtime)[/-] [+]Image generation v1 shipped — later work tracked separately[/+] on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions