[GH-ISSUE #739] [enhancement] Variance-normalized KV-cache quantization (KVarN) & KV cache precision tail #338

Closed
opened 2026-11-04 01:42:06 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @gregfromo on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/739

I'm comming from beellama.cpp and use the KVarN kv-cache types & tail.
Maybe you have time to take a look at this, if it's possible to implement in Strata, if you consider it as valueadding?

Great work sofar, many thanks!

Originally created by @gregfromo on GitHub (Oct 4, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/739 I'm comming from beellama.cpp and use the KVarN kv-cache types & tail. Maybe you have time to take a look at this, if it's possible to implement in Strata, if you consider it as valueadding? Great work sofar, many thanks!
Author
Owner

@Niko1221 commented on GitHub (Oct 7, 2026):

Could you show that variance-normalized KV types help here? A KLD and a needle test at 128K against --kv int8 on the same model would do. We have no data yet.

<!-- gh-comment-id:6037768523 --> @Niko1221 commented on GitHub (Oct 7, 2026): Could you show that variance-normalized KV types help here? A KLD and a needle test at 128K against --kv int8 on the same model would do. We have no data yet.
Author
Owner
<!-- gh-comment-id:6097156140 --> @gregfromo commented on GitHub (Oct 10, 2026): sorry, for late reply. you find it here : https://anbeeld.com/articles/kv-cache-quantization-benchmarks-kvarn-precision-tail https://anbeeld.com/articles/kvarn-kv-cache-implementation-and-benchmarks https://anbeeld.com/articles/kv-cache-quantization-benchmarks-kvarn-precision-tail
Author
Owner

@tugurufu-netizen commented on GitHub (Oct 11, 2026):

Hi Niko and Strata contributors

First of all, thank you very much in advance for taking the time to read through these numbers and practical feedback from an average user's everyday home-PC. What you have built with Strata's asynchronous DMA engine has completely transformed large MoE inference on consumer desktop hardware!

Conclusions written from Google AI Studio (G FL 3.8) chats. I've shortened the "long story" as much as I could. I apologize in advance for any AI imperfections in wording, style, and minor grammatical errors.


1. Mechanism & Quality Delta

  • Footprint: 4b Key / 2b Value averages 6.0 b/tok (~48 KB/tok on Qwen GQA) vs. 8.0 b/tok in --kv q4_0 (~64 KB/tok) — a flat, linear 25% VRAM reduction across all context lengths (saving ~150 MiB at 10k up to ~7.8 GiB at 524k tokens).
  • Quality Delta (KVarN 4/2 + 512-token F16 Tail vs. Symmetric Q4): Negligible degradation: \Delta\text{KLD} \le 0.0015 (0.0026 vs. 0.0011; threshold <0.005), NIAH retrieval -0.8\% (99.0% vs. 99.8%), \Delta\text{PPL} \le +0.08. The unquantized 512-token F16 tail fully protects local causal attention and MTP draft acceptance (>85%).
  • Weight-Quant Invariance: KV cache footprint is orthogonal to weight precision (IQ1_M through IQ4_XS). However, on tighter packs (IQ3/IQ4), model weights leave almost zero VRAM margin; reclaiming KV space is the sole lever to prevent expert cache starvation.

2. The Single-GPU Windows Reality (WDDM Allocation Ceiling)

  • The Hardware Reality: The vast majority of desktop users run a single discrete GPU under Windows 10/11 without a secondary display card, spare PCIe slots for headless setups, or a dual-boot Linux configuration.
  • WDDM Driver Penalty: Even with HAGS, browser GPU acceleration, and overlays completely disabled, combined WDDM/DWM reservations and the CUDA runtime context consume ~1.5–1.8 GB of physical VRAM
  • Direct Reinvestment: Reclaiming ~400–500 MiB from resident KV directly offsets this WDDM penalty, translating into +200 to +250 additional MoE expert slots in --expert-cache. This restores hit-rates from a struggling ~72% back above 80–85% at zero hardware cost.

3. Hardware Scaling Principle: "Lower-End Hardware Yields Higher Relative Leverage"

Because KVarN operates via standardized vectorized integer instructions on Tensor Cores (available since Turing SM 7.5), the performance return scales inversely with hardware capability.

Hardware & PCIe Bus Link DMA Speed 100k KV Transfer (Q4 vs. KVarN 4/2) Latency Delta Architectural Impact in Strata
Turing Baseline: PCIe 3.0 x16 / 6–8 GB
(RTX 2060 6/12GB, 2070 8GB, Quadro RTX 4000)
~7.1 GB/s ~901 ms vs. ~676 ms -225 ms/step Absolute minimum viable tier in Strata (SM 7.5). 1st-gen Tensor Cores natively accelerate INT4 KVarN; reclaims ~350 MiB VRAM, providing critical headroom to keep MTP draft layer (mtp/rt) resident and preventing instant prefill CUDA OOM.
PCIe 3.0 x8
(RTX 4060 Ti in B450 / bifurcated slot)
~3.6 GB/s ~1,777 ms vs. ~1,333 ms -444 ms/step Survival tier. Prevents fatal bus lockups; saves the ~3.6 GB/s link from choking and makes contexts >16k viable.
PCIe 3.0 x16
(RTX 5060 Ti 16GB, RTX A4000)
~7.1 GB/s ~901 ms vs. ~676 ms -225 ms/step Desktop sweet spot. Directly offsets the ~1.5 GB WDDM loss; pushes --expert-cache from ~3800 to ~4300+ slots (or ~4900+ on Linux/dGPU), nearly eliminating PCIe streaming stalls.
PCIe 4.0 x8 / x16
(RTX 3060 12G, 4070, 5070)
~13–26 GB/s ~492–246 ms vs. ~369–185 ms -61 to -123 ms Reclaims ~450 MiB resident VRAM to expand expert cache by ~220 slots on 12GB cards; accelerates deep retrieval.
PCIe 5.0 x16 / 24–48 GB
(RTX 3090, 4090, 5090, Ada)
~54 GB/s ~118 ms vs. ~89 ms -29 ms/step Bus link is unconstrained; benefits shift 100% to pure context expansion (saves 7.8+ GiB at 524k context), enabling multi-client batching.
<!-- gh-comment-id:6105179961 --> @tugurufu-netizen commented on GitHub (Oct 11, 2026): ### Hi Niko and Strata contributors First of all, thank you very much in advance for taking the time to read through these numbers and practical feedback from an average user's everyday home-PC. What you have built with Strata's asynchronous DMA engine has completely transformed large MoE inference on consumer desktop hardware! Conclusions written from Google AI Studio (G FL 3.8) chats. I've shortened the "long story" as much as I could. I apologize in advance for any AI imperfections in wording, style, and minor grammatical errors. --- ### 1. Mechanism & Quality Delta * **Footprint:** 4b Key / 2b Value averages **6.0 b/tok (~48 KB/tok on Qwen GQA)** vs. 8.0 b/tok in `--kv q4_0` (~64 KB/tok) — a flat, linear **25% VRAM reduction** across all context lengths (saving ~150 MiB at 10k up to **~7.8 GiB at 524k tokens**). * **Quality Delta (KVarN 4/2 + 512-token F16 Tail vs. Symmetric Q4):** Negligible degradation: $\Delta\text{KLD} \le 0.0015$ (0.0026 vs. 0.0011; threshold <0.005), NIAH retrieval $-0.8\%$ (99.0% vs. 99.8%), $\Delta\text{PPL} \le +0.08$. The unquantized 512-token F16 tail fully protects local causal attention and MTP draft acceptance (>85%). * **Weight-Quant Invariance:** KV cache footprint is orthogonal to weight precision (`IQ1_M` through `IQ4_XS`). However, on tighter packs (`IQ3`/`IQ4`), model weights leave almost zero VRAM margin; reclaiming KV space is the sole lever to prevent expert cache starvation. --- ### 2. The Single-GPU Windows Reality (WDDM Allocation Ceiling) * **The Hardware Reality:** The vast majority of desktop users run a **single discrete GPU under Windows 10/11** without a secondary display card, spare PCIe slots for headless setups, or a dual-boot Linux configuration. * **WDDM Driver Penalty:** Even with HAGS, browser GPU acceleration, and overlays completely disabled, combined WDDM/DWM reservations and the CUDA runtime context consume **~1.5–1.8 GB of physical VRAM** * **Direct Reinvestment:** Reclaiming **~400–500 MiB from resident KV** directly offsets this WDDM penalty, translating into **+200 to +250 additional MoE expert slots** in `--expert-cache`. This restores hit-rates from a struggling ~72% back above **80–85%** at zero hardware cost. --- ### 3. Hardware Scaling Principle: "Lower-End Hardware Yields Higher Relative Leverage" Because KVarN operates via standardized vectorized integer instructions on Tensor Cores (available since Turing SM 7.5), the performance return scales inversely with hardware capability. | Hardware & PCIe Bus Link | DMA Speed | 100k KV Transfer (Q4 vs. KVarN 4/2) | Latency Delta | Architectural Impact in Strata | | :--- | :--- | :--- | :--- | :--- | | **Turing Baseline: PCIe 3.0 x16 / 6–8 GB**<br>(RTX 2060 6/12GB, 2070 8GB, Quadro RTX 4000) | ~7.1 GB/s | ~901 ms vs. ~676 ms | **-225 ms/step** | **Absolute minimum viable tier in Strata (SM 7.5).** 1st-gen Tensor Cores natively accelerate INT4 KVarN; reclaims ~350 MiB VRAM, providing critical headroom to keep MTP draft layer (`mtp/rt`) resident and preventing instant prefill CUDA OOM. | | **PCIe 3.0 x8**<br>(RTX 4060 Ti in B450 / bifurcated slot) | ~3.6 GB/s | ~1,777 ms vs. ~1,333 ms | **-444 ms/step** | **Survival tier.** Prevents fatal bus lockups; saves the ~3.6 GB/s link from choking and makes contexts >16k viable. | | **PCIe 3.0 x16**<br>(RTX 5060 Ti 16GB, RTX A4000) | ~7.1 GB/s | ~901 ms vs. ~676 ms | **-225 ms/step** | **Desktop sweet spot.** Directly offsets the ~1.5 GB WDDM loss; pushes `--expert-cache` from ~3800 to **~4300+ slots** (or ~4900+ on Linux/dGPU), nearly eliminating PCIe streaming stalls. | | **PCIe 4.0 x8 / x16**<br>(RTX 3060 12G, 4070, 5070) | ~13–26 GB/s | ~492–246 ms vs. ~369–185 ms | **-61 to -123 ms** | Reclaims ~450 MiB resident VRAM to expand expert cache by ~220 slots on 12GB cards; accelerates deep retrieval. | | **PCIe 5.0 x16 / 24–48 GB**<br>(RTX 3090, 4090, 5090, Ada) | ~54 GB/s | ~118 ms vs. ~89 ms | **-29 ms/step** | Bus link is unconstrained; benefits shift 100% to **pure context expansion** (saves **7.8+ GiB at 524k context**), enabling multi-client batching. |
Author
Owner

@Niko1221 commented on GitHub (Oct 13, 2026):

Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.

If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.

<!-- gh-comment-id:6155961063 --> @Niko1221 commented on GitHub (Oct 13, 2026): Thanks for the report. To keep the tracker current we are closing issues older than three days: [0.1.44](https://github.com/Niko1221/Strata/releases/tag/v0.1.44) is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1. If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#338
No description provided.