llama.cpp b11140:CUDA 稀疏注意力优化加速 dsv4 预填充
原标题:b11140
AI 摘要
llama.cpp 发布 b11140 版本,主要针对 CUDA 后端优化 DeepSeek-V4(dsv4)预填充阶段的 sparse-fa(稀疏 FlashAttention)。改动包括将 sparse mask 扫描的查询循环按 ncols1 模板化以在编译期确定循环边界,并把越界检查提升到主机端代码,使 49k 列稀疏解码形状下的扫描耗时从 46us 降至 17us,批量稀疏算子从 586us 降至 244us。该版本同时提供 macOS、Linux、Windows、Android 等多平台预编译二进制。
正文节选
<details open> CUDA: enable sparse-fa for dsv4 prefill (again) (#29298) * CUDA: enable sparse-fa for dsv4 prefill (again) * CUDA: unroll the query loop of the sparse mask scan The query loop of flash_attn_mask_to_sparse_indices has a runtime trip count, which keeps the unrolled scan over the values of a lane from issuing its loads together. Template the kernel on ncols1 so the loop is bounded at compile time: batch one decodes compile to straight line code and the scan drops from 46 to 17 us