Merge upstream master-982 (MOSS-Image) and port the ggml patches to dc99877 by danielhanchen · Pull Request #34 · unslothai/stable-diffusion.cpp · GitHub
Skip to content

Merge upstream master-982 (MOSS-Image) and port the ggml patches to dc99877 - #34

Merged
danielhanchen merged 16 commits into
masterfrom
sync/upstream-moss
Oct 21, 2026
Merged

danielhanchen merged 16 commits into
masterfrom
sync/upstream-moss

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Merges upstream leejet/stable-diffusion.cpp master-982 (0518b34) into the fork, which adds MOSS-Image (from master-975), and ports our carried ggml patches onto the new leejet/ggml submodule (d25b121 -> dc99877).

Upstream merge

Three conflicts:

ggml patches

0008 and 0010-0013 apply as is. 0001-0007 and 0009 were rebuilt as commits on the old base, cherry-picked onto dc99877 and regenerated. Five needed real changes:

  • load_tile lost its swz argument.
  • launch_fattn gained async_kv_preload before our occupancy arguments. Passed positionally, our function pointer would have become that bool, so the longseq calls now pass it explicitly.
  • rms_norm_f32 gained nchannels / nsamples and do_scale / scale_out; the small-row launcher is ported to match.
  • ggml_cuda_should_use_mmvf gained warp_size.
  • 0009: the cwd-search removal wins over upstream's reworded log line.

Applying the regenerated patches in order to a fresh dc99877 gives a tree identical to the ported branch.

Results (B200, sm_100, CUDA 13.1, 512x512, seed 42, base = master bdb47d1 rebuilt with the same toolchain)

Case Result
FLUX.2-klein-4B Q4_K_M, 4 steps base, candidate and repeats identical
Z-Image-Turbo Q4_K_M, 8 steps base and candidate identical
MOSS-Image-SFT UD-Q4_K_XL + Qwen3.5-9B Q8_0, 20 steps, CFG 3 base: get sd version from file failed; candidate renders, repeat identical

The non-publishing prebuilt build of this branch covers the Windows, macOS / Metal, Vulkan, ROCm, CPU and CUDA 12.8 legs.

therealshulgin and others added 16 commits October 17, 2026 00:50
…ubmodule)

