Skip to main content

Module sdcpp

Module sdcpp 

Source
Expand description

Engine that runs real image inference by subprocess-invoking the stable-diffusion.cpp (sd-cli) binary.

The studio’s offer carries a ModelSource with everything we need: an engine identifier (sd-cpp), the list of files to download (diffusion-model + text-encoder + VAE, each with a public URL + filename), and CLI defaults (cfg-scale, steps, dimensions). The worker has zero hardcoded model knowledge \u2014 it caches whatever the studio asks for under cfg.models_root and invokes sd-cli with the files arranged by role.

Layout under cfg.models_root (default ~/models):

~/models/<filename1>
~/models/<filename2>
\u2026

Files are downloaded on first use - skipped when already present under cfg.models_root. The streamed body is checked against the server’s Content-Length so a truncated download is rejected and cleaned up instead of being renamed into place as a corrupt model that every later job would fail to load. Cached files are re-used across every subsequent job that names them.

The engine self-registers only when sd-cli is present on the box (either at $STUDIO_WORKER_SD_CLI, or ~/.local/bin/sd-cli, or on $PATH). Without sd-cli the worker can’t run real-image jobs at all so it skips registration and the multi engine falls through to synthetic for any kind it doesn’t have a real backend for.

Structs§

SdCppEngine
Worker-side engine that drives sd-cli per job.