Andy Bell (@andyjsbell) — Local reasoning models¶
Original post: https://x.com/andyjsbell/status/2117294046310011391
Posted: 2026-11-02T16:33:32Z · Collected: 2026-11-03T15:30:00Z
Why it matters¶
Concrete performance bug and fix in a Rust local-inference stack.
Summary¶
@andyjsbell found that a single .contiguous() call made Qwen2 decode 2.4× faster in Candle on Metal (42→102 tok/s at 2K context): after prefill the V tensor is a transposed view, so each cache append copied the whole KV cache. The fix is Candle PR #4077, with a write-up and repro.
Pull quotes¶
One
.contiguous()call makes Qwen2 decode 2.4× faster in Candle on Metal: 42 → 102 tok/s at 2k context. After prefill, V is a transposed view, so eachTensor::catcopies the whole KV cache.
Referenced links¶
Make value_states contiguous before the KV cache append in qwen by andyjsbell · Pull Request #4077 · huggingface/candle (from post
2117294046310011391)A non-contiguous KV cache cuts Qwen2 decode speed by 59 % at 2k context in Candle on Metal (from post
2117294046310011391)https://t.co/8yRRbz4d3J (from post
2117294046310011391)https://t.co/TEYt45ZydX (from post
2117294046310011391)