llama.cpp b11576:填充 no-cache 注意力 KV 维度至 256
原标题:b11576
AI 摘要
llama.cpp 发布 b11576 版本,修复了 no-cache 注意力路径中 KV 维度未填充的问题。此前该路径构建 [n_tokens, n_tokens] 掩码并直接传入未填充的 K、V,导致 head size 512 的 CUDA 内核因不满足 FATTN_KQ_STRIDE 倍数要求而回退到 CPU,且 -fa auto 探测会禁用此类模型的 flash attention。本次改动将掩码按 llama_kv_cache::get_n_kv 方式填充,并将 K、V 用零填充至掩码的 KV 维度,clef 也采用相同填充方式。
正文节选
<details open> graph: pad the KV dimension of the no-cache attention to 256 (#30416) The no-cache path builds a [n_tokens, n_tokens] mask and passes K and V unpadded, so FLASH_ATTN_EXT sees K->ne[1] == n_tokens. The CUDA kernels for head size 512 require a multiple of FATTN_KQ_STRIDE, so the op falls back to the CPU for most lengths, and the -fa auto probe (1 token) disables flash attention for such models. Pad the mask like llama_kv_cache::get_n_kv and pad K and V with zeros up to the KV dim