stable-diffusion.cpp/src/core
Claude a873187b6a
feat: let --auto-fit place modules on several GPUs
With more than one discrete GPU of the same backend, auto-fit used only the
one with the most free memory. A model that did not fit there was streamed
from RAM or disk while the other GPUs stayed idle.

--multi-gpu auto (the default) moves a module that does not fit next to the
modules placed before it to another GPU: first the text encoder or the VAE,
and when the diffusion model or the text encoder fits on no single GPU, it is
split across the fewest GPUs that can hold it, as --backend
"diffusion=cuda0&cuda1" does. on also moves the text encoder and the VAE away
from the GPU of the diffusion model when everything would fit on one, and off
keeps the previous single-GPU behavior.

Modules named in --backend, or split by rows, are never moved or split, and
only discrete GPUs of one backend are combined. The planner requires the free
memory of the GPUs, less the compute reserve of each, to exceed the weights by
10% plus 256 MiB per boundary, because blocks cannot be cut exactly where the
memory ends. A split saves memory but does not make one image faster.

The new field multi_gpu is appended to sd_ctx_params_t and sd_ctx_params_init()
sets it to the default.

Not run on real GPUs; the planner is covered by a test with simulated devices
in the next commits.

Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
2026-10-14 01:03:42 +02:00
..
backend_diag.cpp feat: log why a GPU backend module could not be used 2026-10-11 05:52:43 +02:00
backend_diag.h feat: log why a GPU backend module could not be used 2026-10-11 05:52:43 +02:00
backend_fit.cpp feat: let --auto-fit place modules on several GPUs 2026-10-14 01:03:42 +02:00
backend_fit.h feat: let --auto-fit place modules on several GPUs 2026-10-14 01:03:42 +02:00
compute_workspace.cpp feat: support building with upstream ggml (#1999) 2026-09-19 22:25:01 +08:00
compute_workspace.h fix: guard GPU memory capacity and propagate encoding failures (#1958) 2026-09-13 21:35:46 +08:00
cuda_driver.cpp fix: load the CUDA driver at run time so the library starts without it 2026-10-11 12:51:59 +02:00
cuda_driver.h fix: load the CUDA driver at run time so the library starts without it 2026-10-11 12:51:59 +02:00
ggml_extend.cpp chore: resolve MSVC warnings in ggml extensions 2026-10-06 20:10:36 +08:00
ggml_extend.h fix: scale Qwen Image 2.1 VAE convolutions (#2054) 2026-09-25 15:52:35 +08:00
ggml_extend_backend.cpp fix: load the CUDA driver at run time so the library starts without it 2026-10-11 12:51:59 +02:00
ggml_extend_backend.h feat: log why a GPU backend module could not be used 2026-10-11 05:52:43 +02:00
ggml_graph_cut.cpp feat: support building with upstream ggml (#1999) 2026-09-19 22:25:01 +08:00
ggml_graph_cut.h perf: reduce CPU overhead in graph execution and sampling (#1997) 2026-09-19 18:32:58 +08:00
ggml_runner.cpp feat: report why a call failed and expose system memory 2026-10-11 07:09:28 +02:00
ggml_runner.h feat: add configurable Qwen cache types and early cache scheduling (#2045) 2026-09-25 01:51:01 +08:00
ggml_tensor_utils.cpp refactor: split ggml extensions and move implementations to cpp files (#1945) 2026-09-07 23:34:45 +08:00
ggml_tensor_utils.h refactor: split ggml extensions and move implementations to cpp files (#1945) 2026-09-07 23:34:45 +08:00
last_error.cpp feat: report why a call failed and expose system memory 2026-10-11 07:09:28 +02:00
last_error.h feat: report why a call failed and expose system memory 2026-10-11 07:09:28 +02:00
layer_split_partition.cpp feat: add verbose logging and log-level selection (#1941) 2026-09-06 23:14:03 +08:00
layer_split_partition.h feat: drive layer split from graph-cut segments (#1762) 2026-07-07 23:16:52 +08:00
memory_watchdog.cpp feat: apply --memory-guard to CPU backends using system RAM 2026-10-11 04:51:58 +02:00
memory_watchdog.h feat: apply --memory-guard to CPU backends using system RAM 2026-10-11 04:51:58 +02:00
ordered_map.hpp refactor: unify model source and weight lifecycle management (#1956) 2026-09-10 23:53:48 +08:00
parallel.cpp perf: parallelize host tensor elementwise and broadcast ops (#1998) 2026-09-19 21:46:16 +08:00
parallel.h perf: parallelize host tensor elementwise and broadcast ops (#1998) 2026-09-19 21:46:16 +08:00
pe_imports.cpp feat: log why a GPU backend module could not be used 2026-10-11 05:52:43 +02:00
pe_imports.h feat: log why a GPU backend module could not be used 2026-10-11 05:52:43 +02:00
regex.cpp feat: support external Hugging Face tokenizer JSON files (#1973) 2026-09-15 00:27:39 +08:00
regex.h feat: support external Hugging Face tokenizer JSON files (#1973) 2026-09-15 00:27:39 +08:00
rng.hpp feat: support Brownian tree noise in all noise injection samplers (#1899) 2026-09-15 02:37:31 +08:00
rng_mt19937.hpp feat: support Brownian tree noise in all noise injection samplers (#1899) 2026-09-15 02:37:31 +08:00
rng_philox.hpp perf: reduce CPU overhead in graph execution and sampling (#1997) 2026-09-19 18:32:58 +08:00
runner_cache.cpp feat: add Qwen Image 2.1 prefix KV cache (#2035) 2026-09-23 23:08:21 +08:00
runner_cache.h feat: add Qwen Image 2.1 prefix KV cache (#2035) 2026-09-23 23:08:21 +08:00
segment_graph_bindings.cpp refactor: unify runner lifecycles and weight residency (#1940) 2026-09-06 22:30:45 +08:00
segment_graph_bindings.h refactor: unify runner lifecycles and weight residency (#1940) 2026-09-06 22:30:45 +08:00
segment_weight_pipeline.cpp refactor: unify runner lifecycles and weight residency (#1940) 2026-09-06 22:30:45 +08:00
segment_weight_pipeline.h refactor: unify runner lifecycles and weight residency (#1940) 2026-09-06 22:30:45 +08:00
system_memory.cpp feat: report why a call failed and expose system memory 2026-10-11 07:09:28 +02:00
system_memory.h feat: report why a call failed and expose system memory 2026-10-11 07:09:28 +02:00
tensor.hpp perf: parallelize host tensor elementwise and broadcast ops (#1998) 2026-09-19 21:46:16 +08:00
tensor_ggml.hpp refactor: unify runner lifecycles and weight residency (#1940) 2026-09-06 22:30:45 +08:00
util.cpp feat: report why a call failed and expose system memory 2026-10-11 07:09:28 +02:00
util.h refactor: escape newlines in prompt logs and clarify source separators (#2106) 2026-10-06 19:51:12 +08:00