Skip to content

Upstream/flash kv decode - #55

Open
DrJesseGlass wants to merge 2 commits into
downstreamfrom
upstream/flash-kv-decode
Open

Upstream/flash kv decode#55
DrJesseGlass wants to merge 2 commits into
downstreamfrom
upstream/flash-kv-decode

Conversation

@DrJesseGlass

Copy link
Copy Markdown
Owner

No description provided.

ivarflakstad and others added 2 commits June 26, 2026 23:12
Adds an f16 variant of the raw interleaved KV cache and matching CPU flash
kernels: RawInterleavedKvCacheF16 (head-major, grow-on-demand) with
causal_decode_f16kv_interleaved and causal_prefill_f16kv_headmajor. Storing
K/V as f16 halves the bytes streamed per decoded token - decode is memory
bound on CPU, so this is a direct throughput win - while accumulation stays
in f32 via the existing widening dot.

The optional f16-attn-dot cargo feature (default OFF, bit-exactness
preserved by default) switches the q.k dot to native fp16 FMA where the
target supports it.

Measured on Qwen3-0.6B (Apple M1, CPU): decode 1.28x at 1 thread, 1.13x at
4 threads; greedy output byte-identical to the f32 cache. On Graviton2 the
f16 cache underpins a 1.14x-1.17x decode win in the downstream stack.

Tests: cpu_flash_attn suite under both default and f16-attn-dot builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants