{"id":2486,"date":"2026-09-22T20:13:54","date_gmt":"2026-09-22T11:13:54","guid":{"rendered":"https:\/\/localmodelwatch.tsuchitsuchi.com\/2026\/09\/22\/transformers-llama-cpp-gguf-support\/"},"modified":"2026-09-22T20:13:54","modified_gmt":"2026-09-22T11:13:54","slug":"transformers-llama-cpp-gguf-support","status":"publish","type":"post","link":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/2026\/09\/22\/transformers-llama-cpp-gguf-support\/","title":{"rendered":"Run GGUF Models Directly in Transformers with llama.cpp Support"},"content":{"rendered":"<p><!-- lmw:facts --><\/p>\n<h2>At a Glance<\/h2>\n<div class=\"lmw-table-scroll\" tabindex=\"0\" style=\"overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%;\">\n<table style=\"width:max-content;min-width:100%;border-collapse:collapse;\">\n<thead>\n<tr>\n<th>Item<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Publisher<\/td>\n<td>Hugging Face Blog<\/td>\n<\/tr>\n<tr>\n<td>Published<\/td>\n<td>2026-09-22<\/td>\n<\/tr>\n<tr>\n<td>Source type<\/td>\n<td>Primary source (the publisher itself)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><em>Values determined by this site&#8217;s code at collection time. Dates are JST.<\/em><\/p>\n<p><!-- \/lmw:facts --><\/p>\n<h2>Overview<\/h2>\n<p>On September 22, 2026, Hugging Face announced the addition of direct and efficient execution support for GGUF format models from <code>llama.cpp<\/code> within the <code>transformers<\/code> inference library. This enables users to load GGUF checkpoints from the Hub via the <code>from_pretrained<\/code> API and run inference directly on their local machines. Initial optimization targets local inference of the Qwen3.5 architecture on Apple Silicon environments.<\/p>\n<h2>Announcement Details<\/h2>\n<p>Hugging Face announced a new integration allowing GGUF format models to be loaded and executed directly within the <code>transformers<\/code> ecosystem. GGUF is a format developed by the <code>llama.cpp<\/code> team and widely adopted in local AI tools such as Ollama, LM Studio, and Jan. This addition allows developers to use lightweight GGUF models while maintaining their familiar <code>transformers<\/code> Python APIs and PyTorch workflows.<\/p>\n<p>In terms of performance, aiming for execution speeds close to <code>llama.cpp<\/code>, a mechanism was introduced to directly utilize <code>ggml<\/code> Metal kernels via the <code>kernels<\/code> library. Specifically, it leverages <code>ggml-quantization<\/code> for matrix operations, <code>ggml-norm<\/code> for normalization, <code>ggml-attn<\/code> for attention processing, and <code>ggml-gated-delta-net<\/code> for hybrid architectures, alongside a custom <code>topk<\/code> kernel that speeds up routing in MoE models. Processing weights on Metal while keeping them packed reduces memory consumption and overhead, though it automatically falls back to <code>sdpa<\/code> (Scaled Dot-Product Attention) if compatible kernels are not available.<\/p>\n<p>For usage forms, beyond loading from scripts, it also supports launching an OpenAI-compatible API server using the <code>transformers serve<\/code> command. This enables client applications like Jan and Pi to use models via local endpoints such as <a href=\"http:\/\/localhost:8000\/v1\">http:\/\/localhost:8000\/v1<\/a>. Additionally, for those wishing to perform fine-tuning, setting <code>GgufConfig(dequantize=True)<\/code> dequantizes the model to incorporate it into standard <code>transformers<\/code> training workflows.<\/p>\n<p>Furthermore, to reduce synchronization between the CPU and GPU\u2014which often becomes an inference bottleneck\u2014improvements were also made to the <code>generate<\/code> loop itself. Enhancements include early filtering of unnecessary attention masks in inputs without padding (PR #48814) and asynchronous stop condition determination during token generation to increase execution overlap (PR #47975). These optimizations also contribute to improving inference efficiency for all non-GGUF <code>transformers<\/code> models.<\/p>\n<p>Note that the initial implementation currently has several limitations. The fast inference path using packed kernels is limited to Apple Silicon (MPS) environments, and other devices may require weight expansion. Additionally, optimizations for batched processing with padding (<code>generate_batch<\/code>) and support for model architectures other than Qwen3.5 (Dense\/MoE) and Qwen3.8 are planned for gradual expansion as future tasks.<\/p>\n<h2>Background<\/h2>\n<p>When the GGML and <code>llama.cpp<\/code> projects joined Hugging Face, their complementary roles were highlighted: <code>llama.cpp<\/code> provides the foundation for efficient local inference, while <code>transformers<\/code> provides the foundation for model definitions. <code>llama.cpp<\/code> features a dedicated runtime, memory management, and extensive hardware support, positioning it as the recommended engine for scenarios where efficient local inference is the top priority.<\/p>\n<p>With GGUF format models now directly executable within <code>transformers<\/code>, the distance between these two foundations has narrowed. By closely combining the flexible model definitions and ecosystem provided by <code>transformers<\/code> with <code>ggml<\/code>&#8216;s high-performance optimization kernels, developers can simultaneously advance local inference and advanced customization\/verification within a single environment.<\/p>\n<h2>Impact on Local LLM Users<\/h2>\n<p>For developers and engineers operating open-weight models in local environments such as personal PCs or servers, this integration brings the significant advantage of leveraging GGUF checkpoints while maintaining standard Python and PyTorch workflows. The specific impacts and utilization points presented in the documentation are as follows:<\/p>\n<ol>\n<li>\n<p><strong>Flexible Experimentation and Verification in Python\/PyTorch Environments<\/strong><br \/>\nUsing familiar PyTorch toolkits, developers can inspect intermediate activations via hooks, directly modify the model&#8217;s forward pass, and prototype custom layers for GGUF models. It also makes it easy to experiment with incorporating custom logits processors or stop conditions into <code>generate<\/code>, or writing custom generation loops in Python.<\/p>\n<\/li>\n<li>\n<p><strong>Evaluation and Fine-Tuning in Existing Workflows<\/strong><br \/>\nExisting <code>transformers<\/code> evaluation workflows can be applied as-is to measure generation quality across checkpoints of various quantization types. Furthermore, by loading the original checkpoint and the GGUF-converted model simultaneously on <code>transformers<\/code>, conversion accuracy can be verified while accounting for quantization errors. For training, users can specify <code>GgufConfig(dequantize=True)<\/code> to dequantize weights and proceed to standard <code>transformers<\/code> fine-tuning tasks.<\/p>\n<\/li>\n<li>\n<p><strong>Utilization of Kernels Beyond the GGUF Format and Expansion to Other Modalities<\/strong><br \/>\nThis optimization goes beyond merely reading GGUF files. Because <code>ggml<\/code>&#8216;s optimization kernels (matrix operations, normalization, attention, etc.) function on a per-tensor basis, they can potentially accelerate processing via PyTorch even when the entire model is not provided in GGUF format, or for new architectures, research models, and custom variants lacking full implementations on the <code>llama.cpp<\/code> side. As a future prospect, applying these kernels to other modalities such as image, audio, and multimodal models is also envisioned.<\/p>\n<\/li>\n<li>\n<p><strong>Current Limitations and Feedback Acceptance<\/strong><br \/>\nAt present, the speedup path using packed kernels is limited to Apple Silicon (MPS) environments; when compatible kernels are unavailable, it falls back to weight expansion (dequantization), increasing memory consumption. Moreover, optimizations for batched processing with padding (<code>generate_batch<\/code>) and support for architectures other than Qwen3.5 (Dense and MoE) or Qwen3.8 are noted as future tasks. Hugging Face invites users to share checkpoints and use cases on GitHub Issues if there are GGUF models they wish to use in local environments, planning to determine priority and progressively expand support based on demand.<\/p>\n<\/li>\n<\/ol>\n<p><!-- lmw:related --><\/p>\n<h2>Related Articles<\/h2>\n<ul>\n<li><a href=\"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/2026\/09\/21\/pruning-llms-like-a-physicist-cbo\/\">Pruning LLMs Like a Physicist: Constrained Binary Optimization<\/a><\/li>\n<\/ul>\n<p><!-- \/lmw:related --><\/p>\n<h2>Sources<\/h2>\n<ul>\n<li><a href=\"https:\/\/huggingface.co\/blog\/transformers-llama-cpp-quants\">https:\/\/huggingface.co\/blog\/transformers-llama-cpp-quants<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Hugging Face adds direct execution support for llama.cpp GGUF models in transformers, starting with local Qwen3.5 inference on Apple Silicon.<\/p>\n","protected":false},"author":1,"featured_media":2485,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[417],"tags":[505,163,1907,1073,165,759,1547],"class_list":["post-2486","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-companies-and-funding","tag-apple-silicon-en","tag-gguf-en","tag-hugging-face-blog-en","tag-llama-cpp-en","tag-moe-en","tag-transformers-en","tag-verified"],"lang":"en","translations":{"en":2486,"ja":2484},"_links":{"self":[{"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/posts\/2486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/comments?post=2486"}],"version-history":[{"count":0,"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/posts\/2486\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/media\/2485"}],"wp:attachment":[{"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/media?parent=2486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/categories?post=2486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/localmodelwatch.tsuchitsuchi.com\/en\/wp-json\/wp\/v2\/tags?post=2486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}