Optimize Chatterbox KV cache reads - #410
Conversation
Pass strided KV-cache views directly to flash attention.
eb3d02c to
e9d9bea
Compare
|
Merged after audit, with a follow-up proof on The direct per-layer K/V views are valid: their logical layout is contiguous and only the layer view offset is nonzero; Hosted live run 33333867440 is green: public Nano Q4_K + Turbo S3Gen Q4_K, same 40-token trajectory and byte-identical decoded PCM between direct-view and old-materialized paths. (The WAV containers themselves carry timestamped provenance, so the workflow correctly compares stream parameters and PCM rather than container bytes.) |
Summary
Pass GPT-2 K/V cache views directly to
ggml_flash_attn_extinstead of materializing the full KV history withggml_cont()on every layer and decode step.The naive attention fallback still materializes contiguous K/V tensors as before.
The same optimization can also be applied to the shared attention code in
attention.h. The flash-attention path can consume the strided KV-cache views directly.Result
On Chatterbox Nano CPU T3 decoding, this improves decode performance by about 2%