Unable to get KV cache from GPU when KV cache is quantized to q8_0 #34555
|
Hello everyone, I am currently building a prototype pipeline for the GUI Agent project (GSoC Project 1) and have run into a blocker I'd appreciate some guidance on. As part of the pipeline, I need to capture a snapshot of the KV cache prior to image input being processed. To handle longer contexts more efficiently, I attempted to quantize the KV cache to Issue It appears that KV cache compression (quantization) and the state snapshot API are mutually exclusive in the current implementation. get_state and set_state will not work when KV cache is quantized What Works Question Thank you in advance for your help! |
Replies: 1 comment 3 replies
|
@KarSri7694 The error message is actually quite informative: From what I could find, this is currently a limitation of the GPU plugin rather than a bug. The OpenVINO documentation explicitly states that when KV-cache quantization/compression is enabled on the GPU:
So with a configuration such as: ov_config = {
"KV_CACHE_PRECISION": "u8", # q8_0 equivalent KV compression
}the following is expected to fail: infer_request.get_state()
infer_request.set_state()On the other hand, using an uncompressed KV cache (e.g. So, regarding your question:
From what I can tell, I couldn't find any documented workaround that allows
I also couldn't find any public roadmap or issue indicating planned support for combining GPU KV-cache compression with state snapshot APIs. Out of curiosity, is your pipeline tied specifically to the GPU plugin? The reason I ask is that this limitation is documented specifically for GPU. If your prototype can tolerate CPU execution for the snapshot stage, it would be interesting to know whether that satisfies your use case, or whether the snapshot/restore must happen entirely on the GPU. If this solves your problem, feel free to mark it as the accepted answer so others can find it easily. |
Hi @Ganesh-403
Yes, The pipeline is specifically tied to using GPU, as without it, inference would be way too slow, I was able to create logic using claude to implement
get_state()andset_state()for compressed KV cache.You can find the code I implemented here.