如果新一轮的 prompt 能够直接复用上一轮计算得到的 KV Cache,就能实现跨请求的 KV Cache 复用,从而显著提升 prefill 的性能,并降低新一轮请求的首次 Token 计算时间(Time To First Token,TTFT)。这种优化方法被称为 Prefix Caching,其核心思想是缓存系统提示和历史对话中的 KV Cache,以便在后续请求中复用,从而...
由前面的分析我们知道,RadixAttention算法中的Prefix Caching是包括Prefix和Generated KV Cache,并且如果Generated KV Cache如果也能被缓存,那么在多轮对话的场景中,显然具有更大的首Token时延优势。因此,我也比较关注vLLM实际的实现是否和RadixAttention算法描述的一致。我提了issue咨询vLLM团队,他们的回复是: yes! 也就...
hash值的计算非常重要:当两个等待做prefill的seq拥有同样的hash值时,说明它们共享一样的prompt,这时就可以重复利用已有的KV cache。(decode阶段当然也有这种操作,但有些许不同,我们在后文细聊)。计算hash值的脚本在Sequence类的定义下(一切尽在注释中): # vllm/vllm/sequence.py def hash_of_block(self, logi...
当请求不同的 prefix 较多,随着请求的不断输入,先前的 prefix cache 就会被驱逐,而后有相同 prefix 的请求就无法命中 prefix cache,需重新 prefill 得不到加速。 TACO LLM 提供 prefix cache offload 功能,在显存 prefix cache 被驱逐时 offload 到 cpu 内存上,命中时 load 回 gpu 中,进而加速原先 prefix cache...
We are planning to add prefix-cache-aware routing support, as mentioned in #26 . Here is an initial version of design. This design focuses on building the fundamental APIs for prefix-cache-aware routing, without requiring large API chang...
Your current environment vLLM version 0.5.0.post1 🐛 Describe the bug Hi, Seems that there is a dirty cache issue with --enable-prefix-caching. We noticed it as we saw internal eval scores significantly degrade when running with --enable-...
KV Cache reuse will speed up TTFT starting on the second request and following. You can use the following script to demonstrate the speedup: importtimeimportrequestsimportjson# Define your model endpoint URLAPI_URL="http://0.0.0.0:8000/v1/chat/completions"# Function to send a request to the...
KV Cache reuse will speed up TTFT starting on the second request and following. You can use the following script to demonstrate the speedup: importtimeimportrequestsimportjson# Define your model endpoint URLAPI_URL="http://0.0.0.0:8000/v1/chat/completions"# Function to send a request to the...
mss与prefix cacheing可以同时开。 启动命令: python3 -m vllm_mindspore.entrypoints vllm.entrypoints.openai.api_server --model "/data/checkpoints/dsr1-w8a8/" --trust_remote_code --tensor_parallel_size=16 --max-num-seqs 192 --max_model_len=4096 --enable-prefix-caching --port 8012 --dist...
但KV Cache 跟其它服务缓存不一样的地方是,它太大了,以至于(目前)很难通过 Redis/Memcache 这种分布式缓存服务存取。比如对 13B LLM 模型来说,在 FP16 精度下单 token 的 KV Cache 大约是 1MB,假设要缓存的前缀有 500 个 token(大约800多个汉字),那就是 500MB。一般来说,我们不会每次请求去从分布式系统里...