mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #54] [MERGED] Support pruned expert variants (GSQ-RCO-Coder: 256 of 512 experts) #2432
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#2432
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/54
Author: @pjgmobile
Created: 9/28/2026
Status: ✅ Merged
Merged: 9/28/2026
Merged by: @Niko1221
Base:
main← Head:pruned-geometry-support📝 Commits (8)
80a1f13Merge branch 'pr-7'30acb0cMerge branch 'pr-8'9ef55a4Merge branch 'pr-14'4a4ec34Merge remote-tracking branch 'origin/main'e02b848serve: optional --fit-max-tokens clamps the output cap to remaining context instead of rejecting597d043Merge remote-tracking branch 'origin/main'f07c68cSupport pruned expert variants (GSQ-RCO Coder: 256 of 512 experts)9e8a70dMerge remote-tracking branch 'origin/main' into pruned-geometry-support📊 Changes
8 files changed (+87 additions, -52 deletions)
View changed files
📝
include/strata/artifact/gguf_reader.hpp(+4 -3)📝
include/strata/prefill/kernels.hpp(+1 -1)📝
src/core/layer.cpp(+2 -5)📝
src/kernels/cpu/expert_layout.cpp(+11 -2)📝
src/prefill/kernels.cu(+16 -9)📝
src/prefill/prefill.cpp(+20 -20)📝
src/program/generate.cpp(+23 -6)📝
tools/iq_pack.py(+10 -6)📄 Description
Support pruned expert variants (GSQ-RCO-Coder: 256 of 512 experts)
Motivation
ISTA-DASLab recently published
Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF— the samearchitecture with half the routed experts pruned away per layer (512 → 256,
qwen4exp.expert_count = 256, still 10 active). The engine currently specialises to thecanonical geometry in a number of places, so a pruned model fails at a different spot for
each one: the pack tool divides by a hardcoded 512, the pack loader validates against the
compile-time default, the runtime graph is default-constructed, the prefill kernels and
buffers assume 512, and serve mode additionally demands a canonical profile-filled cache.
This PR threads the model's own declared expert geometry through those paths so pruned
variants boot and run, while canonical behaviour stays byte-identical.
Changes
tools/iq_pack.py—N_EXPERT = 512was hardcoded; the expert count is now derivedfrom the router tensor's shape (
ffn_gate_inp.weight, dim 1) with a uniformity checkacross layers. Blob sizes, offsets and the
native_experts.txtheader all follow it.src/kernels/cpu/expert_layout.cpp—expert_layout_load()trusted the caller'sgeometry (a compile-time default) for the contiguity stride. It now parses
n_expertfrom the pack header (v3 headers already record it) and uses that for boththe stride and the stored layout, so
ArenaExpertSource's geometry check passes.include/strata/artifact/gguf_reader.hpp—Qwen4ExpGuardvalidated every GGUFagainst canonical constants.
experts/experts_usednow default to 0 = presence-only;block count, hidden size and head counts are still hard-validated.
src/program/generate.cpp— the runtimeModelGeometrywas default-constructed;it now reads
qwen4exp.expert_count/expert_used_countfrom the--nativeshard(K too). The MTP drafter deliberately keeps the canonical geometry via a
static const ModelGeometry— the draft layer is the original 512-expert head, and itsizes its own arena from it (speculation works unchanged; acceptance 74-85% measured).
The serve-mode gate also no longer demands the profile-filled graph-hit path: an
on-demand (
--expert-cache auto) cache is a valid serve configuration.src/core/layer.cpp— the native fused router stays canonical-only; non-canonicalgeometry falls back to the generic
router_top10instead of erroring.src/prefill/*— theNE = 512constant is replaced by the geometry's expertcount in buffer sizing, host loops and residency indexing;
route_kernelistemplatized on registers-per-lane (512 → 16, 256 → 8, anything else takes the generic
router_top10);route()gained ann_expertparameter;moe_set_bytes()likewise.Design notes
as fallbacks and for the canonical fast paths.
the shipped MTP draft is still the original head, so it must keep 512x10 sizing.
data/expert-profile.binis 48x512. For a pruned model weremapped the ranked (layer, expert) pairs onto the survivor indices using the release's
published
tensor-allocation/*.rco-allocation.txt(Section 2 records each survivor'soriginal index) — 8000 → 5492 pairs survived remapping, trimmed to fit VRAM. A
make_profile.pyrun against pruned-model routing would do this properly; happy tofollow up with that as a companion tool.
Testing (Ryzen 5 5600X, RTX 3090 24 GB, CUDA 13.1)
n-gram table; symlinked, no re-download).
(4500 slots), MTP draft over the canonical head.
peak 192k tokens, one omp compaction, zero engine errors, decode 27-42 tok/s
(post-0.1.14 AVX2 i-quant kernels: 38.7 cold / 42.6 warm on fixed prompts vs 23.1/24.6
before this upgrade), draft acceptance 65-85%.
spot check), IQ2_XS and vision configs untouched.
Disclosure
This PR was authored by GLM-5.3-Flash (ZCode agent); Pete (pjgmobile) tested it on real
workloads overnight and submitted it.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.