[GH-ISSUE #5069] [Engine] Qwen3.6-35B-A3B: support --kv int8 / --kv-resident and a long-context decode path, as the Flash-Next path has #2357

Open
opened 2026-11-04 01:58:40 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @BumBee-dev on GitHub (Nov 3, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5069

[Feature] Qwen3.6-35B-A3B: KV cache quantization and a long-context decode path, like the Flash-Next one

What

The qwen35moe (Qwen3.6-35B-A3B) engine path has no KV cache quantization: --kv, --kv-resident and
--cache-type-k/v are printed as ignoring <flag> (not an option of this engine) and skipped (see #5023, #3303),
so its KV is always fp32 at 44 KB per context token. On a 24 GB card this makes decode collapse as the context
grows, which makes the family unusable for RAG / agent workloads whose prompts are long by nature.

The qwen4exp (Qwen3.8-Flash-Next) path does not have this problem: it takes --kv int8 and --kv-resident, and
its decode stays essentially flat out to 200K+.

Request: give qwen35moe the same two capabilities — an int8 (and ideally k8v4) KV cache, --kv-resident,
and an attention path whose cost does not explode with context length (flash-attention-style, or the opt-in QSA
32-cell variant from #4567 wired into the CUDA build).

Why it matters (measured, not estimated)

Hardware: Tesla P40 24 GB, sm_61 (Pascal), driver 580.178.04, CUDA 12.6, engine 0.1.53 (v0.2.7.1
source build, -DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=61), 1 slot, greedy requests with MTP on.

Qwen3.6-35B-A3B, every routed expert resident in VRAM (every routed expert in VRAM (8.89 GiB)), so expert
streaming is not a factor. Decode vs. context:

context decode
~0.5K 88–93 tok/s
4K 55.6
8K 33.2
13.5K 19.5
36K 8.3
53K 6.8

That is ≈ 3.2 µs per 1K context tokens, i.e. an effective KV read bandwidth of ~14 GB/s on a 346 GB/s card
(4 % of peak)
.

Same card, same boot, the Flash-Next path (qwen4exp, --kv int8 --kv-resident 32768, IQ2_XS):

context decode
short 42.2 tok/s
4K 36.5
16K 36.6
43K 36.8

Same-shape control from the repository's own Pascal benchmark (#4920, GTX 1070 Ti 8 GB, sm_61, Flash-Next IQ2_XS,
--kv int8): decode 31.8 / 31.0 / 30.6 at short / 4K / 16K — flat on Pascal too.

And the same Qwen3.6 GGUF under llama.cpp (-ctk q8_0 -ctv q8_0 --flash-attn on) on the same card:
23.6 short → 17.5 at 43K (flat, lower absolute because of its constant per-token cost).

Decomposing the per-token cost at 43K context:

engine short ctx at 43K increment KV bytes read per step effective BW
Strata qwen36 (fp32 KV) 10.7 ms 147.1 ms +136.4 ms 1.94 GB 14 GB/s (4 %)
llama.cpp qwen36 (q8 KV + FA) 42.4 ms 57.1 ms +14.8 ms 0.48 GB 33 GB/s (9 %)
Strata Flash-Next (int8 KV) 23.7 ms 27.2 ms +3.5 ms 0.48 GB 139 GB/s (40 %)

Two independent gaps, both on the qwen35moe path: 4× more bytes (fp32 vs int8) and ~10× lower read
efficiency
(14 vs 139 GB/s).

Impact

  • Any prompt above ~10K tokens on a 24 GB card drops below 20 tok/s; a 50K-token prompt runs at 6.8 tok/s and its
    prefill alone takes 122 s (431 tok/s).
  • A memory/RAG service (retain/consolidate style workloads) issues exactly those long prompts, so the model is
    effectively limited to short turns even though --max-context 65536 is accepted.
  • It also costs VRAM: 64K of context is 2.95 GB as fp32 versus 0.74 GB as int8 — 2.2 GB that could be expert cache.
  • MTP does not help here: at 36K context --mtp 2 = 8.3 tok/s versus --mtp 0 = 8.7 tok/s. The context term
    dominates.

Suggested scope (smallest thing that helps)

  1. Parse and honour --kv int8 (and ideally k8v4) plus --kv-resident N in strata::qwen35::run, the way
    qwen4exp does — including the refusal in #5023 instead of a silent ignoring.
  2. A long-context decode attention path for the QSA layers that reads KV once per window at near-peak bandwidth.
    #4567's STRATA_QSA_ATTN_VARIANT=2 (32-cell chunks) exists but its issue notes "CUDA was not built (no NVIDIA
    card here)"
    , so it is not in any CUDA engine; at minimum please compile and measure it for CUDA.
  3. Document kv_bytes_per_token per family in docs/QWEN36.md (it is already in setup.py: 11 * 2 * 256 * 2 * 4),
    so users can predict this before installing.

Reproduce

# engine: v0.2.7.1 source build for Pascal
cd /opt/Strata
CC=gcc-13 CXX=g++-13 CUDAHOSTCXX=g++-13 STRATA_NVCC=/usr/local/cuda-12.6/bin/nvcc \
  ./setup.sh --setup --family qwen36 --model UD-Q4_K_XL --context 65536 --vision no --no-start --yes
# then serve the generated config, and time a 40K-token prompt:
#   every routed expert in VRAM (8.89 GiB) is printed at startup, and decode is ~8 tok/s

--kv int8 on that command line produces strata-q36: ignoring --kv int8 (not an option of this engine);
--kv-resident and --cache-type-k behave the same.

Environment

GPU Tesla P40 24 GB, sm_61, driver 580.178.04, PCIe 3.0 x16
CPU Xeon Platinum 8168, 10 cores, AVX-512 without VNNI
RAM 60 GB
Strata v0.2.7.1, engine 0.1.53, experimental CUDA 12 (sm_61) build, CUDA 12.6, gcc 13
Model unsloth/Qwen3.6-35B-A3B-MTP-GGUF UD-Q4_K_XL, and a 12.75 GB Q2_0 build with the MTP block baked in
Settings 1 slot, --mtp 2, --max-context 65536, greedy requests

Happy to run any build or measurement you want on this Pascal card and post the numbers back — including an
interleaved A/B of --kv int8 versus fp32 at 8K/32K/64K once the flag exists.

Originally created by @BumBee-dev on GitHub (Nov 3, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5069 # [Feature] Qwen3.6-35B-A3B: KV cache quantization and a long-context decode path, like the Flash-Next one ## What The `qwen35moe` (Qwen3.6-35B-A3B) engine path has no KV cache quantization: `--kv`, `--kv-resident` and `--cache-type-k/v` are printed as `ignoring <flag> (not an option of this engine)` and skipped (see #5023, #3303), so its KV is always fp32 at **44 KB per context token**. On a 24 GB card this makes decode collapse as the context grows, which makes the family unusable for RAG / agent workloads whose prompts are long by nature. The `qwen4exp` (Qwen3.8-Flash-Next) path does not have this problem: it takes `--kv int8` and `--kv-resident`, and its decode stays essentially flat out to 200K+. **Request:** give `qwen35moe` the same two capabilities — an int8 (and ideally `k8v4`) KV cache, `--kv-resident`, and an attention path whose cost does not explode with context length (flash-attention-style, or the opt-in QSA 32-cell variant from #4567 wired into the CUDA build). ## Why it matters (measured, not estimated) Hardware: **Tesla P40 24 GB, sm_61 (Pascal)**, driver 580.178.04, CUDA 12.6, engine **0.1.53** (`v0.2.7.1` source build, `-DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=61`), 1 slot, greedy requests with MTP on. **Qwen3.6-35B-A3B, every routed expert resident in VRAM** (`every routed expert in VRAM (8.89 GiB)`), so expert streaming is *not* a factor. Decode vs. context: | context | decode | |---:|---:| | ~0.5K | 88–93 tok/s | | 4K | 55.6 | | 8K | 33.2 | | 13.5K | 19.5 | | 36K | 8.3 | | 53K | 6.8 | That is ≈ **3.2 µs per 1K context tokens**, i.e. an effective KV read bandwidth of **~14 GB/s on a 346 GB/s card (4 % of peak)**. Same card, same boot, the Flash-Next path (`qwen4exp`, `--kv int8 --kv-resident 32768`, IQ2_XS): | context | decode | |---:|---:| | short | 42.2 tok/s | | 4K | 36.5 | | 16K | 36.6 | | 43K | **36.8** | Same-shape control from the repository's own Pascal benchmark (#4920, GTX 1070 Ti 8 GB, sm_61, Flash-Next IQ2_XS, `--kv int8`): decode **31.8 / 31.0 / 30.6** at short / 4K / 16K — flat on Pascal too. And the same Qwen3.6 GGUF under llama.cpp (`-ctk q8_0 -ctv q8_0 --flash-attn on`) on the same card: 23.6 short → 17.5 at 43K (flat, lower absolute because of its constant per-token cost). Decomposing the per-token cost at 43K context: | engine | short ctx | at 43K | increment | KV bytes read per step | effective BW | |---|---:|---:|---:|---:|---:| | Strata qwen36 (fp32 KV) | 10.7 ms | 147.1 ms | **+136.4 ms** | 1.94 GB | **14 GB/s (4 %)** | | llama.cpp qwen36 (q8 KV + FA) | 42.4 ms | 57.1 ms | +14.8 ms | 0.48 GB | 33 GB/s (9 %) | | Strata Flash-Next (int8 KV) | 23.7 ms | 27.2 ms | **+3.5 ms** | 0.48 GB | **139 GB/s (40 %)** | Two independent gaps, both on the qwen35moe path: **4× more bytes** (fp32 vs int8) and **~10× lower read efficiency** (14 vs 139 GB/s). ## Impact - Any prompt above ~10K tokens on a 24 GB card drops below 20 tok/s; a 50K-token prompt runs at 6.8 tok/s and its prefill alone takes 122 s (431 tok/s). - A memory/RAG service (retain/consolidate style workloads) issues exactly those long prompts, so the model is effectively limited to short turns even though `--max-context 65536` is accepted. - It also costs VRAM: 64K of context is 2.95 GB as fp32 versus 0.74 GB as int8 — 2.2 GB that could be expert cache. - MTP does not help here: at 36K context `--mtp 2` = 8.3 tok/s versus `--mtp 0` = 8.7 tok/s. The context term dominates. ## Suggested scope (smallest thing that helps) 1. Parse and honour `--kv int8` (and ideally `k8v4`) plus `--kv-resident N` in `strata::qwen35::run`, the way `qwen4exp` does — including the refusal in #5023 instead of a silent `ignoring`. 2. A long-context decode attention path for the QSA layers that reads KV once per window at near-peak bandwidth. #4567's `STRATA_QSA_ATTN_VARIANT=2` (32-cell chunks) exists but its issue notes *"CUDA was not built (no NVIDIA card here)"*, so it is not in any CUDA engine; at minimum please compile and measure it for CUDA. 3. Document `kv_bytes_per_token` per family in `docs/QWEN36.md` (it is already in `setup.py`: `11 * 2 * 256 * 2 * 4`), so users can predict this before installing. ## Reproduce ```bash # engine: v0.2.7.1 source build for Pascal cd /opt/Strata CC=gcc-13 CXX=g++-13 CUDAHOSTCXX=g++-13 STRATA_NVCC=/usr/local/cuda-12.6/bin/nvcc \ ./setup.sh --setup --family qwen36 --model UD-Q4_K_XL --context 65536 --vision no --no-start --yes # then serve the generated config, and time a 40K-token prompt: # every routed expert in VRAM (8.89 GiB) is printed at startup, and decode is ~8 tok/s ``` `--kv int8` on that command line produces `strata-q36: ignoring --kv int8 (not an option of this engine)`; `--kv-resident` and `--cache-type-k` behave the same. ## Environment | | | |---|---| | GPU | Tesla P40 24 GB, sm_61, driver 580.178.04, PCIe 3.0 x16 | | CPU | Xeon Platinum 8168, 10 cores, AVX-512 without VNNI | | RAM | 60 GB | | Strata | v0.2.7.1, engine 0.1.53, experimental CUDA 12 (sm_61) build, CUDA 12.6, gcc 13 | | Model | `unsloth/Qwen3.6-35B-A3B-MTP-GGUF` UD-Q4_K_XL, and a 12.75 GB Q2_0 build with the MTP block baked in | | Settings | 1 slot, `--mtp 2`, `--max-context 65536`, greedy requests | Happy to run any build or measurement you want on this Pascal card and post the numbers back — including an interleaved A/B of `--kv int8` versus fp32 at 8K/32K/64K once the flag exists.
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#2357
No description provided.