mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #238] [CLOSED] Let the native router and the expert geometry take the count from the file #2520
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#2520
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/238
Author: @lukmanfauzie
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:pr-coder-native-router-0128📝 Commits (1)
74a8f88Let the native router and the expert geometry take the count from the file📊 Changes
9 files changed (+257 additions, -22 deletions)
View changed files
📝
include/strata/artifact/gguf_reader.hpp(+35 -0)📝
include/strata/kernels/native_router.hpp(+8 -3)📝
include/strata/prefill/kernels.hpp(+2 -1)📝
src/core/layer.cpp(+3 -3)📝
src/core/mtp.cpp(+4 -1)📝
src/kernels/cuda/native_router.cu(+23 -12)📝
src/program/generate.cpp(+40 -1)📝
tools/iq_pack.py(+28 -1)➕
tools/make_expert_profile.py(+114 -0)📄 Description
The Coder router change part of #151, @Niko1221 asked to split out, onto v0.1.29 (
d6708a4).This is the one that needs its own byte gate on the Coder.
The Coder release is Qwen3.8-Flash-Next with half of its routed experts pruned away (256 of 512 per layer, ISTA-DASLab's RCO) and every other geometry number identical, so a hard-coded 512 is not a tuning assumption but a mis-indexing bug:
ffn_gate_inp.weightis[n_embd, 256], and reading 512 logits per token reads the NEXT token's logits as experts 256..511 - finite, correctly sized and wrong.native_router_top10takesn_expert(32..512 in multiples of 32, checked) and the device kernel derivesper_lane = n_expert / 32, filling the unused slots with -INFINITY so the softmax max, sum and argmax ignore them exactly as if the tensor were shorter. The unused slots must NOT enter the sum: adding -INFINITY to it makes the reciprocal -0 and every probability a NaN, which the NaN guard then replaces with -FLT_MAX - a router that picks arbitrary experts. One kernel therefore serves both counts with no second code path.n_expertinstead of 512, so the pruned pack's verify window is right too.read_expert_countreads the count off the GGUF itself (the router's last axis, cross-checked againstqwen4exp.expert_count) and the loader refuses a pack and a model file that disagree, rather than routing a 256-expert pack through a 512-expert geometry.ffn_gate_inp.weightshape it reads is the drafter's.tools/iq_pack.pyderives the count from the file's tensors so a pruned model packs correctly, andtools/make_expert_profile.pybuilds a profile for it (--want-expert, because a routing trace only bounds the count).--dump-routingnow reports the records it wrote rather than the number of dispatches: it wascalls, so a trace of zero bytes - a profile that reads as empty instead of broken - reported as a full one.Only the single-token router contract is widened. The verify window still takes the 512-expert kernel (
verify.cppguardsnative_router_enabled() && NE == 512 && K == 10, andnative_router_top10_multiis[n,512]internally), and the prompt path needs neither -prefill.cppalready callsroute(...)with the geometry's count. Widening the multi kernel is a separate change with its own gate, so it is not smuggled in here.expert_layout.cppis left alone: it already reads the pruned count from a v3 pack's header, and the router takes its count fromModelGeometry, not from that field, so the stricter parse adds risk without changing what runs.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.