mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2941] [CLOSED] kv: mixed K16V8 (FP16 K, INT8 V) #4348
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4348
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2941
Author: @iskamag
Created: 10/17/2026
Status: ❌ Closed
Base:
main← Head:feat/k16v8📝 Commits (3)
743f9f9kv: mixed K16V8 (FP16 K, INT8 V) KV format7492fdekv: keep K16V8 on the fused attention pathfa49b96docs: K16V8 results and SVG output comparison📊 Changes
19 files changed (+1704 additions, -44 deletions)
View changed files
➕
docs/K16V8.md(+99 -0)➕
docs/media/k16v8/fp16.png(+0 -0)➕
docs/media/k16v8/fp16.svg(+574 -0)➕
docs/media/k16v8/int8.png(+0 -0)➕
docs/media/k16v8/int8.svg(+519 -0)➕
docs/media/k16v8/k16v8.png(+0 -0)➕
docs/media/k16v8/k16v8.svg(+288 -0)📝
include/strata/core/layer.hpp(+13 -1)📝
include/strata/kernels/kv_stream.hpp(+15 -2)📝
src/core/conversation_snapshot.cpp(+17 -8)📝
src/core/conversation_snapshot_test.cpp(+16 -3)📝
src/core/layer.cpp(+52 -5)📝
src/core/mtp.cpp(+4 -1)📝
src/core/verify.cpp(+16 -0)📝
src/kernels/cuda/kv_stream.cu(+12 -1)📝
src/kernels/cuda/qsa_decode_attn.cu(+36 -16)📝
src/kernels/kv_stream_parity.cpp(+22 -4)📝
src/prefill/prefill.cpp(+16 -1)📝
src/program/generate.cpp(+5 -2)📄 Description
Title
kv: mixed K16V8 (FP16 K, INT8 V)
Issue: Resolves # (none)
Summary
Adds
--kv k16v8, a KV cache format betweenint8andfp16: FP16 K + INT8 V (codes plus one FP16 scale per 64 values). It keeps FP16 precision for the attention scores while keeping the V-side memory saving: 1,552 B/cell vs 1,056 for int8 and 2,048 for fp16.The format streams with
--kv-resident(three runs: FP16 K, V codes, V scales), works with the MTP drafter (the drafter stays plain INT8, as under k8v4), and is independent of the SCR/suffix-reuse work.Full write-up and assets:
docs/K16V8.mdWhat changed
include/strata/core/layer.hpp,src/core/layer.cpp:kv_f16k_q8vstate flag, format tag 4, pool sizing, elastic/streamed host allocation, zeroing,qsa_attn_pools, decode append.src/kernels/cuda/qsa_decode_attn.cu: decode-attention mode 4 (FP16 K, INT8 V) acrossstep,batch,slotsandrows.src/kernels/cuda/kv_stream.cu,include/strata/kernels/kv_stream.hpp: 3-run block movers and the folded K/V host helpers for appends.src/prefill/prefill.cpp,src/core/verify.cpp,src/core/mtp.cpp: prefill/verify append paths; drafter forced to INT8 under k16v8.src/core/conversation_snapshot.cpp: per-side K/V sizes and format tag 4 (modes 0/1/2).src/program/generate.cpp:--kv k16v8parsing and help.src/kernels/kv_stream_parity.cpp,src/core/conversation_snapshot_test.cpp: mixed-format coverage.docs/K16V8.md,docs/media/k16v8/: results and the SVG output comparison.Extra Notes
Performance
Controlled A/B: same engine, IQ3_S, RX 6800 (gfx1030), HIP,
STRATA_HIP_PROMPT_F16=1, MTP spec 4, 13,109-token prompt, fully resident KV.int8k16v8fp16The three are within run-to-run/draft-acceptance noise. K16V8 is effectively int8 speed with FP16 K, and 24% smaller than fp16.
At 96k context and 12 QSA layers: 1.71 GiB host KV (vs ~1.16 GiB int8 / ~2.25 GiB fp16); 32,768 resident cells use ~610 MB VRAM (vs ~415 MB / ~805 MB). The extra VRAM against int8 can reduce the expert cache by roughly 200 MB.
Output length on the same prompt
Prompt:
Make an animated SVG of an anthropomorphic cat holding a swordint8k16v8fp16On this workload, higher KV precision correlated with fewer output tokens: int8 produced the longest response, fp16 the shortest, and k16v8 sat between them — consistent with less overthinking when the cache is more precise. This is one observation, not a general quality or latency guarantee.
Animated originals: int8, k16v8, fp16.
Compatibility
Exercised:
--kv-resident 0and32768,--mtp/--spec 4,--prompt-cacheprefix reuse, 96k context, vision, control vectors,--adapt-async,--expert-cache auto, HIP gfx1030.--no-fast-attnand--native-flash-attn-shortfall back to the fused decode attention for k16v8; the gather/native path is not implemented for this format.Not yet exercised:
--batch,--layer-split,--pipeline-windows,--kv-grow(elastic), and CUDA. Batch slots/rows and elastic allocation are implemented. On CUDA the prompt attention falls back to the decode kernel; gfx1030 already uses that path for most formats.--cache-suffix-reuseand--kv-pool-tokensare not inmain, so this change is independent of SCR.Tests
kv_stream_parity: all five formats pass; k16v8 streamed-vs-resident is bitwise and the ring restore is identical.conversation_snapshot_test: 4,872 checks pass, including k16v8 modes 0/1/2.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.