AISpot

llama.cpp 最佳化 Metal 後端:MXFP4 矩陣向量與 GLU 提速

llama.cpp releases版本更新地端推論開源

llama.cpp 發布 b11985,Metal 後端三項改動提速:MXFP4 矩陣向量核心改用 fp16 位技巧解碼 fp4 值、以對齊的 32 位字載入打包 nibble,不再佔用 threadgroup 記憶體;連續 unary/binary 與行廣播 binary 路徑改為每 threadgroup 最多 256 執行緒並對尾部做邊界檢查;GLU 的每行拆分到多個 threadgroup,單行 decode 不再只用一個 threadgroup。

Metal 核心層面的三項具體最佳化,直接作用於 Apple Silicon 上 llama.cpp 的量化推理與單行 decode 速度,對在 Mac 本地跑模型、關注 Metal 後端效能的人最有參考價值。

原標題:b11985
閱讀原文

評分52 / 55(平均 53,門檻 60)
狀態未入選

原文

metal : faster MXFP4 mat-vec, full threadgroups for unary/binary/GLU ( #31075 ) metal : faster MXFP4 mat-vec kernel Decode the fp4 values with the fp16 bit trick instead of a threadgroup lookup table, and load the packed nibbles as aligned 32-bit words. The kernel no longer uses threadgroup memory. metal : launch contiguous unary and binary ops with full threadgroups The contiguous unary path and the row-broadcast binary path used one thread per threadgroup. Use up to 256 threads per threadgroup and bound-check the tail. metal : split GLU rows across threadgroups A GLU row ran on one threadgroup, so single-row decode used a single threadgroup for the whole op. Split each row over threadgroups of up to 256 threads. Website: https://llama.app Attestations: https://github.com/ggml-org/llama.cpp/attestations/61399679 macOS/iOS: macOS Apple Silicon (arm64) macOS Apple Silicon (arm64, KleidiAI enabled) DISABLED macOS Intel (x64) iOS XCFramework Linux: Ubuntu x64 (CPU) Ubuntu arm64 (CPU) Ubuntu s390x (CPU) Ubuntu 26.04 s390x (CPU) Ubuntu 26.04 s390x (zDNN) Ubuntu x64 (Vulkan) Ubuntu arm64 (Vulkan) Ubuntu x64 (CUDA 12) - CUDA 12.8 libraries Ubuntu x64 (CUDA 13) - CUDA 13.4 libraries Ubuntu arm64 (CUDA 13) - CUDA 13.4 libraries Ubuntu x64 (ROCm 10.0) Ubuntu x64 (OpenVINO) Ubuntu x64 (SYCL FP32) Ubuntu x64 (SYCL FP16) Linux arm64 (Snapdragon: CPU, Adreno GPU, Hexagon NPU) - setup guide Android: Android arm64 (CPU) Android arm64 (Snapdragon: CPU, Adreno GPU, Hexagon NPU) - setup guide Windows: Windows x64 (CPU) Windows arm64 (CPU) Windows arm64 (OpenCL Adreno) Windows x64 (CUDA 12) - CUDA 12.4 DLLs Windows x64 (CUDA 13) - CUDA 13.4 DLLs Windows arm64 (CUDA 13) - CUDA 13.4 DLLs Windows x64 (Vulkan) Windows arm64 (Vulkan) Windows x64 (OpenVINO) Windows x64 (SYCL) Windows x64 (ROCm 10.0) openEuler: DISABLED openEuler x86 (310p) openEuler x86 (910b, ACL Graph) openEuler aarch64 (310p) openEuler aarch64 (910b, ACL Graph) UI: UI

相關報導

llama.cpp releases● 精選AI 評分62

llama.cpp Metal 把 few-row MMA 核心擴充套件到 BF16、MXFP4 等型別

llama.cpp 的 Metal 後端將通用 few-row MMA 矩陣乘法核心擴充套件到更多權重量化型別,BF16、Q1_0、Q2_0、MXFP4、Q2_K、Q3_K、TQ2_0 及 IQ 系列現已納入。該核心適用於任何帶 16-weight 反量化器的型別,各型別從在 M3 Ultra 上能勝過現有核心的行數起啟用:TQ2_0 為 5 行,BF16 為 4 行,MXFP4、Q2_0、Q2_K、IQ4_NL 為 3 行,其餘為 2 行。

llama.cpp releasesAI 評分56

llama.cpp CUDA 後端融合 FFN gate/up 矩陣乘與 GLU

llama.cpp 的 CUDA 後端把稠密 FFN 的 gate 與 up 兩次矩陣乘合併為一次 mul_mat_q 呼叫,並在寫回階段直接計算 GLU,主要加速 prompt 處理。權重按每 8 行交錯裝載,使每個執行緒同時持有 up 值與對應的 gate 值,MMA 迴圈、warp 佈局與 vec_dot 保持原樣,寫回只輸出一半行。

llama.cpp releasesAI 評分41

llama.cpp 修復 Metal 大矩陣偏移溢位問題

llama.cpp 建置版本 b11895 修復了 Metal 後端在大型矩陣輸出偏移時出現的整數溢位,同時加寬了 batch 偏移與 MUL_MAT_ID 的 token 索引。改動由 Codex 輔助完成,屬於影響大模型在 Apple Silicon 上推理正確性的底層修復,本次建置仍按慣例提供 macOS、Linux、Windows、Android 等多平台二進位制包。

llama.cpp releases● 精選AI 評分74

llama.cpp 修復 Metal 後端 MUL_MAT+ADD 融合錯誤

llama.cpp 合併 PR #30100,修復 Metal 後端 MUL_MAT+ADD 融合中殘差運算元的選擇錯誤:當 ADD 的兩個運算元都是矩陣乘法輸出(x = W1@u + W2@v)時,舊邏輯會選中自身從未寫入的輸出緩衝區,導致結果錯誤。Clef 決策模型因此在 Metal 上機率趨近均勻,billing 輸出 0.28,而 CPU 後端為 0.977,且同一檔案在 CPU 上結果正確,說明並非量化問題。