关于--parallel 2 的测试
软硬件环境:
cpu: AMD Ryzen 7 9700X
RAM:DDR5 64GB 6000
GPU:R9700 32G
OS: Ubuntu 24.04
软件 : llama.cpp + vulkan
结论:将并行设为1或者2,大部分情况下,性能变化属于正常波动,没有明显差别。
但是,即使有32G显存,有些任务还是会报以下错误:
26.48.401.777 E init_batch: failed to prepare attention ubatches
26.48.401.778 W decode: failed to find a memory slot for batch of size 16
26.48.401.779 W srv decode: failed to find free space in the KV cache, retrying with smaller batch size, off = 190, n_batch = 8, ret = 1
26.48.403.275 E init_batch: failed to prepare attention ubatches
26.48.403.277 W decode: failed to find a memory slot for batch of size 8
26.48.403.277 W srv decode: failed to find free space in the KV cache, retrying with smaller batch size, off = 190, n_batch = 4, ret = 1
虽然使用了 --cache-type-k/v q8_0 做 KV 量化来节省显存,但是 128K 的超长上下文,加上 --parallel 2,对 KV Cache 的要求依然极其恐怖。模型权重稳稳地占了 17GB。但当开启并发,且 Prompt 超长时,给 128K 上下文预留的 KV Cache 空间,在高峰期(特别是并发请求时)瞬间耗尽了,导致没有空位给下一个 Token 的生成。
好消息是,llama.cpp不能为KV Cache分配空间,并不会导致崩溃或任务中断(我没有碰到过),只会导致llama.cpp降级重试,严重的情况下会感觉明显卡顿而已,不用过于担心。
所以,用7900XTX的朋友,把并发设为1可能是更好的选择。