You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explore llama.cpp/ggml quantization kernels for our GGUF integration #14841
Transformers recently landed support for running llama.cpp / ggml quantization schemes directly, backed by a set of ggml kernels distributed through the kernels library. Write-up: https://huggingface.co/blog/transformers-llama-cpp-quants
This looks potentially interesting for our GGUF integration in Diffusers:
Today our GGUF support dequantizes on the fly; the ggml kernels could let us run quantized ops natively instead, which should help both memory and speed.
It could also open up nicer MPS / local-inference angles, which is a frequent ask for Diffusers users.
Relevant kernels (currently being moved from transformers-community to the ggml-org org):
Which of these kernels are actually applicable to diffusion model architectures (quantization/norm most likely; attn depends on our attention dispatch).
Whether they can be plugged into the existing GGUFQuantizer path via the kernels library.
Benchmark quality/speed/memory vs. the current dequantize-on-load behaviour, including on MPS.
While Llama.cpp proper cannot run models with media outputs, there is a longstanding downstream project that supports inference with a variety of diffusion models here. Llama.cpp contributor @ServeurpersoCom also maintains downstream GGML projects for Ace-Step and MiniMax Music.
I would like to take this one, and I think we can proceed in 3 steps.
ggml-quantization covers the linear layers of the transformer blocks, which should account for most of the GGUF weights, and RMSNorm is already possible via ggml-norm as long as the dtypes match up. ggml-attn depends on how we plan to hook into the attn dispatcher.
Load ggml-org/ggml-quantization from GGUFQuantizer via get_kernel and use the Metal build on MPS. CUDA can remain on Isotr0py/ggml's MMQ implementation. As a fallback we can continue to use dequantize when there is no kernel for a given quantization type.
I would like to run the benchmarks twice and post the results here, once with these changes and once with the current dequantize path. I will try Flux and SD3.5 models with Q4_K and Q8_0 GGUF quants, then we can look at similarity, step latency and peak memory on CUDA and MPS.
Can a maintainer please confirm the scope above looks right before I make a PR?
There is an import failure relevant to this integration and #12509. This CPU reproduction simulates CUDA eligibility while calling the real kernels loader:
Observed: the import fails with A kernel version or revision must be specified. Expected: an unavailable optional GGUF accelerator should not prevent importing an unrelated model.
GGUF utilities call get_kernel("Isotr0py/ggml") during model import without a version or revision. A warning plus native-dequantization fallback restores the tested imports while preserving the explicit trust requirement; it does not restore accelerated kernel compatibility. I can send a focused import/fallback fix after maintainer acknowledgment.
Found and reproduced with AI assistance; the repro above was run by me.
Activity
iwr-redmond commentedon Sep 23, 2026
While Llama.cpp proper cannot run models with media outputs, there is a longstanding downstream project that supports inference with a variety of diffusion models here. Llama.cpp contributor @ServeurpersoCom also maintains downstream GGML projects for Ace-Step and MiniMax Music.
LaelaZorana commentedon Oct 8, 2026
I would like to take this one, and I think we can proceed in 3 steps.
ggml-quantization covers the linear layers of the transformer blocks, which should account for most of the GGUF weights, and RMSNorm is already possible via ggml-norm as long as the dtypes match up. ggml-attn depends on how we plan to hook into the attn dispatcher.
Load ggml-org/ggml-quantization from GGUFQuantizer via get_kernel and use the Metal build on MPS. CUDA can remain on Isotr0py/ggml's MMQ implementation. As a fallback we can continue to use dequantize when there is no kernel for a given quantization type.
I would like to run the benchmarks twice and post the results here, once with these changes and once with the current dequantize path. I will try Flux and SD3.5 models with Q4_K and Q8_0 GGUF quants, then we can look at similarity, step latency and peak memory on CUDA and MPS.
Can a maintainer please confirm the scope above looks right before I make a PR?
Jackmeson1 commentedon Oct 20, 2026
There is an import failure relevant to this integration and #12509. This CPU reproduction simulates CUDA eligibility while calling the real kernels loader:
Observed: the import fails with
A kernel version or revision must be specified. Expected: an unavailable optional GGUF accelerator should not prevent importing an unrelated model.Environment: Python 3.12.15, diffusers
e04f0c5f/ 0.42.0.dev0, torch 2.14.1+cpu, kernels 0.17.2, gguf 0.19.0.GGUF utilities call
get_kernel("Isotr0py/ggml")during model import without a version or revision. A warning plus native-dequantization fallback restores the tested imports while preserving the explicit trust requirement; it does not restore accelerated kernel compatibility. I can send a focused import/fallback fix after maintainer acknowledgment.Found and reproduced with AI assistance; the repro above was run by me.