mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4843] [Engine] support the dense qwen35 family (Qwen3.5-4B, Qwen3.8-4B distills) #2225
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#2225
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?
Originally created by @FurBlood344324 on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4843
What I want to do
Run and serve GGUFs that carry
general.architecture = qwen35but a dense FFN —unsloth/Qwen3.5-4B-GGUFand the
Qwen3.8-4Bdistills (empero-ai/Qwen3.8-4B-Distill-GGUF) — on the q36 path. Today the engine refusesthem at load:
architecture is 'qwen35', this engine requires 'qwen4exp'(0.1.55, upstreamc62d5e3a).The 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. Only the FFN differs:qwen35moe(runs today)qwen35denseffn_gate/up/down.weight, 9216ffn_gate_inp.weightblk.<n>.nextn.*nextn_predict_layers = 1)output.weighttoken_embd.weightSo the GPU work exists already: the MoE path's shared expert is a dense MLP and the kernels are runtime-shaped.
I am asking for scope before opening the PR, as CONTRIBUTING asks.
What I did today, on a fork
FurBlood344324/strata-dense, branchdense-qwen35(private copy of this tree, upstream stays its remote).Diff against
main: 8 files, +465/−52, no kernel changes.ModelFamily::Qwen35,check_architecture_qwen35, geometry (n_ff = feed_forward_length,n_expert = 0,n_ff_shexp = n_ff), a dense layout table,TensorWant.optionalfor the tied head, the family switch.token_embd.weightas the head (same[n_embd, n_vocab]; no second 497 MiB copy), and the host-side f32 pathdequantizes K-quant blocks (this distill stores
ssm_alpha/ssm_betaas Q4_K).layer(): a dense branch afteradd_rms_post(SwiGLU + down, then the residual and the next layer's norm);k_moe_outcannot be reused, it always reads its first expert's row.place_experts()returns forn_expert == 0(it divided by the expert count: SIGFPE).Measurements (GTX 1650 4 GB, CUDA 13.4, sm_75, ctx 1024, chunk 512, warm-up and capture on)
Greedy,
Qwen3.8-4B-Q4_K_M.gguf,llama.cppb10387 as the reference engine (llama-server, temp 0):The26142614The capital of France is760 6511 314 9338strata-q36ref):760760 6511 314strata-q36ref:760Prefill 700 tokens in 7.2 s (~97 tok/s, the native MMVQ — this card has no room for the prompt GEMM's scratch),
decode 37.5 tok/s. VRAM, measured with
cudaMemGetInfo: weights 2.59 GiB of the card's 3.64 GiB usable (32 trunklayers 2.03,
token_embd/tied head 0.49, MTP block 71 MiB), state + buffers 0.69 GiB at ctx 3072, so the practicalcontext ceiling on a 4 GB card is ~3K (2560 with room to spare, 3584 OOM).
One sizing bug that this family exposes, worth fixing whatever you decide about the port
init()sizes the F32 projections' split-K partials asThe buffer is laid out
[kSplitK][T][n_out].n_expert + 1is the router's width (257 for a MoE file) and ithappens to be ≥ the other user of this buffer, the GDN alpha / beta projections, which have
ssm_v_heads(32)rows. A dense family has no router, so
n_expert + 1 = 1and every chunked prompt writes 32 rows per row pastthe end, over whatever the allocator placed next. Its symptoms looked like two unrelated bugs: a warm-up (which is
just a 512-row prompt chunk) left the next sequence wrong, and a 300-token prompt raised an illegal memory access.
max(n_expert + 1, ssm_v_heads)fixed both.Note on reproduction status: on the current tree this is unreachable, because the family is refused before the
engine starts. I hit it through my branch, so I state it as a latent sizing bug this family exposes, not as an
existing crash — the MoE path is insulated only by the router being wider than the GDN projections.
Scope I would like agreed
model_family_testgrows to 37 checks, all pass);
sk_partsizing line above.Not in that PR unless you want them: MTP drafting for a dense
nextnblock (it is loaded but unused; acommunity distill's block may be a donor head),
serveplumbing (the chat template should come fromtokenizer.chat_templatein the file rather than a hardcoded jinja),setup.py's family entry, and honouringwant_mtpinload()(today the MTP block is loaded even when drafting is off — 71 MiB on a 4 GB card).What I did not test
Only CUDA on sm_75 (a 4 GB GTX 1650). No ROCm, Metal, SYCL or Blackwell run, no other quantization of the same
family, no multi-GPU / layer split, and no long-context run past 3K cells. The spec-decode and
servepaths werenot exercised at all.
Reproduction status: measured locally. Happy to open the PR with the exact commands and logs if the scope is
acceptable.