mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4845] [Engine] dense qwen35 family: recognition, loader, layer path, and the split-K partials' size #5210
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#5210
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/4845
Author: @FurBlood344324
Created: 10/31/2026
Status: 🔄 Open
Base:
main← Head:dense-qwen35📝 Commits (5)
f886ae0docs: plan for a dense qwen35 (Qwen3.5/3.8-4B) familyca653c2qwen35: the dense family — guard, geometry, layout tables, family switch (M0)fc4a228qwen35 dense: loader, dense layer path, tied head, 4 GB card memory (M1)b952f39qwen35 dense: fix the split-K partials' size, which was a router's width106fd2fqwen35 dense: drop the stale warm-up note and the allocation trace📊 Changes
8 files changed (+475 additions, -51 deletions)
View changed files
➕
docs/DENSE_QWEN35.md(+149 -0)📝
include/strata/artifact/gguf_reader.hpp(+28 -0)📝
include/strata/artifact/model_family.hpp(+9 -0)📝
include/strata/core/family_layout.hpp(+40 -16)📝
src/program/generate.cpp(+6 -4)📝
src/qwen35/q36_engine.cu(+151 -23)📝
src/qwen35/q36ref.cu(+15 -3)📝
tests/core/model_family_test.cpp(+77 -5)📄 Description
Draft, opened so the diff can be read next to #4843 — I will keep it draft until the scope in that issue is
agreed, and I am not asking for review before then.
Problem
GGUFs whose
general.architectureisqwen35with a dense FFN (unsloth/Qwen3.5-4B-GGUF,Qwen3.8-4Bdistills such as
empero-ai/Qwen3.8-4B-Distill-GGUF) are refused at load:Their skeleton is the one the engine already runs for
qwen35moe— same GDN keys (conv_kernel 4,state_size 128,group_count 16,time_step_rank 32,inner_size 4096),full_attention_interval 4,embedding_length 2560,attention.head_count 16 / kv 4,head_dim 256— and the MoE path's shared expertis already a dense MLP. So the GPU work exists; what is missing is recognition and routing the dense MLP into the
path the shared expert takes. No kernel is touched.
What the change does
model_family.hpp,gguf_reader.hpp,family_layout.hpp,generate.cpp):ModelFamily::Qwen35,check_architecture_qwen35(noexpert_*keys,nextn_predict_layersoptional), geometry(
n_ff = feed_forward_length,n_expert = 0,n_ff_shexp = n_ff, no router tables), a dense layout table(
ffn_gate/up/down.weightinstead offfn_*_inp/_shexp/_exps), andTensorWant.optionalso a file withoutoutput.weightstill completes its table.q36_engine.cu):sh_gate/up/down ← ffn_*, no router / expert blobs, and a tied head reusestoken_embd.weightas the head (same[n_embd, n_vocab]shape — no second 497 MiB copy on a small card). Thehost-side f32 path now dequantizes K-quant blocks, because this distill stores
ssm_alpha/ssm_betaas Q4_K.add_rms_postthe dense family computes SwiGLU +sh_downand adds the residual with the nextlayer's norm.
k_moe_outcannot serve it: it always reads its first expert's row.place_experts()returns forn_expert == 0(it divided by the expert count: SIGFPE).sk_partsizing: the split-K partials of the F32 projections are[kSplitK][T][n_out]and were sizedkSplitK * T * (n_expert + 1)— the router's width in a MoE file (257) and1in a dense family, while the GDNalpha / beta projections that share the buffer have
ssm_v_heads(32) rows. Every chunked prompt wrote 32 rowsper row past the end. Sized by
max(n_expert + 1, ssm_v_heads)now; for a MoE file this is the same value asbefore (
max(257, 32) = 257), so the change is a no-op there.auto rule budgets for expert weights that are not there and picked 2048 rows, which OOMed), skips the prompt
GEMM's 45 MB dequant scratch below 640 MB free —
apply()/prep()then read prompts on the native MMVQ in8-column steps — and starts the attention-score buffer at 16 MB. All of it applies only to the dense family; the
MoE path's defaults are untouched.
init(): weights / cache+state+buffers / free VRAM, measured withcudaMemGetInfo. It is what showed that the weights alone are 2.59 GiB of this card's 3.64 GiB.Validation I actually ran
Environment: CachyOS, Linux 7.2.11, driver 615.78.08, CUDA 13.4.92, one GTX 1650 (4096 MiB, sm_75), engine built
from this branch with
-DCMAKE_CUDA_ARCHITECTURES=75. Model:Qwen3.8-4B-Q4_K_M.gguf(2 783 446 304 B).Reference engines:
llama.cppb10387 (llama-server, temp 0) and this tree's ownstrata-q36ref(one token at atime, no chunked path) — both on the same machine.
Passed
model_family_test: 37 checks,ALL PASSED, including the new dense cases (aqwen35file withexpert_*keys is refused, the dense layout table, the optional head).
Greedy parity, ctx 1024, chunk 512, warm-up and CUDA graph capture on:
The(1 token)26142614The capital of France is(5)760 6511 314 9338strata-q36ref760760 6511 314strata-q36ref760Layer-by-layer A/B against
strata-q36ref(residual after every layer, one prompt): max relative difference0.02 over the 32 trunk layers.
Failed, then fixed in this branch — the
sk_partoverflow above. Symptoms were an illegal memory access on a300-token prompt and a warm-up (which is just a 512-row prompt chunk) leaving the next sequence wrong. With the
fix, both are gone and the warm-up and the graph capture are on.
Not run
serve/ the chat template, speculative decoding and the MTP block (loaded, unused:load()ignoreswant_mtpand the MTP block costs 71 MiB),--batch, layer split / multi-GPU.Q4_K_M, and any context beyond 3K cells (this card's ceiling:weights 2.59 GiB of 3.64 GiB usable, 3072 cells fit, 3584 OOM).
Compatibility
Existing families behave as before: the new geometry and layout rows are keyed by the family, and the one shared
line (
sk_part) is unchanged for a MoE file. No kernel, no default and no CLI flag changes.I could not test on a bigger card; a review of the VRAM thresholds for the dense family on 8 GB+ would be
welcome, since the 640 MB prompt-GEMM gate and the 16 MB score buffer were both chosen for a 4 GB card.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.