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 — CPU: three upstream ggml fixes (tiled AVX2 reduce, concat row kernel, NEON fp32 to fp16) by danielhanchen · Pull Request #62 · 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

Three CPU fixes from upstream ggml (ggml-org/llama.cpp, MIT), cherry-picked as patches on the pinned ggml (leejet/ggml 135ce1e0, no submodule bump). Based on master; independent of the open CPU stack (#36 / #42 / #47 / #48 / #49 / #56 / #57 / #58), and each patch also applies on top of it.

patch upstream change results
0040-ggml-cpu-tiled-avx2-reduce-accumulators.patch #30296 (3dbcb7fca) the AVX2 tiled K-quant / I-quant microkernel reduces its eight int32 accumulators together (hadd + permute) instead of one horizontal sum each bit-identical (integer additions)
0041-ggml-cpu-concat-row-kernel.patch #31179 (4d71b42fd) CPU concat as one row kernel for every type, rows split over all threads, tiles of 32 for transposed sources; adds upstream's transposed-b test-backend-ops cases same bytes (copies)
0042-ggml-cpu-neon-fp32-to-fp16.patch #30505 (119f68d7d) the NEON branch of simd-mappings.h defined the hardware fp32 -> fp16 conversion but never selected it, so aarch64 used the portable software conversion (im2col to F16 for VAE convs, F16 copies, F16 activations) same results except NaN payloads

Why these matter for diffusion:

  • 0040: the AVX2 builds (haswell / alderlake variants, and Zen 4 / Zen 5, which CPU: AVX512 kernels on Intel, faster bit-identical direct convolution by default, physical-core thread default #36's patch 0008 keeps on the AVX2 variant) run every K-quant / I-quant weight through this microkernel at diffusion batch sizes.
  • 0041: the old CPU concat split its work over dim 2 only. FLUX-style single blocks concatenate with ne2 == 1, so that concat ran on one thread; video VAE causal-cache concats got few threads.
  • 0042: every F16 conversion on aarch64.

Evidence

Base = master build, head = this branch, same flags (AVX2 + FMA + F16C, no native), Xeon Platinum 8559C, 8 pinned threads, 3 interleaved runs each. The host is shared and loaded, so timing is noisy; the bit checks are exact.

0040, mul_mat 3072 x 3072 x 1024 in the plain buffer (tiled path), FNV-1a hash over the output bits:

type base ms (3 runs) head ms (3 runs) output bits
Q3_K 33.0 / 35.0 / 29.4 27.5 / 26.4 / 28.5 identical
Q6_K 35.0 / 32.4 / 32.3 26.0 / 29.9 / 27.2 identical
Q5_K 34.4 / 31.7 / 37.7 25.6 / 36.4 / 25.6 identical
IQ4_XS 32.5 / 34.0 / 38.5 34.2 / 30.6 / 29.5 identical
IQ3_S 33.3 / 29.9 / 31.9 27.2 / 43.0 / 29.4 identical

An earlier pass also matched Q2_K, Q4_K and IQ2_XXS bit for bit at 3072 x 3072 x 256 and 9728 x 2560 x 64. Q3_K and Q6_K are about 1.2x faster, with the run ranges not overlapping; the other types are inside the noise here.

0041, concat at 8 threads, output hashed:

case base ms (3 runs) head ms (3 runs) output bits
single-block dim 0, [3072, 4608] + [9216, 4608] F32 107.1 / 91.8 / 81.0 20.0 / 20.0 / 5.9 identical
single-block dim 0, [3072, 1280] + [9216, 1280] F32 37.0 / 37.0 / 38.0 12.0 / 4.0 / 0.7 identical
tokens dim 1, [3072, 512] + [3072, 4096] F32 27.2 / 29.1 / 27.4 12.0 / 8.9 / 11.0 identical
VAE cache dim 2, [104, 60, 2, 384] + [104, 60, 1, 384] F32 / F16 noise noise identical
channels dim 3, [104, 60, 1, 192] x 2 F32 noise noise identical
tokens dim 1, transposed b noise noise identical

test-backend-ops -o CONCAT -b CPU: 226/226 passed, including the new transposed-b cases.

Staged run on GitHub runners (master vs this branch, same job, 4 threads):

mul_mat 3072 x 3072 x {128, 1024}, AVX2 (haswell) variant, output hashes identical in every cell:

type Xeon 8370C, 6 runs, n=1024 ms x EPYC 9V45, 3 runs, n=1024 ms x
Q2_K 117.7 -> 109.0 1.08 54.2 -> 48.7 1.11
Q3_K 102.7 -> 95.8 1.07 52.9 -> 48.6 1.09
Q4_K (plain buffer) 112.0 -> 100.3 1.12 50.7 -> 45.9 1.10
Q5_K 112.7 -> 101.0 1.12 49.9 -> 44.9 1.11
Q6_K 103.8 -> 96.8 1.07 50.2 -> 47.4 1.06
IQ4_XS 115.7 -> 104.4 1.11 58.4 -> 52.3 1.12
IQ2_XXS 101.9 -> 94.8 1.07 49.6 -> 47.3 1.05

The AVX-512 (zen4) variant and Neoverse N2 are unchanged (0.98-1.03x, same hashes), as expected: 0040 touches the AVX2 microkernel only. Q4_K in the repack buffer is unchanged.

test-backend-ops -o CONCAT -b CPU: 226/226 on EPYC 9V45 and on Neoverse N2 (master: 198/198, without the new cases).

0042 on Neoverse N2: CPY f32 -> f16 [512, 3072] 574.6 -> 124.9 us (4.6x); the other CPY / IM2COL cases are within 1-7%.

FLUX.2-klein-4B DiT, 512 x 512, 2 steps, s/step (3 runs each), image md5 identical master vs branch for every row:

DiT EPYC 7763 (AVX2) Neoverse N2
Q3_K_M 51.7 -> 48.7 (1.06x) 141.1 -> 140.9
Q4_K_M 54.9 -> 52.9 (1.04x) 78.6 -> 78.4
F16 121.9 -> 122.4 127.9 -> 127.6

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
@danielhanchen
CPU: three upstream ggml fixes (ggml-patches/0031-0033)
d82c258
- 0031, ggml-org/llama.cpp#30296: the AVX2 tiled K-quant microkernel reduces its
  eight int32 accumulators together (hadd + permute) instead of one horizontal
  sum each. Integer additions, so bit-identical.
- 0032, ggml-org/llama.cpp#31179: CPU concat as one row kernel for every type,
  rows split over all threads. The old kernel split over dim 2 only, so the
  FLUX single-block concat (ne2 == 1) ran on one thread. Same bytes.
- 0033, ggml-org/llama.cpp#30505: select the NEON fp32 -> fp16 conversion the
  NEON branch already defined (aarch64 used the portable software conversion).
  Same results except NaN payloads.

All three cherry-picked as patches on the pinned ggml (no submodule bump).
@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-08T10:38:38.559602Z 1522783 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: d82c2580f9

ℹ️ 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
ggml-patches: renumber the upstream picks to 0040-0042
1522783
0031-0033 are also used by other open PRs (HIP / Vulkan patches).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 1522783451

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

This was referenced Nov 9, 2026
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
Merged
CPU flash attention: convert each K / V tile once per four Q tiles (bit-identical, 1.26-1.30x on AVX512, 1.22-1.31x on Apple M1 at 1024 px) #66
Merged
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
Merged
@danielhanchen
danielhanchen merged commit 8b7441a into master Nov 9, 2026
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.

Uh oh!

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

1 participant

@danielhanchen
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.