perf: fuse unquantized Qwen3-Next GDN projections - #555
Open
T4t4KAU wants to merge 1 commit into
Open
Conversation
T4t4KAU
force-pushed
the
perf/fuse-gdn-projections
branch
from
September 11, 2026 09:19
a031419 to
c6522ec
Compare
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.
Summary
csrc/models/qwen3_next/qwen3_next_gated_deltanet.*for unquantized GDN, reducing input projection GEMMs from four to two.csrc/layers/linear/fused_linear.*and preserve checkpoint parameter names and TP shard metadata. Refresh parameter aliases after weight pre-transposition using logical checkpoint views incsrc/layers/quantization/none_quantization.cpp.Motivation
Small-batch GDN decode pays launch overhead for separate projections of the same hidden states. Combining their dense weights reduces layer latency by 12.40%–18.86% in the measured BF16 decode cases. Short prefill is 0.77%–0.93% slower; long prefill is approximately unchanged. Detailed measurements and methodology are below. No linked issue.
Type of Change
feat— new feature / new modelfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changesTest Results of Involved Models on Supported Platforms (Please attach screenshots)
QuantScheme::NONE; no quantized performance claim.Tests were run noninteractively and recorded as text/JSON, so terminal screenshots were not captured. Results and selected output are included below. The four-GPU tests used NCCL 2.27.3+cuda12.9. The standalone harnesses and raw logs are retained outside the source tree; they are not part of this PR.
Recorded validation output
Fresh-directory release build (compiler cache enabled):
FP16 boundary result (single device exercising TP=4, rank=3):
{"boundary":true,"dtype":"float16","max_abs":0.0,"max_reference_abs":0.0006895065307617188,"mode":"graph","norm_scale":128.0,"output_ok":true,"packing_control":false,"phase":"decode","pre_transpose":true,"rank":3,"reference_norm":0.016309970758792116,"relative_l2":0.0,"state_relative_l2":{"conv":0.0,"ssm":0.0},"tokens":4,"tolerance":0.003,"tp":4}Qwen3-8B completion token IDs with pre-transpose disabled, then enabled:
{"pre_transpose":false,"token_ids":[151667,198,32313,11,279,1196,4588,752,311,3270,279,3409,330,14990,3263,6771]} {"pre_transpose":true,"token_ids":[151667,198,32313,11,279,1196,4588,752,311,3270,279,3409,330,14990,3263,6771]}The named example/service scripts were not run:
examples/test_infer.py,examples/bench.py,test/bench/test_benchmark.py, andpython/infinilm/server/inference_server.py+scripts/test_perf.py. A full Qwen3-Next checkpoint is unavailable. The standalone GDN comparison and Qwen3-8B LLM API smoke test are the available validation, not substitutes for whole-model accuracy and service coverage.Benchmark / Performance Impact
One NVIDIA RTX 5090, CUDA 12.8, BF16, TP=1, pre-transpose disabled. The standalone C++ harness runs a complete GDN layer with hidden size 2048, 16 key heads, 32 value heads, key/value head dimensions 128, and convolution kernel size 4. Decode inputs are
[1, B, 2048]with B independent one-token requests; prefill inputs are[1, T, 2048]with one request. Baseline GDN source is identical to main at8657a94, with only its namespace renamed so both implementations can run in one process. Weights and inputs use a fixed seed (20260911).Each case warms up both variants for one second, alternates their order over nine rounds, and reports median CUDA-event latency. Repetitions per round are 500/495 for decode, 31 for 128-token prefill, and 5 for 2048-token prefill. Timed calls read fixed initial recurrent state and write separate final slots; this measures layer latency, not end-to-end generation throughput. Separate continuation tests validate carried state. All eight BF16 performance cases have zero output difference against the baseline.
Negative latency change means faster. These are complete-layer measurements, not projection-only or whole-model throughput numbers. The small prefill regression is retained in the results.
Notes for Reviewers
MergedColumnParallelLinearstores Q/K/V/Z in one allocation. The named parameters must continue to alias the active GEMM weight after pre-transposition;NoneQuantization::split_paramsexposes logical[OC, IC]checkpoint views over the packed[IC, OC]storage.c6522ec) directly on current main (8657a94).CI / ChatOps
Local formatting passed with the CI-pinned clang-format 21.1.8. A fresh-directory release build passed on NVIDIA (compiler cache enabled).
For head commit
c6522ec:action_required; no passing result yet.action_required; no passing result yet.cijob is gated onworkflow_dispatchin.github/workflows/ci_test.yml.Maintainer action is needed to allow the PR workflows to run and arrange hardware CI. The corresponding checklist items remain open. No reviewer has been tagged and no ChatOps command has been posted.
Checklist
Title, Branch, and Commits
perf: fuse unquantized Qwen3-Next GDN projections.<type>/xxx-yyyy-zzzz:perf/fuse-gdn-projections.main; the branch is based directly on currentmain.fixup!/squash!/wipcommits remain.Scope and Design
General Code Hygiene (applies to all languages)
C++ Specific (if C++ files changed)
.clang-format.new/deleteadded.scripts/format.py --ref origin/main --check.csrc/models/llama_legacy/.Python Specific (if Python files changed)
python/infinilm/auto_config.pychecks do not apply.Testing
examples/test_infer.py), or specify the reason for skipping — skipped; full Qwen3-Next checkpoint unavailable. Qwen3-8B LLM API smoke passed.examples/bench.py), or specify the reason for skipping — skipped for the same checkpoint limitation; layer performance is reported above.test/bench/test_benchmark.py), or specify the reason for skipping — skipped for the same checkpoint limitation.python/infinilm/server/inference_server.py+scripts/test_perf.py), or specify the reason for skipping — skipped for the same checkpoint limitation.Build, CI, and Tooling
/retestrequested — pending.Documentation
Security and Safety