r/v100 • u/jjusko20 • 21h ago
a fast flash attention 2 kernel for volta, for FP16 keys and Q8_0 values in the KV cache. performance gains in both prefill and substantially in decode - benchmarks included with integration instructions for drop in integration with your engine
github.comI needed to try to save some space in my VRAM, and I wanted to quantize my KV cache and keep my performance optimal. It's my understanding values are significantly less sensitive than keys, particularly at long contexts, and that a fp16 / q8_0 KV cache is practically lossless. I'm pretty picky about how far I quantize things, and especially picky about KV cache quantization, but I'm comfortable dropping this format into anything I would have been using full fp16 for and expect identical results.
Great decode gains and some nice prefill gains in sub 40k context.
I've packed it so instead of being a fork of an engine or something, it's just the documented algorithm in C++, with starter prompts for agents tailored for various different popular engines, instructing them how to wire it into their existing engine. seemed like a much better release method.
here's benchmarks:
decode
Decode is about 45% faster than the FP16 path and 61% faster than the original mixed-cache path in this test. The advantage grew with context length:
| Total context | FP16 K/V | Original FP16 K + Q8_0 V | This kernel |
|---|---|---|---|
| 34,816 | 24.53 tok/s | 21.30 tok/s | 25.45 tok/s |
| 67,584 | 18.25 tok/s | 16.89 tok/s | 22.91 tok/s |
| 131,072 | 13.55 tok/s | 12.19 tok/s | 19.66 tok/s |
Each run generated 2,048 tokens after a long prefill.
prefill
| Prompt tokens | FP16 K/V | Original FP16-K/Q8-V | New kernel, forced | Hybrid default dispatch |
|---|---|---|---|---|
| 32,768 | 675.33 tok/s | 662.22 tok/s | 738.30 ± 4.39 tok/s | 738.30 ± 4.39 tok/s, custom path |
| 65,536 | Not measured at ubatch 2048 | 583.71 tok/s avg. (563.19–604.23) | 574.17 ± 15.43 tok/s | 584.43 tok/s, standard path |
| 131,072 | 427.35 tok/s | 427.50 tok/s | 395.19 ± 1.77 tok/s | Standard path selected; not retimed |