llama.cpp 轮换 K/V 读取顺序,以提升 L2 缓存命中率(PR #32407)

该 PR 轮换 K/V 读取顺序以提升 L2 缓存命中率;作者在 RTX 5090 上用 qwen35 27B Q4_K - Medium 自测,n_depth 131072 时 prompt 处理速度由 master 分支的 1290.10833 t/s 升至 1822.36027 t/s(1.41 倍),上下文越深收益越大,浅上下文基本持平。
长上下文场景下 prompt 处理显著提速。
实测数据(各列为 gpu_info/model_type/n_prompt/n_gen/n_depth/Master (t/s)/PR (t/s)/Speed-up,其中 Master 为原 master 分支、PR 为本 PR):
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|131072|1290.10833|1822.36027|1.41
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|65536|2030.31282|2527.97409|1.25
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|32768|2931.96118|3142.20539|1.07
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|16384|3562.18311|3573.59336|1.00
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|8192|3854.83184|3850.97547|1.00
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|4096|3974.20194|4015.85501|1.01
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|2048|4079.23891|4077.58068|1.00
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|1024|4103.79141|4123.60737|1.00
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|512|4114.42862|4136.20591|1.01
NVIDIA GeForce RTX 5090|qwen35 27B Q4_K - Medium|512|0|0|4300.67808|4323.0908|1.01
由 /u/jacek2023 提交 [link] [comments]