[PR #4179] [Engine] Qwen3.6-35B-A3B on a 4 GB Maxwell card: sm_52, UD-IQ3_XXS experts, k8v4 KV with host spill, small-VRAM placement #4935

Open
opened 2026-11-07 16:31:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4179
Author: @merbanan
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: pr/q36-small-card


📝 Commits (5)

  • 942ca51 [Engine] Qwen3.6 on a 4 GB Maxwell card: sm_52 build, UD-IQ3_XXS experts, int8 / k8v4 KV cache with host spill, layer-major prompt windows
  • 5299991 [Engine] Qwen3.6 on a small card: shared prompt buffers, decode slot adaptation, FP32 Q6_K decode, draft-p, MTP last row
  • 7a3c69e [Engine] Qwen3.6 KV8: host cells read once per layer through a VRAM bounce buffer in decode
  • 561ce00 [Engine] Qwen3.6 on a small card: Q6_K dense weights as Q8_0 rows (Q8S), the head lent to long prompts
  • 09965bd [Engine] CPU experts: multi-token i-quant downs (STRATA_IQ_DOWN_MT), IQ3_S nibble rows (STRATA_Q36_IQ3_NIBBLE)

📊 Changes

9 files changed (+1647 additions, -100 deletions)

View changed files

📝 CMakeLists.txt (+11 -2)
📝 include/strata/kernels/cpu/iq_avx2.hpp (+7 -0)
📝 include/strata/kernels/cpu/native_expert.hpp (+3 -0)
📝 src/core/device.cu (+2 -2)
📝 src/kernels/cpu/iq_avx2.cpp (+96 -0)
📝 src/kernels/cpu/native_expert.cpp (+23 -0)
📝 src/kernels/cuda/iq_kernels.cu (+76 -5)
📝 src/prefill/moe_mmq.cu (+7 -0)
📝 src/qwen35/q36_engine.cu (+1422 -91)

📄 Description

Problem and result: Qwen3.6-35B-A3B could not run on a small, old card. The experimental build stopped at sm_60, the engine refused Unsloth's UD-IQ3_XXS file (IQ3_S / Q3_K downs, Q2_K gate/up have no native expert kernels), and a 4 GB card has no room for an fp32 KV cache, the chunk buffers and expert slots at once. With this PR the file runs on a GTX 970 (4 GB, sm_52, PCIe gen3 x4) at a context of 131072, and matches or beats the community Pascal fork it used to need from 16K up (server, greedy, same prompts, 2 runs each):

this PR PP / TG (tok/s) Pascal fork PP / TG
short prompt 64-100 / 45.5-48.5 51-55 / 50-52
4K 240-243 / 31.1-32.2 246-257 / 34
16K 220-221 / 22.9-23.2 216-218 / 23
24K 210 / 20.3-20.4 195-196 / 18.7
64K 94.9 / 6.5 (max context 25K)
120K 44.7 / 3.3 (max context 25K)

Needle found in every run. Plain decode (no MTP) is still ~10% behind the fork at short contexts.

Related discussion: none yet; opened as a draft to agree on scope (it touches the q36 engine, the shared expert / MMQ kernels and the CPU pool). Happy to split it.

Approach: every new behaviour is opt-in; the default build and default runs are unchanged.

  • Build: the experimental build (STRATA_EXPERIMENTAL_SM60) accepts sm_52 (the existing dp4a / nanosleep fallbacks cover it).
  • Formats: IQ3_S and Q3_K downs, Q2_K gate/up in the native grouped expert kernels (llama.cpp's vec_dot transcribed); -DSTRATA_MMQ_Q23K=ON adds Q2_K / Q3_K MMQ prompt instances (one layer of each in this file would otherwise take MMQ away from every layer).
  • KV cache: STRATA_Q36_KV=q8|k8v4 (blocks of 32 with an fp16 scale; k8v4 8.9 KiB a cell), the first STRATA_Q36_KV_VRAM_MIB in VRAM and the rest in mapped pinned host memory, read once per layer through a VRAM bounce buffer in decode (STRATA_Q36_KV_BOUNCE), tiled online-softmax prompt attention; split-K partials sized for decode windows.
  • VRAM: STRATA_Q36_STAGE_SLOTS / STRATA_Q36_SHARE_BUFS put the staging pair and the chunk-sized buffers in the expert slots' memory (a 128-row set for decoding; a long prompt empties the slots under them, the rebalance refills them); STRATA_Q36_LEND_HEAD keeps one staging buffer in the head's VRAM during a long prompt (restored from a pinned copy); STRATA_Q36_EMBD_HOST, STRATA_Q36_ATT_MB.
  • Prompt: STRATA_Q36_WINDOW runs a long prompt layer by layer over windows of chunks (each layer's experts staged once per window).
  • Decode: STRATA_Q36_DENSE_Q8S (Q6_K dense matrices as int8 rows + fp16 scales at load, a multi-row kernel with every verify row in shared memory), STRATA_Q36_Q6K_F32 (fp32 Q6_K decode for cards without dp4a), STRATA_Q36_DRAFT_P (draft stop by MTP confidence), STRATA_Q36_MTP_LAST (the MTP block's MoE only for the row a draft needs), STRATA_Q36_REBAL_* (decode slot adaptation), STRATA_IQ_DOWN_MT (CPU pool: multi-token i-quant downs on iq256_rows).
  • Measured slower on this box and kept opt-in: STRATA_Q36_PIPE, STRATA_Q36_Q6K_STAGED, STRATA_Q36_IQ3_NIBBLE (port of the Pascal fork's MIT nibble rows).

Validation:
Passed:

  • sm_52 build of strata-q36 (CUDA 12.4, gcc-13, -DSTRATA_EXPERIMENTAL_SM60=ON -DSTRATA_MMQ_Q23K=ON) and the runs above on a GTX 970 + Ryzen 9 3900X, Qwen3.6-35B-A3B-UD-IQ3_XXS (sha256 36f9ec0e...), config in the comment below; needle-in-haystack at 4K / 16K / 24K / 64K / 120K; greedy text identical across repeated runs of a config.
  • default build (sm_75, gcc-13, STRATA_BUILD_TESTS=ON) of strata and strata-q36 on this revision: compiles and links.
    Failed: none observed.
    Not run: HIP, SYCL and Metal builds (no hardware here; the CPU pool, moe_mmq.cu, iq_kernels.cu and CMakeLists.txt changes touch shared code); the unit / parity tests and tools/qwen35 gates; any run on sm_75+ cards or with the default (non-opt-in) settings; other Qwen3.6 quantizations.

Limits: one card and one quant measured; plain decode ~10% behind the fork at short contexts (the CPU expert part stays partly on the critical path per layer); long contexts are bound by the x4 link and the card's attention compute.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4179 **Author:** [@merbanan](https://github.com/merbanan) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/q36-small-card` --- ### 📝 Commits (5) - [`942ca51`](https://github.com/Niko1221/Strata/commit/942ca514b4ecc2d0d4e0bad7a3336958fd6541c0) [Engine] Qwen3.6 on a 4 GB Maxwell card: sm_52 build, UD-IQ3_XXS experts, int8 / k8v4 KV cache with host spill, layer-major prompt windows - [`5299991`](https://github.com/Niko1221/Strata/commit/529999112442d74290bb723f2b4a416bf4099468) [Engine] Qwen3.6 on a small card: shared prompt buffers, decode slot adaptation, FP32 Q6_K decode, draft-p, MTP last row - [`7a3c69e`](https://github.com/Niko1221/Strata/commit/7a3c69ecde94e3a27d44331e128f76f4c61297c2) [Engine] Qwen3.6 KV8: host cells read once per layer through a VRAM bounce buffer in decode - [`561ce00`](https://github.com/Niko1221/Strata/commit/561ce004aa1bbb683ac58271879cb3463a3ffee8) [Engine] Qwen3.6 on a small card: Q6_K dense weights as Q8_0 rows (Q8S), the head lent to long prompts - [`09965bd`](https://github.com/Niko1221/Strata/commit/09965bd28b49341203d545a73ff9fa90c6be14f5) [Engine] CPU experts: multi-token i-quant downs (STRATA_IQ_DOWN_MT), IQ3_S nibble rows (STRATA_Q36_IQ3_NIBBLE) ### 📊 Changes **9 files changed** (+1647 additions, -100 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+11 -2) 📝 `include/strata/kernels/cpu/iq_avx2.hpp` (+7 -0) 📝 `include/strata/kernels/cpu/native_expert.hpp` (+3 -0) 📝 `src/core/device.cu` (+2 -2) 📝 `src/kernels/cpu/iq_avx2.cpp` (+96 -0) 📝 `src/kernels/cpu/native_expert.cpp` (+23 -0) 📝 `src/kernels/cuda/iq_kernels.cu` (+76 -5) 📝 `src/prefill/moe_mmq.cu` (+7 -0) 📝 `src/qwen35/q36_engine.cu` (+1422 -91) </details> ### 📄 Description Problem and result: Qwen3.6-35B-A3B could not run on a small, old card. The experimental build stopped at sm_60, the engine refused Unsloth's UD-IQ3_XXS file (IQ3_S / Q3_K downs, Q2_K gate/up have no native expert kernels), and a 4 GB card has no room for an fp32 KV cache, the chunk buffers and expert slots at once. With this PR the file runs on a GTX 970 (4 GB, sm_52, PCIe gen3 x4) at a context of 131072, and matches or beats the community Pascal fork it used to need from 16K up (server, greedy, same prompts, 2 runs each): | | this PR PP / TG (tok/s) | Pascal fork PP / TG | |---|---|---| | short prompt | 64-100 / 45.5-48.5 | 51-55 / 50-52 | | 4K | 240-243 / 31.1-32.2 | 246-257 / 34 | | 16K | 220-221 / 22.9-23.2 | 216-218 / 23 | | 24K | 210 / 20.3-20.4 | 195-196 / 18.7 | | 64K | 94.9 / 6.5 | (max context 25K) | | 120K | 44.7 / 3.3 | (max context 25K) | Needle found in every run. Plain decode (no MTP) is still ~10% behind the fork at short contexts. Related discussion: none yet; opened as a draft to agree on scope (it touches the q36 engine, the shared expert / MMQ kernels and the CPU pool). Happy to split it. Approach: every new behaviour is opt-in; the default build and default runs are unchanged. - Build: the experimental build (STRATA_EXPERIMENTAL_SM60) accepts sm_52 (the existing dp4a / nanosleep fallbacks cover it). - Formats: IQ3_S and Q3_K downs, Q2_K gate/up in the native grouped expert kernels (llama.cpp's vec_dot transcribed); `-DSTRATA_MMQ_Q23K=ON` adds Q2_K / Q3_K MMQ prompt instances (one layer of each in this file would otherwise take MMQ away from every layer). - KV cache: `STRATA_Q36_KV=q8|k8v4` (blocks of 32 with an fp16 scale; k8v4 8.9 KiB a cell), the first `STRATA_Q36_KV_VRAM_MIB` in VRAM and the rest in mapped pinned host memory, read once per layer through a VRAM bounce buffer in decode (`STRATA_Q36_KV_BOUNCE`), tiled online-softmax prompt attention; split-K partials sized for decode windows. - VRAM: `STRATA_Q36_STAGE_SLOTS` / `STRATA_Q36_SHARE_BUFS` put the staging pair and the chunk-sized buffers in the expert slots' memory (a 128-row set for decoding; a long prompt empties the slots under them, the rebalance refills them); `STRATA_Q36_LEND_HEAD` keeps one staging buffer in the head's VRAM during a long prompt (restored from a pinned copy); `STRATA_Q36_EMBD_HOST`, `STRATA_Q36_ATT_MB`. - Prompt: `STRATA_Q36_WINDOW` runs a long prompt layer by layer over windows of chunks (each layer's experts staged once per window). - Decode: `STRATA_Q36_DENSE_Q8S` (Q6_K dense matrices as int8 rows + fp16 scales at load, a multi-row kernel with every verify row in shared memory), `STRATA_Q36_Q6K_F32` (fp32 Q6_K decode for cards without dp4a), `STRATA_Q36_DRAFT_P` (draft stop by MTP confidence), `STRATA_Q36_MTP_LAST` (the MTP block's MoE only for the row a draft needs), `STRATA_Q36_REBAL_*` (decode slot adaptation), `STRATA_IQ_DOWN_MT` (CPU pool: multi-token i-quant downs on iq256_rows). - Measured slower on this box and kept opt-in: `STRATA_Q36_PIPE`, `STRATA_Q36_Q6K_STAGED`, `STRATA_Q36_IQ3_NIBBLE` (port of the Pascal fork's MIT nibble rows). Validation: Passed: - sm_52 build of strata-q36 (CUDA 12.4, gcc-13, -DSTRATA_EXPERIMENTAL_SM60=ON -DSTRATA_MMQ_Q23K=ON) and the runs above on a GTX 970 + Ryzen 9 3900X, Qwen3.6-35B-A3B-UD-IQ3_XXS (sha256 36f9ec0e...), config in the comment below; needle-in-haystack at 4K / 16K / 24K / 64K / 120K; greedy text identical across repeated runs of a config. - default build (sm_75, gcc-13, STRATA_BUILD_TESTS=ON) of strata and strata-q36 on this revision: compiles and links. Failed: none observed. Not run: HIP, SYCL and Metal builds (no hardware here; the CPU pool, moe_mmq.cu, iq_kernels.cu and CMakeLists.txt changes touch shared code); the unit / parity tests and tools/qwen35 gates; any run on sm_75+ cards or with the default (non-opt-in) settings; other Qwen3.6 quantizations. Limits: one card and one quant measured; plain decode ~10% behind the fork at short contexts (the CPU expert part stays partly on the critical path per layer); long contexts are bound by the x4 link and the card's attention compute. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4935
No description provided.