Skip to content

CPU: llamafile tinyBLAS GEMM for Q8_0 weights on x86 (bit-identical, 1.6x Q8_0 sampling) - #42

Open
danielhanchen wants to merge 1 commit into
cpu-speedfrom
cpu-sgemm-q8-0
Open

danielhanchen wants to merge 1 commit into
cpu-speedfrom
cpu-sgemm-q8-0

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Based on cpu-speed (#36). One new ggml patch, no source change.

Problem

The CPU build compiles out ggml's llamafile tinyBLAS GEMM (no sgemm.cpp object in the pin's or #36's build logs), so every Q8_0 matmul runs one vec_dot per output element. On a Q8_0 Z-Image DiT that dot product is 84% of the denoise time (per-op profile, Zen 2), and ComfyUI --cpu is 1.69x faster than the pin on Z-Image Q8_0 at 512 px.

Fix

ggml-patches/0017 builds tinyBLAS on x86 and routes Q8_0 weights through it. Every other type keeps its current path. GGML_CPU_SGEMM_TYPES selects the types (default q8_0).

Evidence

Colab CPU VMs (Intel Broadwell, 4 cores / 8 threads, 50 GB), #36 vs #36 + this patch, same VM, interleaved, 3 repeats:

VM Z-Image Q8_0, 512 px, 1 step #36 this branch
vm1 sampling 162.2 s [153.1, 201.5] 100.9 s [99.2, 139.3] (1.60x)
vm1 generate 239.7 s 153.2 s
vm5 sampling 161.3 s [145.2, 189.8] 100.9 s [100.6, 103.6] (1.60x)
vm5 generate 216.1 s 153.6 s
  • Pixels are identical to the same source built without the patch on the same VM.
  • Q4_K_M rows are unchanged, as expected (they already have a fast path).

Not covered

AVX512, Zen 4/5, hybrid Intel, Windows and ARM CPUs were not timed; only 4-core cloud VMs.

…ggml-patches/0017)

(cherry picked from commit f627101079f843f63f16e3fa9a873ddb26cb3d04)
@danielhanchen danielhanchen self-assigned this Nov 3, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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-11-03T20:50:11.371036Z ca0d2bc 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: ca0d2bc42c

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

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.

1 participant