GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Resync with upstream master-1056 (packed INT4 convrot, MiniMax-H3 QKV chunking, RelayVSR, SDXL ControlNet Union) by danielhanchen · Pull Request #54 · unslothai/stable-diffusion.cpp

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Update (Nov 9): ROCm and CUDA builds of this head, and every open PR on top of it

  • gfx1151 Linux, HIP build of this head (TheRock 7.14, GPU_TARGETS=gfx1151) vs master on the same box, 3 interleaved runs: SD1.5 F16 512 20 steps 6.06 -> 6.17 s, Z-Image Turbo Q4_K_M 512 8 steps 8.97 -> 8.93 s, identical pixels on both; FLASH_ATTN_EXT 4052/4052 and MUL_MAT 2449/2449 on ROCm0. RADV on the same box: identical pixels, 5.76 -> 5.76 s and 8.00 -> 7.97 s.
  • gfx1151 Windows 11, Vulkan build (AMD driver): SD1.5 identical pixels, 4.99 -> 5.07 s (master's own runs span 4.97 to 6.24 s). Z-Image flips between two images on master and on this branch alike (the timing-raced conv probe that Vulkan: pick direct convolution whenever its output check passes, not by a timing race #38 removes).
  • CUDA 12.8: this head merged with the GPU PRs (Vulkan: RMS norm for short rows (per-head Q/K norm 2.4-2.7x faster, bit-identical) #37 Vulkan: pick direct convolution whenever its output check passes, not by a timing race #38 ggml-cuda: Q8_0 weights take dequant-to-BF16 + cuBLAS by default; k-quants stay on MMQ #39 auto-fit: plan for integrated GPUs when no discrete GPU is present #51 HIP: bf16 WMMA operands as short vectors for gfx11 / gfx12 (ggml b3844edf2b) #59 Vulkan: no host-buffer import on AMD and MoltenVK (llama.cpp PR 30468) #60 HIP: FP32 accumulators in the tile FlashAttention kernel (long-sequence precision, upstream #2003) #61 CUDA: Q8_1 block sum from the quantized values (Q4_1 / Q5_1 / Q4_K / Q5_K / Q2_K up to 5x lower matmul error) #63 Qwen Image 2.1: concatenate the F16 prefix cache in F16 on reuse (bit-identical, 237 MB less copy traffic per step at 4k prefix) #64) compiles for sm75 and sm80, including the new w4.cu kernels.
  • Every open PR (Add a Linux ROCm leg to the prebuilt pipeline, so AMD hosts stop landing on the CPU build #14, CPU: AVX512 kernels on Intel, faster bit-identical direct convolution by default, physical-core thread default #36 to Prebuilt: run the Linux CPU bundles on emulated CPUs (Intel SDE, qemu-aarch64) before shipping #49, auto-fit: plan for integrated GPUs when no discrete GPU is present #51, Cosmos3-Nano-Sim-Transfer: video-to-video from edge control, streamed with a KV cache #53, Prebuilt: native Windows arm64 CPU bundle (5-6x faster than the x64 bundle under emulation) #55 to CPU direct convolution: convert each source row segment once per patch run (bit-identical, VAE decode 1.09-1.11x, 3x3 convs up to 1.3x) #70) merges into this branch without conflicts. CPU builds of this branch merged with all of them (the CPU stacks via their tips CPU: ik_llama.cpp GEMM kernels for K-quant and I-quant weights on ARM (Q2_K/Q3_K DiTs 1.5x, IQ text encoders up to 2.6x) #48, CPU x86: keep Q4_K / Q2_K on the tiled matmul on AMD CPUs (Klein Q4_K_M 1.12-1.16x on Zen 3 / Zen 4) #57, CPU aarch64: NEON + i8mm variant for 128-bit SVE cores (Neoverse N2 / V2: Q4_0 / Q8_0 / Q4_K repack 1.3x) #58, CPU direct convolution: convert each source row segment once per patch run (bit-identical, VAE decode 1.09-1.11x, 3x3 convs up to 1.3x) #70) pass. No ggml patch changes here, so every patch PR applies exactly as on master.
  • PRs that touch a file this branch also changes, so they should get a master merge and a CI run after this lands: CPU: AVX512 kernels on Intel, faster bit-identical direct convolution by default, physical-core thread default #36 CPU: llamafile tinyBLAS GEMM for Q8_0 weights on x86 (bit-identical, 1.6x Q8_0 sampling) #42 CPU: tinyBLAS GEMM for F16 / BF16 weights by default on x86 (VAE 1.9x, BF16 text encoder 2.4x) #47 CPU: ik_llama.cpp GEMM kernels for K-quant and I-quant weights on ARM (Q2_K/Q3_K DiTs 1.5x, IQ text encoders up to 2.6x) #48 Prebuilt: run the Linux CPU bundles on emulated CPUs (Intel SDE, qemu-aarch64) before shipping #49 CPU: tinyBLAS GEMM for Q4_1 / Q5_0 / Q5_1 weights (x86 bit-identical, 1.5-2.2x) and BF16 on ARM (19x) #56 CPU x86: keep Q4_K / Q2_K on the tiled matmul on AMD CPUs (Klein Q4_K_M 1.12-1.16x on Zen 3 / Zen 4) #57 CPU aarch64: NEON + i8mm variant for 128-bit SVE cores (Neoverse N2 / V2: Q4_0 / Q8_0 / Q4_K repack 1.3x) #58 CPU direct convolution: convert each source row segment once per patch run (bit-identical, VAE decode 1.09-1.11x, 3x3 convs up to 1.3x) #70 (src/core/util.cpp), Vulkan: pick direct convolution whenever its output check passes, not by a timing race #38 (diffusion_engine.cpp), CPU --mmap: repack what the CPU repacks, keep the rest mapped, release copied ranges #43 (common.cpp, util.cpp, model_loader.cpp), Cosmos3-Nano-Sim-Transfer: video-to-video from edge control, streamed with a KV cache #53 (README.md, common.cpp, model_loader.cpp, diffusion_engine.cpp), Qwen Image 2.1: concatenate the F16 prefix cache in F16 on reuse (bit-identical, 237 MB less copy traffic per step at 4k prefix) #64 (qwen_image_2_1.hpp; its F16 prefix path still engages and stays bit-identical on top of this branch), CPU: share the F32 to Q8 dot-input conversion between sibling projections (bit-identical, 1.08x Q3_K / IQ3_XXS DiT at hidden 1024) #65 (ggml_block.hpp).
  • For the next sync: upstream fixed Vulkan: Flux sampling ~6x slower since b1f5a51 (#2286 QKV chunking) - bisected across official release builds, SDXL unaffected leejet/stable-diffusion.cpp#2291 its own way after master-1056 (0b3b98d, fix: avoid CPU fallback based on backend allocation chunk size leejet/stable-diffusion.cpp#2294: Vulkan skips the allocation-size check). That conflicts with 71bf552 here; the two differ only for a single tensor past 4 GiB. Upstream's ggml pin is now d803c238: every open GPU patch applies there, but 0012-ggml-metal-group-norm-threads.patch does not (upstream a70d9e12 changes the same group norm code).

Summary

This merges upstream master-1056-9234ad8 into the fork. It is 6 upstream commits past the last sync (master-1050-58bb3c1, #52). The ggml submodule does not move (still 135ce1e0), so every patch in scripts/unsloth/ggml-patches applies unchanged.

It also fixes a Vulkan speed regression that upstream leejet#2286 introduced (leejet#2291), while keeping the MiniMax-H3 crash fix from that same commit.

What the 6 upstream commits bring

  • feat: support packed INT4 convrot models leejet/stable-diffusion.cpp#2276, perf: accelerate packed INT4 CUDA inference with CUTLASS leejet/stable-diffusion.cpp#2278, perf(vulkan): accelerate packed INT4 with cooperative matrices leejet/stable-diffusion.cpp#2280: loading for packed INT4 convrot checkpoints (convrot_w4a4 and asym_w4a8_int8), with CPU (src/core/cpu/w4.cpp), CUDA/HIP/MUSA (w4.cu, CUTLASS S8 x S4 GEMM on SM80+, HIP W4A8 WMMA) and Vulkan cooperative matrix kernels. Linear stores packed weights at half width, and config detection reads TensorStorage::logical_ne0(). These formats are opt-in: nothing changes for existing checkpoints.
  • feat: ControlNet Union support for SDXL leejet/stable-diffusion.cpp#2284: ControlNet Union for SDXL, and the UNet control residual scale is no longer in place (it segfaulted Vulkan with SDXL ControlNets).
  • feat: add RelayVSR video upscaling with CUDA window attention leejet/stable-diffusion.cpp#2285: RelayVSR video upscaling, parallel permute / interpolate in tensor.hpp, and a vectorised sd_image_to_tensor.
  • fix: chunk MiniMax-H3 QKV projections within backend buffer limits leejet/stable-diffusion.cpp#2286: MiniMax-H3 splits its QKV projection into token chunks when the packed F32 output would exceed the backend's buffer size (the Vulkan SIGSEGV on RADV / Strix Halo at 1024x1024x192 frames, [Bug] MiniMax-H3 on Vulkan: SIGSEGV in ggml_vk_tensor_subbuffer (ggml_vk_mul) at 1024x1024x192 frames, after #2257 leejet/stable-diffusion.cpp#2275). It also makes pin_multi_device_nodes move a node to the CPU when the node or one of its inputs is larger than the buffer type's max size, and switches RMSNorm to a non in-place multiply.

Upstream leejet#2290 (ggml bump to 3fc478e6) is not included. It is still open.

Fork changes on top of the merge

  • src/model/common/ggml_block.hpp (Linear::init_params, conflict): takes upstream's packed INT4 weight shape (half width, I8) and keeps the fork's sd_tag_matmul_only_weight tag for quantized weights. Packed INT4 weights are I8, so they are never tagged for CPU repacking.
  • src/model/diffusion/minimax_h3.hpp (conflict, hand-ported): upstream's project_qkv now returns separate Q/K/V tensors, while the fork's forward_head_major fast path reads the packed projection in place. Attention::forward now asks qkv_chunk_size() first:
    • not chunked (always on CPU and CUDA, and on Vulkan / Metal below the buffer size): the fork's packed fast path runs exactly as before, and the fallback attend gets the same views of the packed tensor the fork built.
    • chunked: upstream's split Q/K/V path.
      The segmented block takes upstream's project_qkv with the input preparation callback. Unchunked it builds the same per-segment projection and concat as before.
      Two additions in the same file: SD_H3_QKV_CHUNK_TOKENS=<n> caps the chunk size so the chunked path can be tested on any backend, and a one-time log line, MiniMax-H3: QKV projection of N tokens runs in chunks of M tokens.
  • src/core/ggml_runner.cpp (71bf552, the Vulkan: Flux sampling ~6x slower since b1f5a51 (#2286 QKV chunking) - bisected across official release builds, SDXL unaffected leejet/stable-diffusion.cpp#2291 regression): on Vulkan the buffer type's max size is the 1 GiB suballocation block (on AMD and Intel), not a device limit. ggml-vulkan allocates larger tensors on their own, and what it cannot bind is a range past maxStorageBufferRange, a 32-bit field. With upstream's check, every node over 1 GiB went to the CPU, for example the attention scores of Flux, Qwen-Image and Z-Image at 1024x1024 when flash attention is off. The threshold is now at least 4 GiB - 1 on Vulkan. Tensors that Vulkan cannot bind at all still fall back to the CPU, so the [Bug] MiniMax-H3 on Vulkan: SIGSEGV in ggml_vk_tensor_subbuffer (ggml_vk_mul) at 1024x1024x192 frames, after #2257 leejet/stable-diffusion.cpp#2275 case stays covered. Other backends keep their reported max size.
  • RMSNorm goes back to ggml_mul_inplace. Upstream made it non in-place so the multiply can follow the normalization to another backend; ggml patch 0013 already runs in-place ops on the backend that owns the output.
  • src/model_io/safetensors_io.cpp (c3d6fd5, packed INT4 layer config): upstream reads convrot_groupsize and group_size only from the top level of the per-layer quantization config JSON. Exporters may also write them under params (the reference loader reads both, top level first). Before this change, a W4A4 layer with {"params": {"convrot_groupsize": 64}} loaded as H256 instead of H64 (wrong rotation, different output), and a W4A8 layer with its group size under params, or with no group size at all, failed with invalid packed INT4 scales/codebook. The reader now takes each setting from the top level, then from params, then the format default (rotation 256; W4A8 weight group 16). Configs with the settings at the top level load exactly as before.

Every open fork PR still merges cleanly on top of this branch.

Testing

All comparisons are fork master ba6ac30 (base) against this branch on the same runner in the same job, interleaved.

Staging matrix, head 71bf552 (9 legs, the prebuilt leg flags, ggml patches applied, head run from its release bundle)

SD1.5 at 256x256, 4 steps (F16 / Q8_0 / Q3_K converted at load), and Z-Image Turbo Q2_K + Qwen3-4B Q2_K at 256x256, 2 steps. Cells are pixel identity, then median sampling seconds base / head (3 reps for F16 and Q8_0, 2 for the others).

leg builds head bundle SD1.5 F16 SD1.5 Q8_0 SD1.5 Q3_K Z-Image Q2_K
Linux x86_64 (ubuntu-22.04) ok / ok 38.5 MiB identical, 11.29 / 11.25 identical, 10.84 / 10.90 identical, 12.64 / 12.64 identical, 13.79 / 13.93
Linux x86_64 (ubuntu-latest) ok / ok 39.2 MiB identical, 19.28 / 19.25 identical, 18.98 / 19.15 identical, 21.44 / 21.41 identical, 33.51 / 33.48
Linux aarch64 ok / ok 35.6 MiB identical, 16.62 / 16.66 identical, 13.94 / 13.95 identical, 21.02 / 20.93 identical, 68.59 / 68.61
Linux x86_64 Vulkan build, CPU backend ok / ok 58.1 MiB identical, 16.59 / 16.58 identical, 16.42 / 16.45 identical, 18.19 / 18.16 identical, 27.44 / 27.73
macOS arm64 (Metal build) ok / ok 33.2 MiB identical, 36.85 / 35.54 identical, 26.27 / 25.25 identical, 25.54 / 25.09 identical, 48.65 / 47.83
macOS x86_64 ok / ok 39.1 MiB identical, 73.98 / 60.93 identical, 49.38 / 40.90 identical, 33.86 / 28.63 identical, 65.45 / 51.70
Windows x64 ok / ok 31.9 MiB identical, 19.86 / 19.95 identical, 20.73 / 20.82 identical, 24.09 / 24.16 identical, 35.25 / 35.37
Windows x64 Vulkan build, CPU backend ok / ok 53.5 MiB identical, 16.89 / 16.91 identical, 17.80 / 17.78 identical, 20.06 / 20.05 identical, 28.41 / 28.35
Windows arm64 ok / ok 31.3 MiB identical, 19.62 / 12.90 identical, 10.82 / 11.02 identical, 16.62 / 16.58 identical, 58.01 / 56.94

Metal on macOS arm64 (SD1.5 F16 at 512x512, 4 steps, 3 reps): pixel-identical; base 92.4 / 140.4 / 96.6 s, branch 93.9 / 131.3 / 119.9 s. The spread within each side (the hosted M1 runner) is wider than the difference between them. In the first pass it was base 134.2 s vs branch 128.1 s (medians). The macOS x86_64 and Windows arm64 runners are noisy as well (base repeats range from 66 to 105 s and from 14 to 23 s); on those runners the branch is never slower than the base range.

The first pass on e7f4838 (before 71bf552) gave the same picture: every leg built, every pair pixel-identical, and the medians within the base repeats.

Vulkan speed, Strix Halo gfx1151 (RADV), 1024x1024, 4 steps

Base, the plain merge (e7f4838, what upstream ships) and this branch. Seconds per step; base and branch ran twice, the plain merge once.

model flash attention base plain merge this branch branch pixels
FLUX.1-schnell Q2_K auto (on) 6.97 / 6.81 6.80 6.78 / 6.92 identical to base
FLUX.1-schnell Q2_K off 8.53 / 8.50 35.53 8.50 / 8.51 identical to base
Qwen-Image Q2_K auto (on) 8.53 / 8.36 8.40 (total 57.1 s vs 38.9 s) 8.40 / 8.46 identical to base
Qwen-Image Q2_K off 10.44 / 10.41 37.14 10.36 / 10.40 identical to base
Z-Image Turbo Q2_K auto (on) 5.20 / 5.23 5.26 5.21 / 5.22 identical to base
Z-Image Turbo Q2_K off 5.86 / 5.92 22.38 5.91 / 5.87 identical to base

The plain merge is 3.6x to 4.2x slower per step whenever attention scores are materialised, and its images differ from base because those nodes ran on the CPU. This branch matches base in time and pixels in every cell.

MiniMax-H3 (Q2_K DiT, Qwen3-VL 32B Q2_K_M, --diffusion-fa)

  • Strix Halo gfx1151, RADV (on e7f4838; 71bf552 does not touch this model's graph): 640x384x25 frames, 4 steps: base and branch give identical decoded frames, and repeats are identical (sampling 49.1 s on both). Forcing chunks of 512 tokens is also identical. At 1024x576x97 frames (18798 tokens) the branch chunks on its own (QKV projection of 18798 tokens runs in chunks of 12483 tokens) and renders frames identical to base, 293 s vs 296 s sampling. Base did not crash at this size; the [Bug] MiniMax-H3 on Vulkan: SIGSEGV in ggml_vk_tensor_subbuffer (ggml_vk_mul) at 1024x1024x192 frames, after #2257 leejet/stable-diffusion.cpp#2275 crash needs a tensor past 4 GiB (1024x1024x192), which was not run.
  • A100 (CUDA, sm80 build): 384x256x9 and 640x384x25 frames: base and branch give identical frames and audio. SD_H3_FAST_QKV=0 is identical to the fast path. Forced chunks of 384 and 1024 tokens are identical. Chunks of 256 and 128 differ (PSNR 26.9 / 28.7 dB on this 4-step Q2_K render), and a rounding-only change with no chunking (cuBLAS F32 compute type, or a build that sends every matmul to cuBLAS) moves the output by the same amount (28.9 / 28.3 dB). In the all-cuBLAS build, chunks of 256 are bit-identical, and with the DiT on CPU, chunks of 256 and 128 are bit-identical to unchunked and to base. So the difference is the quantized matmul rounding by row count, not the chunked path.

Packed INT4

  • No public checkpoint I found loads as published, on upstream or here: JoaoZaokk/Z-Image-Turbo-W4A4-ConvRot and a MiniMax-H3 W4A8 file keep their per-layer formats only in the safetensors header (_quantization_metadata), and the loader reads per-layer quantization config tensors. Both fail with wrong shape in model metadata on base and on this branch.
  • After adding the per-layer config tensors (weights untouched): Z-Image W4A4 renders a clean image on A100 (1.57 s sampling at 512x512, identical pixels with GGML_CUDA_W4_FORCE_DP4A=1) and on CPU (256x256, about 1200 s per step on 2 threads, so the CPU path is a fallback, not a fast path). MiniMax-H3 W4A8 renders a coherent clip on A100. Base cannot load the converted W4A4 file (W4A8 was not tried on base).

Packed INT4 layer config (c3d6fd5)

Tiny safetensors fixtures (2 x 256 packed weights, same bytes in every file), only the config JSON differs. Loader output from read_safetensors_file, then a CPU W4A4 matmul on the loaded tensor (ggml_mul_mat_w4_convrot), before (04e9eb0) and after (c3d6fd5):

config before after
W4A4, top-level convrot_groupsize: 64 H64, output [1304.126, -26.906] H64, output [1304.126, -26.906]
W4A4, params.convrot_groupsize: 64 H256, output [1557.206, 355.765] H64, output [1304.126, -26.906]
W4A4, no group size H256 H256
W4A4, top level 64 and params 16 H64 H64 (top level wins)
W4A8, top-level rotation 64 and group 16 loads, H64 loads, H64
W4A8, both under params rejected loads, H64
W4A8, no settings rejected loads, H256, group 16
W4A8, params.group_size: 32 rejected rejected (only group 16 is supported)
W4A8, top-level 32 and params 16 rejected rejected (top level wins)

Every top-level config gives the same result before and after; only the nested and default cases change.

Builds

  • Every staging leg above builds base and branch, and the branch's own package_bundle.py packages it.
  • The prebuilt workflow's CUDA legs on e7f4838: Linux CUDA 12 and CUDA 13 pass. Windows CUDA 12 and CUDA 13 compile and link sd-cli / sd-server, then stop at the signing check because the staging repository has no signing secrets.

Not verified

  • No CUDA, ROCm or Windows CUDA build of 71bf552 itself; it changes two small C++ hunks that the CPU, Vulkan and Metal legs compile.
  • The [Bug] MiniMax-H3 on Vulkan: SIGSEGV in ggml_vk_tensor_subbuffer (ggml_vk_mul) at 1024x1024x192 frames, after #2257 leejet/stable-diffusion.cpp#2275 size (1024x1024x192) was not rendered, so the "tensor past 4 GiB goes to the CPU" path did not run on real hardware.
  • No discrete-GPU Vulkan runner (the RX 6950 XT in Vulkan: Flux sampling ~6x slower since b1f5a51 (#2286 QKV chunking) - bisected across official release builds, SDXL unaffected leejet/stable-diffusion.cpp#2291 is RDNA2 with the proprietary driver); the speed check ran on RADV gfx1151.
  • Vulkan through lavapipe and Metal with Z-Image Q2_K abort the same way on base and on this branch (pre-allocated tensor ... in a buffer ... that cannot run the operation), so those cells are missing from the table. SD1.5 on Metal is pixel-identical.
  • The CUDA W4 kernel actually used is not logged, so CUTLASS being picked on sm80 is inferred from the speed difference, not observed.
  • RelayVSR and SDXL ControlNet Union were not run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
leejet and others added 8 commits November 6, 2026 00:35
@leejet @noctrex
feat: support packed INT4 convrot models (leejet#2276)
7952693
Co-authored-by: noctrex <[email protected]>
@leejet
perf: accelerate packed INT4 CUDA inference with CUTLASS (leejet#2278)
f5df5f8
@leejet
perf(vulkan): accelerate packed INT4 with cooperative matrices (leeje…
5a1ba5d
…t#2280)
@daniandtheweb
feat: ControlNet Union support for SDXL (leejet#2284)
fdfc913
@leejet
fix: chunk MiniMax-H3 QKV projections within backend buffer limits (l…
b1f5a51
…eejet#2286)
@leejet
feat: add RelayVSR video upscaling with CUDA window attention (leejet…
9234ad8
…#2285)
@danielhanchen
Merge upstream master 9234ad8 (master-1056) into the fork
ce40632
Conflicts: src/model/common/ggml_block.hpp keeps upstream's packed INT4 weight shape and the fork's matmul-only tag for quantized weights. src/model/diffusion/minimax_h3.hpp takes upstream's chunked QKV projection and keeps the fork's packed head-major fast path whenever the projection is not chunked.
@danielhanchen
MiniMax-H3: log once when the QKV projection is chunked
e7f4838
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T17:53:38.068602Z c3d6fd5 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danielhanchen and others added 2 commits November 7, 2026 18:33
@danielhanchen
Vulkan: only fall back to the CPU for tensors Vulkan cannot bind, kee…
71bf552
…p the in-place RMSNorm multiply

Upstream leejet#2286 moves a node to the CPU when it or an input is larger than the buffer type's max size. On Vulkan that is the 1 GiB suballocation block, not a device limit, so Flux attention at 1024x1024 ran on the CPU (leejet#2291). The threshold is now at least 4 GiB - 1 on Vulkan, the largest range a storage buffer binding can address. RMSNorm goes back to the in-place multiply: ggml patch 0013 already runs in-place ops on the backend that owns the output.
@danielhanchen
Vulkan: let supports_op decide tensor size, keep the allocation gate …
04e9eb0
…for other backends

The runner gate from upstream leejet#2286 compares a node and its inputs with the
buffer type's max size. On Vulkan that is the suballocation block, and the
4 GiB floor added for leejet#2291 still overrode ggml-vulkan's own check, which
accepts tensors up to max_buffer_size and past maxStorageBufferRange with
64-bit indexing. Vulkan nodes now go by supports_op alone, as before leejet#2286;
the QKV chunking and the gate for other backends stay.
@danielhanchen

danielhanchen commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

@codex review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 04e9eb0b9f

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danielhanchen
Packed INT4: read convrot_groupsize / group_size from params as well …
c3d6fd5
…as the top level
This was referenced Nov 9, 2026
CPU: llamafile tinyBLAS GEMM for Q8_0 weights on x86 (bit-identical, 1.6x Q8_0 sampling) #42
Merged
CPU: tinyBLAS GEMM for F16 / BF16 weights by default on x86 (VAE 1.9x, BF16 text encoder 2.4x) #47
Merged
HIP: FP32 accumulators in the tile FlashAttention kernel (long-sequence precision, upstream #2003) #61
Merged
Vulkan: pick direct convolution whenever its output check passes, not by a timing race #38
Merged
Vulkan: RMS norm for short rows (per-head Q/K norm 2.4-2.7x faster, bit-identical) #37
Merged
@danielhanchen

danielhanchen commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

chatgpt-codex-connector[bot] reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@danielhanchen

danielhanchen commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: c3d6fd52f9

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danielhanchen
danielhanchen merged commit 6e70077 into master Nov 9, 2026
@danielhanchen danielhanchen mentioned this pull request Nov 11, 2026
Studio sd.cpp: pin the prebuilt resynced with upstream master-1056 unslothai/unsloth#17459
Merged
debojyoti-dev pushed a commit to debojyoti-dev/unsloth that referenced this pull request Nov 11, 2026
@danielhanchen
Studio sd.cpp: pin the prebuilt resynced with upstream master-1056 (u…
57a486b
…nslothai#17459)

## Summary

Moves Studio's stable-diffusion.cpp prebuilt from
`master-982-0518b34-uba6ac30` to `master-982-0518b34-ueb0e729`, the
release built from fork master `eb0e729`. That is 36 fork commits on top
of the current pin. The tag keeps the `master-982` prefix because the
fork's release naming still counts from its last upstream release tag.

What the new build brings:

- Upstream resync to `master-1056` (unslothai/stable-diffusion.cpp#54):
packed INT4 convrot, MiniMax-H3 QKV chunking, RelayVSR, SDXL ControlNet
Union. Also Cosmos3-Nano-Sim-Transfer video-to-video (unslothai#53).
- x86 CPU: llamafile tinyBLAS GEMM for Q8_0 (unslothai#42), F16 / BF16 (unslothai#47) and
Q4_1 / Q5_0 / Q5_1 (unslothai#56) weights; an int8 tiled GEMM for Q8_0 / Q4_0 /
Q4_1 / Q5_0 / Q5_1 / IQ4_NL (unslothai#76); AVX512 kernels on Intel and a faster
direct convolution by default (unslothai#36, unslothai#70); Q4_K / Q2_K kept on the tiled
matmul on AMD (unslothai#57); Q5_0 / Q5_1 / Q4_1 through the Q8_0 GEMM at
diffusion batch sizes (unslothai#74); tiled flash attention and SIMD max fixes
(unslothai#66, unslothai#68, unslothai#62).
- aarch64 CPU: ik_llama.cpp GEMM kernels for K-quant and I-quant weights
(unslothai#48, unslothai#75), a NEON + i8mm variant for 128-bit SVE cores (unslothai#58), SVE flash
attention on the NEON path (unslothai#69), a 4x4 flash attention register tile
(unslothai#67).
- Metal: long graphs spread over more command buffers so the GPU
watchdog does not fire (unslothai#44), a coalesced im2col kernel (unslothai#45), flash
attention `auto` now means on without the timing probe (unslothai#46).
- Vulkan: RMS norm for short rows (unslothai#37), direct convolution chosen by an
output check instead of a timing race (unslothai#38), no host-buffer import on
AMD and MoltenVK (unslothai#60).
- HIP: bf16 WMMA operands for gfx11 / gfx12 (unslothai#59), FP32 accumulators in
the tile flash attention kernel (unslothai#61).
- CUDA: the Q8_1 block sum is computed from the quantized values, which
lowers matmul error for Q4_1 / Q5_1 / Q4_K / Q5_K / Q2_K weights (unslothai#63);
BF16 cuBLAS for large Q8_0 matmuls on A100, Hopper and datacenter
Blackwell (unslothai#39).
- Memory: the conditioning cache keeps entries across output sizes and
denoiser-only LoRA changes (unslothai#71); auto-fit charges unified-memory
devices against the RAM budget (unslothai#73, `SD_AUTOFIT_UMA=0` disables);
CPU-resident text-encoder weights are released when the next phase would
not fit (unslothai#72, `SD_TE_RELEASE=0` disables); `--mmap` repacks only what
the CPU repacks (unslothai#43); Qwen Image 2.1 prefix cache concatenated in F16
(unslothai#64).
- Packaging: bundles are smaller (unslothai#41; the Linux CPU bundle is 38.4 to
26.0 MiB, Linux CUDA 12 is 368.5 to 338.3 MiB, Linux Vulkan is 57.9 to
30.5 MiB), the Linux CPU bundles are run on emulated CPUs before
shipping (unslothai#49), and there is a new native Windows arm64 CPU bundle
(unslothai#55).

## Changes

- `studio/install_sd_cpp_prebuilt.py`: `DEFAULT_TAG` now names the new
release.
- Tests that pin the release name and its asset list now point at the
new tag. `test_sd_cpp_args.py` keeps the old pin in its list of builds
that support `--mmap`.
- The pinned asset lists gain `win-cpu-arm64`, with a test that a
Windows ARM64 host gets that bundle for `auto` / `cpu` while an x64 host
keeps `win-cpu-x64`, and that ARM64 with `cuda` or `vulkan` still gets
no match.

No Studio code changes. The existing selector already filters Windows
bundles by host architecture, so a Windows arm64 host, which today finds
no bundle in the pinned release and falls through to the upstream
fallback, now installs the native arm64 CPU build. An x64 Python running
under emulation on Windows arm64 reports `AMD64` and keeps the x64
bundle, as before. No option was removed from `sd-cli --help` or
`sd-server --help`; the new build only adds `--control-type`,
`--input-frames`, `--upscale-factor` and `--vsr-window-size`.

## Testing

- The sd.cpp, args, families, install, pin upgrade and download retry
tests pass (1406 passed). One test and one fixture error fail on main
and on this branch alike on this host, because its huggingface_hub is
older than the installed diffusers expects:
`test_create_causal_mask_patch_is_self_disabling_and_idempotent` and
`test_selection_installs_the_cuda_build`.
- Asset names: every bundle the selector can return was enumerated over
Linux x86_64 / aarch64, Windows AMD64 / ARM64 and macOS arm64 / x86_64,
with `auto`, `cpu`, `cuda` (no major, 12, 13), `vulkan` and `rocm`,
against the real asset list of the new release. Every returned name
exists in the release. The only change from the current pin is Windows
ARM64 `auto` / `cpu`, which goes from no match to `win-cpu-arm64`.
- SD1.5 (`v1-5-pruned-emaonly`), 512x512, 8 steps on CPU and 20 steps on
CUDA, euler, cfg 7, seed 42, both builds on the same machine. Each arm
repeated two or three times; every repeat was pixel-identical to the
first run of its arm. LPIPS is AlexNet.

Linux x86_64 CPU bundle, Xeon Platinum 8559C, 32 threads, wall time per
image:

| Weights | current pin | this branch | old vs new LPIPS | max pixel
diff |
| --- | --- | --- | --- | --- |
| f16 | 34.8 / 34.8 s | 16.4 / 17.2 s | 0.0001 | 13 |
| q8_0 | 31.3 / 32.4 s | 15.7 / 15.2 s | 0.007 | 118 |
| q4_K | 35.5 / 35.0 s | 18.7 / 19.0 s | 0.023 | 211 |

VAE decode alone went from 10 to 12 s down to 3.6 to 3.7 s. The
quantized CPU renders are not bit-identical to the current pin, but they
stay as close to the f16 render as before (q8_0 LPIPS to f16: 0.038 old,
0.046 new; q4_K: 0.163 old, 0.173 new).

Linux CUDA 12 bundle, Colab L4, wall time per image:

| Weights | current pin | this branch | old vs new LPIPS | max pixel
diff |
| --- | --- | --- | --- | --- |
| f16 | 4.70 / 4.70 / 4.71 s | 4.70 / 4.91 / 4.73 s | 0 | 0 |
| q8_0 | 7.42 / 4.92 / 4.90 s | 4.94 / 4.93 / 4.93 s | 0 | 0 |
| q4_1 | 18.13 / 17.97 / 17.94 s | 18.02 / 17.97 / 18.01 s | 0.025 | 198
|
| q4_K | 19.14 / 17.63 / 17.79 s | 17.74 / 17.63 / 17.61 s | 0.106 | 253
|

The current pin's first q8_0 run includes a cold start. f16 and q8_0 are
pixel-identical. q4_K moves, as the Q8_1 fix intends, and moves toward
the f16 render: LPIPS to f16 drops from 0.240 to 0.176 (q4_1: 0.327 to
0.322).

## Not covered

- macOS (Metal) and Windows were not run on hardware yet; the
cross-platform staging legs (Ubuntu, macOS 15, Windows) are still to
run.
- The new Windows arm64 bundle is covered only by the selector test and
the asset check. No Windows arm64 host ran it.
- No Vulkan, ROCm or HIP render with this build, no aarch64 Linux
render, and no Studio HTTP flow run (only `sd-cli` directly).
- No MiniMax-H3, MOSS-Image, Qwen-Image or FLUX.2 render with this
build; only SD1.5.
- CPU timings are from a shared host (both arms ran back to back with
the same thread count), and the CUDA timings come from one L4 VM, three
runs per arm. No T4 run.
@danielhanchen danielhanchen mentioned this pull request Nov 12, 2026
MiniMax-H3-Image on upstream #2324, with the release VAE tiling and edit inputs #84
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Vulkan: Flux sampling ~6x slower since b1f5a51 (#2286 QKV chunking) - bisected across official release builds, SDXL unaffected

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@danielhanchen @leejet @daniandtheweb
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.