Merge leejet/stable-diffusion.cpp 9e7eed7 into fork-pull (sync 4/4, part 1)

The last step towards upstream master comes in three parts. This first
one takes the commits before the Diffusion Graph Language rewrite:

- two unused ggml compat functions removed, so the library links
  against a shared libggml 1.0.0 (#2363);
- asym_w4a8_int8 defaults to group size 16, as in ComfyUI (#2388);
- batched spatial padding in the Hunyuan causal convolutions (#2374)
  and fewer CUDA launches in the H3 VAE encoder (#2369);
- documentation: Windows ROCm 0xC0000135, Off Grid AI, the server's
  browser notification (#2356, #2372, #2318).

The merge is clean; no fork code changes.

Verified with a CPU build: the library, sd-cli and sd-server build, and
all nine unit-test programs pass.

Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
This commit is contained in:
Claude 2026-11-24 18:52:13 +01:00
commit bfefd6a1ef
No known key found for this signature in database
10 changed files with 68 additions and 74 deletions

View file

@ -30,3 +30,4 @@ applications that integrate it as an image generation backend.
- [NodeTool](https://github.com/nodetool-ai/nodetool)
- [Quo](https://github.com/quo-ai/quo)
- [Prisme](https://github.com/d3Ita/prisme)
- [Off Grid AI](https://github.com/off-grid-ai/OGAD)

View file

@ -77,3 +77,32 @@ If the problem persists after trying the relevant steps above,
[submit a bug report](https://github.com/leejet/stable-diffusion.cpp/issues/new?template=bug_report.yml).
Include your full command, backend and hardware, model and weight format, logs,
and the scale values you tried with their results.
## Windows: process exits immediately with 0xC0000135 (STATUS_DLL_NOT_FOUND)
`sd-cli.exe` / `sd-server.exe` from the Windows ROCm prebuilt may exit with
`0xC0000135` (`STATUS_DLL_NOT_FOUND`) and no output when the HIP runtime is
not on `PATH`. `stable-diffusion.dll` statically imports `hipblas.dll` and
`libhipblaslt.dll`, but the release archive only bundles `amd_comgr.dll`,
`amdhip64_7.dll` and `rocm_kpack.dll`. This is a loader failure, unrelated to
`--audio-vae` or other generation options; `0xC000001D`
(`STATUS_ILLEGAL_INSTRUCTION`) would instead indicate a CPU instruction issue.
Fix: prepend the ROCm SDK `bin` directories to `PATH` — with the Python ROCm
wheels these are `<python home>\Lib\site-packages\_rocm_sdk_libraries\bin` and
`_rocm_sdk_core\bin`. Do not copy individual DLLs: `rocblas.dll` and
`libhipblaslt.dll` also need their sibling `rocblas\` and `hipblaslt\` data
directories.
Verify:
```powershell
.\sd-cli.exe --version
'0x{0:X8}' -f $LASTEXITCODE
```
Expect the version string and `0x00000000`. If it still fails, inspect the
whole DLL chain (`sd-cli.exe` -> `stable-diffusion.dll` -> ...): `dumpbin
/dependents` lists only one image's direct imports, so use
[Dependencies](https://github.com/lucasg/Dependencies) or also check
`stable-diffusion.dll` to find the missing module.

View file

@ -114,6 +114,14 @@ total work is unknown. The canvas keeps the submitted output aspect ratio, and
stage changes keep the same layout. Editing the next request's resolution does
not resize the current preview or result.
Settings will offer **Notify me when generation finishes** (upcoming; requires
a frontend update). When enabled, the UI requests browser notification
permission and shows a notification when a generation job completes, fails, or
is cancelled, so you do not need to watch the tab while waiting. The
preference is saved locally. Notifications require granting browser
notification permission; if permission was previously denied, reset it in the
browser's site settings for this site before turning the setting on.
### LoRAs
To apply a LoRA, open **LoRA**, select a compatible file, and set its

View file

@ -151,17 +151,6 @@ bool ggml_graph_cpy_use_counts(const ggml_cgraph* src, ggml_cgraph* dst) {
}
return true;
}
ggml_status ggml_backend_graph_compute_async_range(ggml_backend_t backend, ggml_cgraph* graph, int first, int last) {
if (!backend || !graph || first < 0 || last < first || last > graph->n_nodes) {
return GGML_STATUS_FAILED;
}
if (first == last) {
return GGML_STATUS_SUCCESS;
}
auto view = ggml_graph_view(graph, first, last);
return ggml_backend_graph_compute_async(backend, &view);
}
#endif
#ifdef SD_USE_UPSTREAM_GGML

View file

@ -29,13 +29,6 @@ bool ggml_graph_cpy_mapped(const struct ggml_cgraph* src, struct ggml_cgraph* ds
// This preserves external consumers when constructing an inference graph segment.
bool ggml_graph_cpy_use_counts(const struct ggml_cgraph* src, struct ggml_cgraph* dst);
// Executes nodes [first, last) with the original graph's use counts. No graph ownership
// is transferred. Tensor storage must already be allocated; invalid bounds fail.
enum ggml_status ggml_backend_graph_compute_async_range(ggml_backend_t backend,
struct ggml_cgraph* graph,
int first,
int last);
#else
#error "Patched ggml requires ggml-graph.h; select SD_USE_UPSTREAM_GGML for upstream compatibility"
#endif

View file

@ -637,50 +637,6 @@ void sd_backend_clear_buffer_cache(ggml_backend_t backend) {
}
}
ggml_status sd_backend_graph_compute_with_eval_callback(ggml_backend_t backend,
ggml_cgraph* gf,
sd_graph_eval_callback_t callback_eval,
void* callback_eval_user_data) {
if (callback_eval == nullptr) {
return ggml_backend_graph_compute(backend, gf);
}
ggml_status status = GGML_STATUS_SUCCESS;
const int n_nodes = ggml_graph_n_nodes(gf);
bool stopped = false;
for (int j0 = 0; j0 < n_nodes; ++j0) {
ggml_tensor* t = ggml_graph_node(gf, j0);
bool need = callback_eval(t, true, callback_eval_user_data);
int j1 = j0;
while (!need && j1 < n_nodes - 1) {
t = ggml_graph_node(gf, ++j1);
need = callback_eval(t, true, callback_eval_user_data);
}
status = ggml_backend_graph_compute_async_range(backend, gf, j0, j1 + 1);
if (status != GGML_STATUS_SUCCESS) {
break;
}
ggml_backend_synchronize(backend);
if (need && !callback_eval(t, false, callback_eval_user_data)) {
stopped = true;
break;
}
j0 = j1;
}
ggml_backend_synchronize(backend);
if (stopped && status == GGML_STATUS_SUCCESS) {
status = GGML_STATUS_ABORTED;
}
return status;
}
const char* sd_get_system_info() {
static std::string cache_info = []() -> std::string {
ggml_backend_load_all_once();

View file

@ -102,10 +102,6 @@ bool sd_backend_cpu_set_n_threads(ggml_backend_t backend_cpu, int n_threads);
void sd_backend_set_buffer_cache_enabled(ggml_backend_t backend, bool enabled);
void sd_backend_clear_buffer_cache(ggml_backend_t backend);
ggml_status sd_backend_graph_compute_with_eval_callback(ggml_backend_t backend,
ggml_cgraph* gf,
sd_graph_eval_callback_t callback_eval,
void* callback_eval_user_data);
std::string sd_backend_resolve_name(const std::string& name);
bool sd_parse_backend_assignment(const std::string& spec, SDBackendAssignment* assignment, std::string* error);
bool sd_parse_flash_attention_assignment(const std::string& spec, SDBackendAssignment* assignment, std::string* error);

View file

@ -140,8 +140,15 @@ namespace Hunyuan {
}
return input;
};
padded = replicate_pad(padded, 0, pad_w, pad_w);
padded = replicate_pad(padded, 1, pad_h, pad_h);
if (pad_w > 0 || pad_h > 0) {
const int64_t frames = padded->ne[2];
const int64_t channels = padded->ne[3];
// Keep spatial padding in one outer slice to avoid per-channel CUDA launches.
padded = ggml_reshape_3d(ctx->ggml_ctx, ggml_ext_cont(ctx, padded), padded->ne[0], padded->ne[1], frames * channels);
padded = replicate_pad(padded, 0, pad_w, pad_w);
padded = replicate_pad(padded, 1, pad_h, pad_h);
padded = ggml_reshape_4d(ctx->ggml_ctx, padded, padded->ne[0], padded->ne[1], frames, channels);
}
return conv->forward(ctx, padded);
}
};

View file

@ -100,8 +100,15 @@ namespace MiniMaxH3VAE {
return value;
};
x = reflect_pad(x, 0, std::get<2>(temporal_padding));
x = reflect_pad(x, 1, std::get<1>(temporal_padding));
if (std::get<1>(temporal_padding) != 0 || std::get<2>(temporal_padding) != 0) {
const int64_t frames = x->ne[2];
const int64_t channels = x->ne[3];
// Keep spatial padding in one outer slice to avoid per-channel CUDA launches.
x = ggml_reshape_3d(ctx->ggml_ctx, ggml_ext_cont(ctx, x), x->ne[0], x->ne[1], frames * channels);
x = reflect_pad(x, 0, std::get<2>(temporal_padding));
x = reflect_pad(x, 1, std::get<1>(temporal_padding));
x = ggml_reshape_4d(ctx->ggml_ctx, x, x->ne[0], x->ne[1], frames, channels);
}
int temporal_pad = std::get<0>(temporal_padding) * 2;
if (temporal_pad > 0) {
x = ggml_ext_pad_ext(ctx,
@ -167,10 +174,14 @@ namespace MiniMaxH3VAE {
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
if (spatial_stride == 2) {
GGML_ASSERT(x->ne[0] > 1 && x->ne[1] > 1);
auto right = ggml_ext_slice(ctx, x, 0, x->ne[0] - 2, x->ne[0] - 1);
x = ggml_concat(ctx->ggml_ctx, x, right, 0);
auto bottom = ggml_ext_slice(ctx, x, 1, x->ne[1] - 2, x->ne[1] - 1);
x = ggml_concat(ctx->ggml_ctx, x, bottom, 1);
const int64_t frames = x->ne[2];
const int64_t channels = x->ne[3];
x = ggml_reshape_3d(ctx->ggml_ctx, ggml_ext_cont(ctx, x), x->ne[0], x->ne[1], frames * channels);
auto right = ggml_ext_slice(ctx, x, 0, x->ne[0] - 2, x->ne[0] - 1);
x = ggml_concat(ctx->ggml_ctx, x, right, 0);
auto bottom = ggml_ext_slice(ctx, x, 1, x->ne[1] - 2, x->ne[1] - 1);
x = ggml_concat(ctx->ggml_ctx, x, bottom, 1);
x = ggml_reshape_4d(ctx->ggml_ctx, x, x->ne[0], x->ne[1], frames, channels);
}
return std::dynamic_pointer_cast<CausalConv3d>(blocks["conv"])->forward(ctx, x);
}

View file

@ -147,6 +147,10 @@ static bool read_comfy_quant_config(std::ifstream& file,
config.convrot = true;
config.group_size = json.value("convrot_groupsize", 256);
}
if (config.format == "asym_w4a8_int8") {
// ComfyUI defaults the W4A8 weight group size to 16 when the key is missing.
config.weight_group_size = json.value("group_size", 16);
}
} catch (const std::exception&) {
set_error(error, "parsing ComfyUI quantization metadata tensor failed: '" + tensor_name + "'");
return false;