Skip to content

Sync upstream master (fd21ecf): server cancel, Z-Image reference crash fix, ggml Vulkan small-BAR placement, one placeholder per image - #35

Open
danielhanchen wants to merge 15 commits into
masterfrom
sync-upstream-a77d362
Open

danielhanchen wants to merge 15 commits into
masterfrom
sync-upstream-a77d362

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Syncs the fork with upstream master-995-fd21ecf (2026-10-22). This replaces the master-987-a77d362 sync: upstream moved 8 commits since, including a ggml bump. Fork master is master-982-0518b34 (#34), so this brings in 13 upstream commits in total.

Merge this with "Create a merge commit", not squash or rebase. The prebuilt workflow names a release after the highest upstream master-* tag reachable from the tree, so fd21ecf has to stay reachable, and the tag master-995-fd21ecf has to be in this repository (git push origin refs/tags/master-995-fd21ecf).

Upstream commits brought in

From the earlier a77d362 sync:

New since a77d362:

Conflicts

None. git merge --no-ff upstream/master applied cleanly on f3b773a (the a77d362 sync). All 13 patches in scripts/unsloth/ggml-patches apply in order on ggml c1f80e5.

The CPU speed branch stacked on this one (#36) conflicts in src/core/util.cpp, because leejet#2186 fixes the same sysfs typo #36 fixes. #36 keeps its version: upstream's loop now finds the files but still counts every CPU of the machine, so a 4-CPU cpuset on a 192-CPU host would still get 96 threads, while #36 counts the cores in the affinity mask.

Verification

sd-cli built for the a77d362 sync (f3b773a, ggml dc99877 + 13 patches) and for this branch (ggml c1f80e5 + 13 patches), same GCC, CPU backend, 16 threads, seed 42, 256x256, 4 steps:

Case f3b773a vs this branch
Z-Image Turbo Q4_K_M, Qwen3-4B Q8_0, FLUX.1 AE pixel-identical
FLUX.2 klein 4B Q4_K_M, Qwen3-4B Q8_0, FLUX.2 VAE pixel-identical
FLUX.2 klein 4B with --ref-image pixel-identical

The ggml change is Vulkan-only (memory heap selection for device buffers), so the CPU renders cannot show it.

Not covered

@danielhanchen danielhanchen self-assigned this Oct 22, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T05:38:38.920466Z 344a3b6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3b773a306

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +69 to +70
if (key != "inpaint_width" && key != "inpaint_height" && key != "steps") {
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bound server-side ADetailer allocation parameters

When sd-server is started with --ad-model, native and OpenAI requests can supply extra_ad_args, but this validation only bounds inpaint dimensions and steps. A request such as extra_ad_args: "input_size=1000000" therefore reaches make_letterbox_input, which attempts to allocate and process a 1,000,000×1,000,000×3 float tensor, allowing a single request to exhaust memory or terminate the server. Bound input_size and the other resource-sensitive native ADetailer parameters before generation, as is already done for the SDAPI translation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comes from upstream (leejet/stable-diffusion.cpp master-995-fd21ecf); this PR only merges it and does not touch this file. Leaving it to upstream.

Comment on lines +17 to +18
for (int h = min_size; h < 2LL * area / w; h += factor) {
int64_t pixels = int64_t(w) * h;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Cap the area used by the bucket search

With vae_size_buckets=true, vae_input_max_pixels is accepted as any positive int and is used directly as area here. A server request can set it near INT_MAX, causing this nested search to examine millions of widths and hundreds of millions of width/height pairs before inference while the generation mutex is held; Fibo enables bucket sizing by default. Cap the requested area to a practical image limit or compute the candidate dimensions without iterating up to a user-controlled area.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comes from upstream (leejet/stable-diffusion.cpp master-995-fd21ecf); this PR only merges it and does not touch this file. Leaving it to upstream.


sd_image_t* detailed_images = nullptr;
int detailed_count = 0;
if (!adetail_image(ad_ctx.get(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate detector inference failures

If the YOLO runner fails and returns an empty tensor, ADetailerGGML::predict logs the failure but returns the same empty detection vector used for a legitimate no-detection result. adetail_image then copies the original image and returns success, so this new server call produces HTTP success instead of the documented request failure. Preserve a distinct detector-error state and make this call fail while continuing to accept a successful inference with zero detections.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code comes from upstream (leejet/stable-diffusion.cpp master-995-fd21ecf); this PR only merges it and does not touch this file. Leaving it to upstream.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen danielhanchen changed the title Sync upstream master (a77d362): ADetailer server, remaining time, Fibo 2.0, RPC list-devices, eviction recheck Sync upstream master (fd21ecf): server cancel, Z-Image reference crash fix, ggml Vulkan small-BAR placement, one placeholder per image Oct 23, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 344a3b663b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 344a3b663b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/util.cpp
Comment on lines +594 to +595
static int show_eta = -1; // -1 - estimate duration, 0 - hide, 1 - show
static float passed_time = 0.f;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep ETA state local to each generation

When two sd_ctx_t instances generate concurrently without a custom progress callback, both threads reset and update these file-scope variables without synchronization. This creates a C++ data race and mixes elapsed times between generations, producing nondeterministic ETAs; keep the accounting per generation/context or otherwise synchronize it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from upstream (leejet/stable-diffusion.cpp master-995-fd21ecf): src/core/util.cpp is identical to upstream at that commit, and this PR only merges it. Leaving it to upstream.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants