Llama.cpp PR 带来 8% 速度提升

Reddit r/LocalLLaMA 工具

摘要

一个 llama.cpp PR 将采样从 CPU 移至 GPU,在 RTX 5090 上为 Qwen3.6-35B 推理带来 8% 的 token 速度提升,在 Tesla P40 上约为 4%。

Llama.cpp 目前对启用 MTP 的用户使用基于 CPU 的采样。该 PR 将采样移至 GPU,在 5090 上为 qwen3.6:35b 带来了 8% 的 tok/s 提升。我在我的 P40 上测试,观察到推理速度提升了 4%。看到我在 nvidia p40 上最高达到 84 tok/s 是非常令人兴奋的。后端采样在 Linux + Tesla P40 (sm_61, Pascal) 上显示出约 4% 的提升: CPU 采样: llama-server -m Qwen3.6-35B-A3B-UD-IQ4_NL.gguf --spec-type draft-mtp --seed 42 python3 mtp-bench.py code_python pred= 192 draft= 132 acc= 124 rate=0.939 tok/s=73.1 code_cpp pred= 113 draft= 76 acc= 74 rate=0.974 tok/s=75.9 explain_concept pred= 192 draft= 159 acc= 111 rate=0.698 tok/s=62.4 summarize pred= 192 draft= 167 acc= 107 rate=0.641 tok/s=59.6 qa_factual pred= 192 draft= 159 acc= 111 rate=0.698 tok/s=62.4 translation pred= 119 draft= 92 acc= 73 rate=0.793 tok/s=67.0 creative_short pred= 192 draft= 197 acc= 92 rate=0.467 tok/s=50.7 stepwise_math pred= 192 draft= 133 acc= 124 rate=0.932 tok/s=73.6 long_code_review pred= 192 draft= 155 acc= 113 rate=0.729 tok/s=63.8 后端采样: llama-server -m Qwen3.6-35B-A3B-UD-IQ4_NL.gguf --spec-type draft-mtp --seed 42 -bs python3 mtp-bench.py code_python pred= 192 draft= 132 acc= 124 rate=0.939 tok/s=76.2 code_cpp pred= 113 draft= 76 acc= 74 rate=0.974 tok/s=79.4 explain_concept pred= 192 draft= 159 acc= 111 rate=0.698 tok/s=64.6 summarize pred= 192 draft= 167 acc= 107 rate=0.641 tok/s=61.6 qa_factual pred= 192 draft= 159 acc= 111 rate=0.698 tok/s=64.6 translation pred= 119 draft= 92 acc= 73 rate=0.793 tok/s=69.6 creative_short pred= 192 draft= 197 acc= 92 rate=0.467 tok/s=52.1 stepwise_math pred= 192 draft= 133 acc= 124 rate=0.932 tok/s=76.6 long_code_review pred= 192 draft= 155 acc= 113 rate=0.729 tok/s=65.7 后端采样和 CPU 采样的接受率完全相同。改进幅度小于 RTX 5090(4% vs 12%),这在意料之中——P40 受内存带宽限制(sm_61,580 GB/s vs RTX 5090 的 1,792 GB/s),因此 CPU↔GPU logits 往返占整个解码时间的比例较小。不过,这仍然是我一段时间以来看到的 tok/s 最大提升。(约 +2 t/s)。 https://github.com/ggml-org/llama.cpp/pull/25532
查看原文

相似文章