Skip to content

Studio: pin the master-982 stable-diffusion.cpp prebuilt so MOSS-Image GGUFs load - #14565

Merged
danielhanchen merged 3 commits into
mainfrom
studio-sdcpp-pin-moss
Oct 21, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio-sdcpp-pin-moss

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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.

…GUFs load

MOSS-Image support landed upstream in master-975 (leejet/stable-diffusion.cpp#2148,
split QKV GGUF loading #2160). The previous base, master-968, cannot load the
transformer. Raise the floor the pin tests assert from 968 to 975 and keep the
previous pin in the macOS --mmap table.
@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-21T21:25:03.084855Z b61b51c Manual request
🔒 Security Review ⚠️ Failed 2026-10-21T21:21:51.568065Z
We couldn’t complete this review. Comment @codex security review to try again.
b61b51c 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

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: b61b51cb4c

ℹ️ 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
danielhanchen merged commit 5ab80ff into main Oct 21, 2026
@danielhanchen
danielhanchen deleted the studio-sdcpp-pin-moss branch October 21, 2026 22:02
danielhanchen added a commit that referenced this pull request Oct 23, 2026
…er lists them (#14860)

## Problem

Since the master-982 pin (#14565), the resident sd-server ignores image
LoRAs that Studio stages for it. `materialize_native_dir` stages each
adapter as a symlink from the per-request `gen_*` directory, under
`--lora-model-dir`, to the file in the LoRA cache. In sd-server at
`0518b34` (unchanged in the Unsloth patch set):

- `examples/server/runtime.cpp:294-298` (`refresh_lora_cache`) calls
`fs::canonical` on every entry and skips any entry that resolves outside
the LoRA directory.
- `examples/server/runtime.cpp:336-338` (`get_lora_full_path`) repeats
the containment check on the canonical path and requires a regular file.

So the staged symlink is never listed. The structured `lora` entry then
fails to resolve, and the request is rejected.

With the real master-982 CPU `sd-server`, `/sdapi/v1/loras` lists a
regular file and a hard link but leaves out Studio's symlink. The server
log shows `skipping inaccessible LoRA or path outside LoRA directory ...
runtime.cpp:297`.

## Fix

`materialize_native_dir` gains `real_files=True`, which stages a hard
link with the existing copy fallback (for example across filesystems).
The server generation path passes it. A hard link's canonical path stays
inside the server directory, so sd-server's containment check is
satisfied and stays fully in force. sd-cli staging is unchanged: it
resolves `<lora:...>` tags with `fs::exists` / `is_regular_file`, which
follow symlinks.

## Tests

- `test_materialize_native_dir_real_files_hardlinks_inside_dest`: checks
the staged file is not a symlink, its canonical path is inside the
destination, and it is the same inode as the source.
- `test_materialize_native_dir_real_files_copies_when_hardlink_fails`:
checks the copy fallback when `os.link` raises.
- `test_generate_server_stages_loras_as_real_files_inside_the_lora_dir`:
runs the real materializer through server-mode `generate`, checks the
staged file resolves inside `--lora-model-dir`, and checks that cleanup
leaves the source intact.
- On main, these 3 tests fail. With the fix, `test_diffusion_lora.py`
and `test_sd_cpp_backend.py` give 190 passed.
- With the real master-982 `sd-server`, the main materializer's output
is skipped and the fixed materializer's output is listed.

## Not covered

- No full image render with a LoRA through the server: there is no tiny
sd.cpp image GGUF on this host. Only the scan and resolve steps were
exercised against the real binary.
- No Windows run. `os.link` on NTFS should work, and the copy fallback
covers FAT and exFAT.
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.

1 participant