Upstream master-982 moves the ggml submodule from d25b121 to dc99877 (leejet#2147), so
0001-0007 and 0009 no longer applied. Ported by cherry-picking each patch onto the
new submodule commit; conflicts were adjacent additions plus four API moves:
load_tile lost its swz template argument, launch_fattn gained async_kv_preload
before the occupancy arguments, rms_norm_f32 now takes nchannels/nsamples and a
do_scale/scale_out pair, and ggml_cuda_should_use_mmvf takes warp_size.
@danielhanchen danielhanchen self-assigned this Oct 21, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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 ✅ Completed 2026-10-21T12:26:10.155885Z 0a68764 PR opened
🔒 Security Review ✅ Completed 2026-10-21T12:26:00.659549Z 0a68764 PR opened
ℹ️ 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.

@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: 0a687648ee

ℹ️ 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".

@@ -0,0 +1,49 @@
{
"schema_version": 1,
"id": "moss-image-sft",

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 Reuse one recipe for both MOSS checkpoints

The Base and SFT recipe files declare identical slots, defaults, and feature sets; only their identifiers, names, descriptions, and URLs differ. Exposing moss-image-sft as a separate entry therefore splits same-task checkpoints without a component or capability distinction, contrary to rule 4 of examples/server/recipes/README.md, which requires such variants to reuse the family recipe. Consolidate both checkpoints under one MOSS recipe.

AGENTS.md reference: AGENTS.md:L85-L87

Useful? React with 👍 / 👎.

Comment on lines +29 to +30

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 Trigger builds for embedded recipe changes

The server now embeds every examples/server/recipes/*.json file into the executable at configure time, but neither the push nor pull_request path filter includes those JSON files or recipes_builtin.h.in. Because a GitHub Actions paths filter runs only when at least one changed path matches, a recipe-only change skips this entire build workflow and receives no binary-build validation; add the recipe directory and generated-header template to both filters. See GitHub's workflow syntax.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen deployed to release-signing October 21, 2026 13:54 — with GitHub Actions Active
@danielhanchen
danielhanchen deployed to release-signing October 21, 2026 13:54 — with GitHub Actions Active
@danielhanchen
danielhanchen deployed to release-signing October 21, 2026 13:54 — with GitHub Actions Active
@danielhanchen
danielhanchen deployed to release-signing October 21, 2026 13:54 — with GitHub Actions Active
@danielhanchen
danielhanchen merged commit d331c66 into master Oct 21, 2026
22 checks passed
danielhanchen added a commit to unslothai/unsloth that referenced this pull request Oct 21, 2026
…e GGUFs load (#14565)

## Summary

Moves Studio's pinned stable-diffusion.cpp prebuilt from
`master-968-8cd731e-ubdb47d1` to `master-982-0518b34-ud331c66`, the
build published today from unslothai/stable-diffusion.cpp#34. master-968
predates MOSS-Image (upstream master-975, which also brought split-QKV
GGUF loading), so a MOSS-Image GGUF cannot load on the current pin;
every other family keeps working on the new base.

## What it does

- `studio/install_sd_cpp_prebuilt.py`: `DEFAULT_TAG =
"master-982-0518b34-ud331c66"`, with the comment explaining why
master-968 is no longer enough. `UNSLOTH_SD_CPP_TAG` still overrides,
and a missing tag still falls back to latest.
- Tests that name the pinned bundle and its asset names
(`test_sd_cpp_args.py`, `test_sd_cpp_vulkan_cpu_torch.py`,
`test_diffusion_more_families.py`, `test_sd_cpp_install.py`) move to the
new tag; the previous pin stays in the accepted-tags list.

## Checks

- The release carries the same 13 assets as master-968 (Linux x86_64 CPU
/ Vulkan / CUDA 12 / CUDA 13, Linux aarch64, Windows CPU / Vulkan / CUDA
12 / CUDA 13, macOS arm64 / x86_64, manifest, sha256 list), so no
platform loses its bundle.
- `UNSLOTH_BUILD.txt` in the Linux CUDA 12 bundle names source commit
`d331c66caa` and the MOSS-Image architecture marker is present in both
`sd-cli` and `sd-server`.
- Installed through `install_sd_cpp_prebuilt.py --accelerator cuda
--cuda-major 12` into a scratch directory, then rendered a
MOSS-Image-SFT UD-Q4_K_XL GGUF through Studio's own
`SdCppDiffusionBackend` (server mode, 512x512, 20 steps, CFG 3) on a
B200: the router picked sd.cpp, the model loaded and the render came out
clean (a fox in snow with the prompted sign text).
- Old pin vs new pin, same host, same Studio code, Studio's own
`SdCppDiffusionBackend` in server mode, 512x512, seed 42, each arm in
its own process (the running `sd-server` binary checked per arm):

| Family (Q4_K_M GGUF) | Steps | Old vs new pixels |
|---|---|---|
| Z-Image-Turbo | 8 | bit-identical |
| FLUX.2-klein-4B | 4 | bit-identical |
| FLUX.1-schnell | 4 | bit-identical |
| Qwen-Image | 20 | bit-identical |
| Qwen-Image-2.1 | 20 | bit-identical |
| FLUX.3 Image Klein | 4 | bit-identical |

Old vs old and two renders in one process were also bit-identical, so
the comparison could have caught any change. Load time and peak VRAM
matched within noise (the arms shared cards, so no speed claim).
- Tests: `test_sd_cpp_install.py`, `test_diffusion_more_families.py`,
`test_sd_cpp_args.py`, `test_sd_cpp_vulkan_cpu_torch.py`: 411 passed, 1
skipped.

## Not verified

- Only the Linux CUDA 12 bundle was installed and run here; the Windows,
macOS, Vulkan and aarch64 bundles are checked by asset name only
(staging covers the install path on Windows and macOS).
- Paths the 14 upstream commits between the two bases touch beyond
MOSS-Image were not rendered: LoRA (the `--lora-apply-mode auto`
heuristic for quantized weights), edit / img2img, Qwen-Image-Edit and
Layered, MiniMax-H3 video, and the CUDA 13 / Vulkan / ROCm / CPU / macOS
/ Windows bundles.
- The Windows and macOS staging legs fail three tests this PR does not
change (`test_sd_cpp_args.py::test_native_speed_flags`,
`::test_minimax_h3_video_command_has_all_joint_av_components`,
`test_sd_cpp_install.py::test_safe_extractall_installs_a_chain_the_loader_can_still_walk`
on macOS;
`test_sd_cpp_install.py::test_a_failure_finalising_the_new_tree_is_an_incomplete_replacement`
on Windows). Only the pinned tag strings change in those files, and
these tests run on those runners only when a PR touches them, so they
fail the same way on main.

This branch was successfully deployed

1 active deployment
release-signing — 0a687648 Deployed Oct 21, 2026 by danielhanchen via win-cuda12-x64 #131
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.

7 participants