[PR #3699] [Engine] qwen35: accept Q4_K down-projection experts (Q4_K_M GGUFs) #4751

Open
opened 2026-11-07 15:38:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3699
Author: @xyehya
Created: 10/22/2026
Status: 🔄 Open

Base: main ← Head: engine-q36-q4k-down


📝 Commits (2)

  • b377a35 [Engine] qwen35: accept Q4_K down-projection experts
  • 6e1e99b [Engine] qwen35: a parity case for the Q4_K down experts at FF 512

📊 Changes

4 files changed (+14 additions, -5 deletions)

View changed files

📝 CMakeLists.txt (+3 -0)
📝 docs/QWEN36.md (+1 -0)
📝 src/kernels/cuda/iq_kernels.cu (+3 -3)
📝 src/kernels/native_expert_parity.cpp (+7 -2)

📄 Description

Problem and result: a Q4_K_M GGUF of a Qwen3.6-35B-A3B-architecture model (qwen35moe) is refused at load by the Qwen3.6 engine path:

strata-q36: blk.5.experts are Q4_K/Q4_K, which the native expert kernels do not take (build with -DSTRATA_Q6K_EXPERTS=ON for Q6_K)

llama.cpp's Q4_K_M recipe stores the routed experts' down projection as Q4_K in about half the layers (here 20 of 41: Q4_K/Q4_K/Q4_K x 20, Q4_K/Q4_K/Q6_K x 21). STRATA_D_FMTS has Q5_K and Q6_K but no Q4_K, so native_expert_supported() returns false. With Q4_K (type 12) added to both STRATA_D_FMTS variants the file loads and runs. The gate/up side already takes Q4_K (it is in STRATA_GU_FMTS) and the CPU pool goes through ggml's vec_dot, so only the GPU down-format list changes.

Model: InternScience/Sage-A1.5 (Qwen3.6-35B-A3B fine-tune, Apache-2.0), official Q4_K_M. That file has a second, separate obstacle (its ssm_alpha / ssm_beta are Q4_K too, which upload_f32 refuses); I worked around it outside the engine by grafting the original BF16 gates, so it is not part of this PR. The resulting file is at https://huggingface.co/ykarout/Strata-Sage-A1.5-GGUF for anyone who wants to reproduce.

Approach: one entry in the existing format list. Flash-Next is unaffected: its FF 640 is not a multiple of Q4_K's 256-value block, so native_expert_supported() still refuses Q4_K downs there, before and after (the existing comment says the same for Q5_K / Q6_K).

Validation (revision 011c9e6 + this commit, Fedora 44, CUDA 13.4, gcc-15 host compiler, RTX 5080 16 GB sm_120, 64 GB DDR5; engine 0.1.47 build of this tree):

Passed:

  • cmake --build build --target strata (CUDA) builds clean.
  • Load: --native Sage-A1.5-Q4_K_M-ssmbf16.gguf --max-context 32768 --prefill auto --mtp 2 --pool-workers 16 -> hybrid experts: 112 of 256 per layer in VRAM (8.16 GiB), serves.
  • Through serve/server.py, 3 fresh ~3.6K-token code prompts, 384 tokens each, temp 1.0: pp 4,560 / 4,885 / 5,069 tok/s, tg 133.9 / 153.2 / 154.7 tok/s, every request completed (1,152 tokens).
  • Greedy text vs llama.cpp (b11798 CUDA build, same GGUF, temp 0, thinking off, 160 tokens, 3 prompts): Fibonacci code prompt identical for the first 380 characters, primes prompt identical, capital-of-Australia prompt diverges after 48 characters at a near-tie word ("established as" vs "purpose-built as"). Text coherent in all three.

Failed: none observed.

Not run:

  • HIP build (iq_kernels.cu is also compiled for HIP): no ROCm on this machine. Keeping this as a draft until someone can build HIP, per CONTRIBUTING.
  • tools/qwen35/q36_solo_gate.py / q36_cmp_gate.py parity gates against Unsloth's UD files (their downs are Q5_K/Q6_K, so the new case is not reached; a check that the UD path is unchanged is still worth running): the GPU is busy with a long agent run here; I can run them afterwards and post the output.
  • Flash-Next regression run: not run (reasoning above, no measurement).
  • Teacher-forced KL of the Q4_K down kernel against llama.cpp: not run; only the greedy comparison above.

Limits: checked on one model and one GPU. Q4_K downs were only exercised with FF 512 (Qwen3.6-35B geometry).


🔄 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/3699 **Author:** [@xyehya](https://github.com/xyehya) **Created:** 10/22/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `engine-q36-q4k-down` --- ### 📝 Commits (2) - [`b377a35`](https://github.com/Niko1221/Strata/commit/b377a3508b0a236f1349424463897d33414188fb) [Engine] qwen35: accept Q4_K down-projection experts - [`6e1e99b`](https://github.com/Niko1221/Strata/commit/6e1e99ba7875c03594d6643d059783bf374f24ed) [Engine] qwen35: a parity case for the Q4_K down experts at FF 512 ### 📊 Changes **4 files changed** (+14 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+3 -0) 📝 `docs/QWEN36.md` (+1 -0) 📝 `src/kernels/cuda/iq_kernels.cu` (+3 -3) 📝 `src/kernels/native_expert_parity.cpp` (+7 -2) </details> ### 📄 Description **Problem and result:** a Q4_K_M GGUF of a Qwen3.6-35B-A3B-architecture model (qwen35moe) is refused at load by the Qwen3.6 engine path: ``` strata-q36: blk.5.experts are Q4_K/Q4_K, which the native expert kernels do not take (build with -DSTRATA_Q6K_EXPERTS=ON for Q6_K) ``` llama.cpp's Q4_K_M recipe stores the routed experts' down projection as Q4_K in about half the layers (here 20 of 41: `Q4_K/Q4_K/Q4_K` x 20, `Q4_K/Q4_K/Q6_K` x 21). `STRATA_D_FMTS` has Q5_K and Q6_K but no Q4_K, so `native_expert_supported()` returns false. With Q4_K (type 12) added to both `STRATA_D_FMTS` variants the file loads and runs. The gate/up side already takes Q4_K (it is in `STRATA_GU_FMTS`) and the CPU pool goes through ggml's `vec_dot`, so only the GPU down-format list changes. Model: [InternScience/Sage-A1.5](https://huggingface.co/InternScience/Sage-A1.5) (Qwen3.6-35B-A3B fine-tune, Apache-2.0), official Q4_K_M. That file has a second, separate obstacle (its `ssm_alpha` / `ssm_beta` are Q4_K too, which `upload_f32` refuses); I worked around it outside the engine by grafting the original BF16 gates, so it is **not** part of this PR. The resulting file is at https://huggingface.co/ykarout/Strata-Sage-A1.5-GGUF for anyone who wants to reproduce. **Approach:** one entry in the existing format list. Flash-Next is unaffected: its FF 640 is not a multiple of Q4_K's 256-value block, so `native_expert_supported()` still refuses Q4_K downs there, before and after (the existing comment says the same for Q5_K / Q6_K). **Validation** (revision `011c9e6` + this commit, Fedora 44, CUDA 13.4, gcc-15 host compiler, RTX 5080 16 GB sm_120, 64 GB DDR5; engine 0.1.47 build of this tree): Passed: - `cmake --build build --target strata` (CUDA) builds clean. - Load: `--native Sage-A1.5-Q4_K_M-ssmbf16.gguf --max-context 32768 --prefill auto --mtp 2 --pool-workers 16` -> `hybrid experts: 112 of 256 per layer in VRAM (8.16 GiB)`, serves. - Through `serve/server.py`, 3 fresh ~3.6K-token code prompts, 384 tokens each, temp 1.0: pp 4,560 / 4,885 / 5,069 tok/s, tg 133.9 / 153.2 / 154.7 tok/s, every request completed (1,152 tokens). - Greedy text vs llama.cpp (b11798 CUDA build, same GGUF, temp 0, thinking off, 160 tokens, 3 prompts): Fibonacci code prompt identical for the first 380 characters, primes prompt identical, capital-of-Australia prompt diverges after 48 characters at a near-tie word ("established as" vs "purpose-built as"). Text coherent in all three. Failed: none observed. Not run: - HIP build (`iq_kernels.cu` is also compiled for HIP): no ROCm on this machine. **Keeping this as a draft until someone can build HIP**, per CONTRIBUTING. - `tools/qwen35/q36_solo_gate.py` / `q36_cmp_gate.py` parity gates against Unsloth's UD files (their downs are Q5_K/Q6_K, so the new case is not reached; a check that the UD path is unchanged is still worth running): the GPU is busy with a long agent run here; I can run them afterwards and post the output. - Flash-Next regression run: not run (reasoning above, no measurement). - Teacher-forced KL of the Q4_K down kernel against llama.cpp: not run; only the greedy comparison above. **Limits:** checked on one model and one GPU. Q4_K downs were only exercised with FF 512 (Qwen3.6-35B geometry). --- <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#4751
No description provided.