[GH-ISSUE #2693] Feature request: KV cache quantization (--kv int8 / --kv q4_0) for the Qwen3.6-35B-A3B (strata-q36) path #1074

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

Originally created by @TorBere on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2693

The q36 path keeps its KV cache in fp32 (src/qwen35; 45,056 B per context cell). On a 12 GB card that is the wall for long contexts: at --max-context 131072 the KV alone takes ~5.9 GB, so no routed expert stays in VRAM at all (engine log: 0 of 256 per layer in VRAM). The Flash-Next path already offers --kv int8 / --kv q4_0 / k8v4; on the q36 path, setting --kv int8 changes nothing (same KV size, same placement).

Setup: RTX 3060 12 GB, Ryzen 7 5800XT, 64 GB RAM, Windows 10, Strata 0.1.44.1 (ready-made CUDA 13 engine), unsloth/Qwen3.6-35B-A3B-MTP-GGUF UD-Q4_K_XL (setup's pinned file, SHA-256 checked), config as setup writes it (--native <gguf> --max-context N --prefill auto --mtp 2).

Measured (greedy, 120-token answers, warmup + 2 runs each, after a fresh start):

context decode experts in VRAM note
65,536 ~46 tok/s (45.5–47.1) 18 of 256 per layer (1.32 GiB) rest on the 8-thread CPU pool
131,072 ~34 tok/s (33.7–34.8) 0 of 256 — nothing fits fp32 KV ~5.9 GB
  • MTP (--mtp 2) is worth +40–44% here (46 vs 32 tok/s at 64K; 34 vs 24 at 128K) — it stays on.
  • In long filled conversations decode drops further (~30 tok/s; GPU ~50% utilised, memory controller ~36% — the bottleneck is the CPU/offload side plus the KV traffic).
  • On the same PC, llama.cpp (via LM Studio, Q4_K_M, 128K context, quantized KV) holds ~43 tok/s at 128K — the KV format is the visible difference.

Why this fits the existing code: Qwen3.6's head_dim is 256 — the exact size of the FWHT-256 rotation used by --kv q4_0 (PR #21). With int8 (1,056 B per cell) or q4_0 (576 B per cell) the 128K KV shrinks from ~5.9 GB to ~1.4 GB / ~0.76 GB: ~4.5–5.1 GB back for experts at 128K and 3–6x less KV traffic per decoded token (related: #2464, where decode falls with context on a V100).

Happy to run A/Bs (int8 vs q4_0 vs fp16, several contexts) on the 3060 if that helps.


Originally created by @TorBere on GitHub (Oct 15, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2693 The q36 path keeps its KV cache in fp32 (`src/qwen35`; 45,056 B per context cell). On a 12 GB card that is the wall for long contexts: at `--max-context 131072` the KV alone takes ~5.9 GB, so **no routed expert stays in VRAM at all** (engine log: `0 of 256 per layer in VRAM`). The Flash-Next path already offers `--kv int8` / `--kv q4_0` / `k8v4`; on the q36 path, setting `--kv int8` changes nothing (same KV size, same placement). Setup: RTX 3060 12 GB, Ryzen 7 5800XT, 64 GB RAM, Windows 10, Strata 0.1.44.1 (ready-made CUDA 13 engine), `unsloth/Qwen3.6-35B-A3B-MTP-GGUF` UD-Q4_K_XL (setup's pinned file, SHA-256 checked), config as setup writes it (`--native <gguf> --max-context N --prefill auto --mtp 2`). Measured (greedy, 120-token answers, warmup + 2 runs each, after a fresh start): | context | decode | experts in VRAM | note | | --- | --- | --- | --- | | 65,536 | ~46 tok/s (45.5–47.1) | 18 of 256 per layer (1.32 GiB) | rest on the 8-thread CPU pool | | 131,072 | ~34 tok/s (33.7–34.8) | **0 of 256 — nothing fits** | fp32 KV ~5.9 GB | - MTP (`--mtp 2`) is worth +40–44% here (46 vs 32 tok/s at 64K; 34 vs 24 at 128K) — it stays on. - In long filled conversations decode drops further (~30 tok/s; GPU ~50% utilised, memory controller ~36% — the bottleneck is the CPU/offload side plus the KV traffic). - On the same PC, llama.cpp (via LM Studio, Q4_K_M, 128K context, quantized KV) holds ~43 tok/s at 128K — the KV format is the visible difference. Why this fits the existing code: Qwen3.6's `head_dim` is 256 — the exact size of the FWHT-256 rotation used by `--kv q4_0` (PR #21). With int8 (1,056 B per cell) or q4_0 (576 B per cell) the 128K KV shrinks from ~5.9 GB to ~1.4 GB / ~0.76 GB: ~4.5–5.1 GB back for experts at 128K and 3–6x less KV traffic per decoded token (related: #2464, where decode falls with context on a V100). Happy to run A/Bs (int8 vs q4_0 vs fp16, several contexts) on the 3060 if that helps. ---
Author
Owner

@rintic-13 commented on GitHub (Oct 15, 2026):

You can use Qwen Flash Next to create Q 5_1 with Hadamar rotation in the code, Q4_0 is unacceptable for KV

<!-- gh-comment-id:6203912501 --> @rintic-13 commented on GitHub (Oct 15, 2026): You can use Qwen Flash Next to create Q 5_1 with Hadamar rotation in the code, Q4_0 is unacceptable for KV
Author
Owner

@TorBere commented on GitHub (Oct 15, 2026):

i've already made the change and set it to 8/8. This way it runs at 59 instead of 33 t/s with mtp=3. Pull request is up.

<!-- gh-comment-id:6204010731 --> @TorBere commented on GitHub (Oct 15, 2026): i've already made the change and set it to 8/8. This way it runs at 59 instead of 33 t/s with mtp=3. Pull request is up.
Author
Owner

@merbanan commented on GitHub (Oct 16, 2026):

I use k8v4. That seems to work ok.

<!-- gh-comment-id:6225607899 --> @merbanan commented on GitHub (Oct 16, 2026): I use k8v4. That seems to work ok.
Author
Owner

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

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271176337 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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#1074
No description provided.