llama.cpp
36591b9d - ggml-metal: hoist QK^T + softmax out of the d-block loop in the FA tensor kernel

Commit
95 days ago
ggml-metal: hoist QK^T + softmax out of the d-block loop in the FA tensor kernel For DV > 128 (NBLK > 1), the tensor kernel previously ran the entire QK^T + online-softmax pass once per d block (NBLKx the QK work). This restructures the NBLK == 2 case (dv = 256) so that QK^T + softmax run once per KV chunk and the P tile (f32, in registers) is reused for both PV d blocks (two live PV destination tiles). NBLK == 1 and NBLK == 4 (dv = 512) keep the per-block form: for NBLK == 4, carrying 4 live PV destination tiles would overflow the register file. 256/256, nq=512, kv=20000 (f16, mask): 43.4 ms -> 31.1 ms (0.71x -> 0.83x vs the vec kernel). Full test-backend-ops FLASH_ATTN_EXT suite passes (tensor on and off).
Author
Parents
Loading