llama.cpp b11927:Metal 后端新增融合 top-k mask 算子
原标题:b11927
AI 摘要
llama.cpp 发布 b11927 版本,为 Metal 后端新增 GGML_OP_TOP_K_MASK 算子,将 CUDA 后端已有的融合 top-k mask 实现移植到 Apple Metal。该实现先用 grid-stride 内核将输出填充为 -inf,再由每行一个 threadgroup 覆盖保留单元的 mask 值,并通过函数常量裁剪图中未使用的 score、blocks 等路径。此次更新提升了 Apple Silicon 设备上采样相关计算的 GPU 加速覆盖,并同步提供 macOS、iOS、Linux、Windows、Android 等多平台构建产物。
正文节选
<details open> metal : add GGML_OP_TOP_K_MASK (#31230) * metal : add GGML_OP_TOP_K_MASK Port the fused top-k mask from the CUDA backend: a grid-stride kernel fills the output with -inf, then one threadgroup per row copies the mask values of the kept cells over it. Function constants drop the score, blocks and extra paths that a given graph does not use. Assisted-by: dsh:llama.cpp/ggml-org/Qwen3.8-Flash-Next-GGUF (MacBook, M5 Max, 128GB) * metal : clean up top-k mask kernel formatting Assis