Repository navigation
[Engine] run Mirai's Qwen3.8-Flash-Next-S (QNS trellis) packs - #3384
Draft
alesha-pro wants to merge 1 commit into
Draft
alesha-pro wants to merge 1 commit into
alesha-pro wants to merge 1 commit into
Conversation
Port of Mirai's strata-qns.patch (written for v0.1.43, HF repo trymirai/Qwen3.8-Flash-Next-S-strata-experimental, 2026-10-15) to 0.2.0-beta. The QNS format, the CUDA and AVX2 kernels and the packer support are Mirai's. Changes against the patch, from the merge with 0.1.44-0.2.0: - QNS packs are native_experts.txt v6 (v5 is the Hadamard-folded experts here); a v5 QNS pack from the old patch is refused with a note to repack. - The MTP draft head on another card than the head (0.1.44): the trellis head's rows and row scales are gathered on the head's card and copied over. - The GDN gate projection on the side stream and the QSA query chain on a branch stream take the trellis GEMV for kQnsDenseType weights. - Expert cache sizing uses slot_stride(expert_bytes(l, e), slot_guard). - docs/QNS.md: how to pack and run, measured on RTX 3090. Every other model takes the same path as before: all new code is behind expert_layout().qns() or kQnsDenseType.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and result
Mirai published Qwen3.8-Flash-Next-S, a trellis build of Flash-Next (routed experts 1-5 bits each, 2.4 on average; backbone and head 5 bits), packed for Strata:
trymirai/Qwen3.8-Flash-Next-S-strata-experimental. Until now it runs only on v0.1.43 with Mirai'sstrata-qns.patch. This PR ports that patch to 0.2.0: the S and S-small packs load and run on one card and on a layer split, with MTP and the refusal projection. Every other model takes the same path as before, checked on IQ3_S below.Related discussion
Scope: I am writing to @Niko1221 directly to agree it. The QNS format, the CUDA and AVX2 kernels and the packer support are Mirai's work, from their
strata-qns.patch.Approach
Mirai's code is taken unchanged from their HF repo (2026-10-15, which already has the layer-split rotation fix). What the merge with 0.1.44-0.2.0 needed:
native_experts.txtv5 for Hadamard-folded experts, and the patch used v5 for QNS layers. QNS packs are v6 here. v5 keeps its meaning (hadamard.txt is required for v5 only). A v5 QNS pack from the old patch is refused with "repack with tools/iq_pack.py"; repacking takes ~20 s and gives the same files except the header line. The packer skips the Hadamard spec for QNS.kQnsDenseType: the GDN gate projection (side_proj) and the QSA query chain on a branch stream.slot_stride(expert_bytes(l, e), slot_guard);expert_bytesis the layer's blob for non-QNS packs.docs/QNS.md: how to pack and run.All new code is behind
expert_layout().qns()orkQnsDenseType.Validation
Ubuntu 22.04, CUDA 12.8, 4x RTX 3090 at 300 W, EPYC 7642 (AVX2), 125 GB RAM. Branch head 8e75f6f (engine sources identical to the tested build).
Passed
cmake -DSTRATA_ENABLE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=86 -DSTRATA_BUILD_TESTS=OFF,--target strata. No new warnings in the touched files.tools/iq_pack.pyon S and S-small: v6 packs;qns_offsets.bin,qns_rotation.bin,dense.bin,index.txtand every layer row byte-identical to the v0.1.43 patch's packs./v1/chat/completions, thinking off, 32K context, MTP on, the refusal vector on: a sum, a Python function, a Russian answer, a tool call, a 6,210-token document with a hidden code, a lock-picking question.Failed: none observed.
Not run
.cufiles are compiled for HIP by the existing glob, so this needs a HIP build (or a CUDA-only guard) before review. Help welcome.Limits
docs/QNS.md).