stable-diffusion.cpp/examples/common
Claude 6d6e51cde6
feat(server): keep compute on the GPUs and try other GPUs before the CPU
When the server stepped down, the CPU took the work and the GPUs were left
behind: `lite` put the text encoder on the CPU, `lite-disk` switched the
auto-fit off, a backend failure jumped straight to `lite-cpu`, and an engine
that could not start a backend quietly turned the whole model into a CPU run.

- profile: `lite` no longer moves the text encoder to the CPU and sets
  `--multi-gpu on` (unless it was set to off); `lite-disk` keeps the
  auto-fit. The new level `lite-hybrid`, between `lite-disk` and `lite-cpu`,
  is where the text encoder goes to the CPU, and only on a machine that has
  an accelerator. Ladder: max > balanced > lite > lite-disk > lite-hybrid >
  lite-cpu. The names and options of `--profile` are unchanged, an explicit
  option still wins, `max` is identical and `include/` is untouched.
- keeper: a backend failure no longer walks down the profiles. The same
  configuration is loaded once more (once per request), then each device the
  engine lists is tried on its own (graphics cards, the vendor's backend
  before Vulkan/OpenCL, most free memory first; accelerators; integrated GPUs
  last; never RPC), and the CPU comes last. Running out of memory on a device
  steps down the profile on that same device. While a GPU is left to try, the
  keeper sets disable_backend_fallback, so the engine does not fall back to
  the CPU by itself. The climb back tries the preferred device first, and
  from the CPU goes straight to the profile the server had when the device
  failed. A placement written in --backend is not rewritten.
- visibility: /sdcpp/v1/health reports device, cpu_modules and
  fallback_devices, and the counters retries and device_switches; the status
  is degraded on another device too. The start-up log tells the order of the
  spare devices, the device in use and the modules the CPU computes.
- the --profile help text no longer says that lite uses the CPU.

Verification: profile_test 74 checks and server_recovery_test 234 checks
(simulated library, device list and clock), the second also under
ASan/UBSan/TSan; seven mutations of the device-failure code are all caught.
On the CPU-only machine used here, sd-server with the synthetic model still
steps down to lite-disk under a memory limit, and the cancel (35 checks) and
model catalog (15 checks) runs pass. Nothing has run on a real GPU.

Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
2026-11-05 17:44:47 +01:00
..
common.cpp feat(server): keep compute on the GPUs and try other GPUs before the CPU 2026-11-05 17:44:47 +01:00
common.h Merge upstream/master (leejet/stable-diffusion.cpp 58bb3c1) into fork-pull 2026-11-05 14:08:44 +01:00
generation_metadata.cpp feat: return generation metadata with core results (#2206) 2026-10-25 03:18:03 +08:00
generation_metadata.h feat: return generation metadata with core results (#2206) 2026-10-25 03:18:03 +08:00
log.cpp refactor: escape newlines in prompt logs and clarify source separators (#2106) 2026-10-06 19:51:12 +08:00
log.h feat: add verbose logging and log-level selection (#1941) 2026-09-06 23:14:03 +08:00
media_io.cpp feat(server): add recipe constraints and update generation workspace (#2217) 2026-10-26 01:01:43 +08:00
media_io.h feat(server): accept ref_videos, ref_audios, ref_video_audios in sdcpp vid_gen (#2194) 2026-10-25 17:18:47 +08:00
media_metadata.cpp feat: return generation metadata with core results (#2206) 2026-10-25 03:18:03 +08:00
media_metadata.h feat: return generation metadata with core results (#2206) 2026-10-25 03:18:03 +08:00
profile.cpp feat(server): keep compute on the GPUs and try other GPUs before the CPU 2026-11-05 17:44:47 +01:00
profile.h feat(server): keep compute on the GPUs and try other GPUs before the CPU 2026-11-05 17:44:47 +01:00
resource_owners.hpp feat: return generation metadata with core results (#2206) 2026-10-25 03:18:03 +08:00