mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[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
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#4935
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/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 windows5299991[Engine] Qwen3.6 on a small card: shared prompt buffers, decode slot adaptation, FP32 Q6_K decode, draft-p, MTP last row7a3c69e[Engine] Qwen3.6 KV8: host cells read once per layer through a VRAM bounce buffer in decode561ce00[Engine] Qwen3.6 on a small card: Q6_K dense weights as Q8_0 rows (Q8S), the head lent to long prompts09965bd[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):
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.
-DSTRATA_MMQ_Q23K=ONadds Q2_K / Q3_K MMQ prompt instances (one layer of each in this file would otherwise take MMQ away from every layer).STRATA_Q36_KV=q8|k8v4(blocks of 32 with an fp16 scale; k8v4 8.9 KiB a cell), the firstSTRATA_Q36_KV_VRAM_MIBin 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.STRATA_Q36_STAGE_SLOTS/STRATA_Q36_SHARE_BUFSput 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_HEADkeeps 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.STRATA_Q36_WINDOWruns a long prompt layer by layer over windows of chunks (each layer's experts staged once per window).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).STRATA_Q36_PIPE,STRATA_Q36_Q6K_STAGED,STRATA_Q36_IQ3_NIBBLE(port of the Pascal fork's MIT nibble rows).Validation:
Passed:
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.