Transformers now runs llama.cpp quants Hugging Face added support for running GGUF models in its transformers library, letting users load llama.cpp-format checkpoints via `from_pretrained` and generate locally, with initial focus on Apple Silicon and the Qwen3.5 architecture. The company said it reuses llama.cpp's underlying ggml kernels through the `kernels` library to bring performance close to llama.cpp while reducing overhead in `generate`. For Unsloth's Qwen3.5-4B, GGUF variants range from 8.42 GB at BF16 to 2.74 GB at Q4_K_M, the quantization Hugging Face recommends as a starting point. Image-Text-to-Text • 4B • Updated • 908k • 432 https://huggingface.co/unsloth/Qwen3.5-4B-GGUF Transformers now runs llama.cpp quants Update on GitHub https://github.com/huggingface/blog/blob/main/transformers-llama-cpp-quants.md We're adding support for running GGUF models efficiently in transformers , so you can use checkpoints sized for your laptop's memory through the familiar transformers APIs. Pick a GGUF from the Hub, load it with from pretrained , and start generating on your own machine. Running AI models on your laptop has become much easier, and llama.cpp https://github.com/ggml-org/llama.cpp has been a big part of that. Its inference engine powers local AI tools such as Ollama, LM Studio, and Jan. Alongside projects like MLX https://github.com/ml-explore/mlx , it has helped make local inference a practical option for everyday use. A recent example of what local AI can feel like: This is where we are right now. And i’m not gonna lie it feels pretty magical 🧙♀️ Qwen3.6 27B running inside of Pi coding agent via Llama.cpp on the MacBook Pro For non-trivial tasks on the @huggingface https://x.com/huggingface?ref src=twsrc%5Etfw codebases, this feels very, very close to hitting the latest Opus in Claude… pic.twitter.com/lsIxLoUneU https://t.co/lsIxLoUneU April 24, 2026 https://x.com/julien c/status/2047647522173104145?ref src=twsrc%5Etfw GGUF , developed by the llama.cpp team, is a widely used format for local inference. The team also shares quantized checkpoints under ggml-org on the Hub https://huggingface.co/ggml-org . Publishers such as Unsloth https://huggingface.co/unsloth , LM Studio Community https://huggingface.co/lmstudio-community , and bartowski https://huggingface.co/bartowski also provide ready-to-use GGUF checkpoints in a range of quantizations, so users can pick the version that fits their machine. GGUF models have been downloaded millions of times. We want to make it easier to run these models locally with transformers, too. Compatibility is only useful if the model is pleasant to run. To bring performance close to llama.cpp, we're reusing its underlying ggml kernels through the kernels https://huggingface.co/docs/kernels/index library, and reducing overhead in generate . Our initial focus is local inference on Apple Silicon, starting with the Qwen3.5 architecture. What is the GGUF file format? GGUF https://github.com/ggml-org/ggml/blob/master/docs/gguf.md packages model weights and metadata, including tokenizer information and an optional chat template, in one file. It supports different quantization levels, letting you trade some precision for a smaller memory footprint. Variants such as Q4 K M mix tensor precisions, using mostly 4-bit weights while keeping sensitive tensors at higher precision. Here's how quantization changes the file size of Unsloth's Qwen3.5-4B https://huggingface.co/unsloth/Qwen3.5-4B-GGUF/tree/main : | GGUF variant | File size | Tradeoff | |---|---|---| | BF16 | 8.42 GB | Unquantized reference | | Q6 K | 3.53 GB | More precision than the smaller variants | | Q5 K M | 3.14 GB | A middle ground between size and precision | | Q4 K M | 2.74 GB | A practical starting point for local inference | We suggest starting with Q4 K M , then trying Q5 K M or Q6 K if you have more memory available. More aggressive quantization can help larger models fit, but the quality tradeoff depends on the model and the task. Evaluate it on the work you actually want the model to do. The Hub's GGUF documentation https://huggingface.co/docs/hub/gguf quantization-types describes the available quantization types. Load GGUF with transformers To get started, you need: - An Apple Silicon Mac . - A PyTorch version supported by the published ggml-quantization kernel builds https://huggingface.co/kernels/ggml-org/ggml-quantization , usually the two latest PyTorch releases. - The latest version of transformers main for now, until the next release and a compatible version of kernels . pip install -U "git+https://github.com/huggingface/transformers.git" kernels To load a GGUF model, pass its Hub model id and filename as gguf file to from pretrained . No extra configuration is needed: when the weights stay packed on Metal, transformers automatically loads the compatible ggml/Metal layer kernels and uses ggml-org/ggml-attn as the attention implementation. If that kernel cannot be fetched, the model falls back to "sdpa" with a warning, and you can always force "sdpa" by passing attn implementation="sdpa" explicitly. See the GGUF documentation https://huggingface.co/docs/transformers/main/en/quantization/gguf for more loading options. python import torch from transformers import AutoModelForCausalLM, AutoTokenizer model id = "unsloth/Qwen3.5-4B-GGUF" filename = "Qwen3.5-4B-Q4 K M.gguf" tokenizer = AutoTokenizer.from pretrained model id, gguf file=filename model = AutoModelForCausalLM.from pretrained model id, gguf file=filename That is the only GGUF-specific step. Everything after it is the standard transformers API: messages = {"role": "user", "content": "Explain why the sky is blue in a few sentences."} inputs = tokenizer.apply chat template messages, tokenize=True, add generation prompt=True, return dict=True, return tensors="pt", .to model.device with torch.inference mode : outputs = model.generate inputs, max new tokens=256 print tokenizer.decode outputs 0 , skip special tokens=True Without a compatible quantization kernel, the loader falls back to dequantizing the model and uses more memory. Serve GGUF with your preferred interface You can also use the same checkpoint with transformers serve https://huggingface.co/docs/transformers/main/en/serve-cli/serving , which exposes an OpenAI-compatible API: pip install -U "transformers serving @ git+https://github.com/huggingface/transformers.git" kernels transformers serve "unsloth/Qwen3.5-4B-GGUF:Qwen3.5-4B-Q4 K M.gguf" The model argument uses