Skip to content

[kernels] fused sigmoid multiplication and optimized gdn update kernel - #740

Merged
HEX1A0A merged 4 commits into
sgl-project:mainfrom
MatsueYu:feature/npu-perf-opt
Sep 17, 2026
Merged

HEX1A0A merged 4 commits into
sgl-project:mainfrom
MatsueYu:feature/npu-perf-opt

Conversation

@MatsueYu

@MatsueYu MatsueYu commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Several optimization on Qwen3.5 decoding, including fused kernels on gdn update and sigmoid mul

Modification

GDN update recurrent decode-optimized

A new kernel optimized only for GDN decoding procedure

  1. grid change from (V-dim tiling num, seq num, value head num) to num_vectorcore in NPU
  2. gates (alpha and beta) only once for every V-dim tiling
  3. every program only process one value head
  4. there is no T loop in decoding procedure
  5. input_guard replaced by light contiguous check

fused sigmoid multiplication

a simple fused kernel of sigmoid and element-wise multiplication

Kernel Test

sigmoid GDN update recurrent decode-optimized kernel

Accuracy

use the following command to test the accuracy in a Ascend NPU environment

pytest -q tests/python/sgl_kernel_npu/test_fused_sigmoid_gating_recurrent_decode.py
bs old vs ref new vs ref new vs old result
1 4.88e-04 4.88e-04 0.00e+00 PASS
8 9.77e-04 9.77e-04 0.00e+00 PASS
32 9.77e-04 9.77e-04 0.00e+00 PASS
128 1.95e-03 1.95e-03 0.00e+00 PASS

Efficiency

bs old (us) new (us) speedup
1 121.76 101.81 1.20x
8 119.34 101.93 1.17x
16 119.02 102.28 1.16x
32 135.99 109.44 1.24x
64 392.95 249.32 1.58x
128 921.77 573.87 1.61x

compared with old kernel (fused_sigmoid_gating_recurrent),Qwen3.6 GDN shapes (H=16, HV=32, K=128, V=128),BF16 input、FP32 state,30 warmup + 100 iterS

fused sigmoid+multiplication

Accuracy

pytest -q tests/python/sgl_kernel_npu/test_fused_sigmoid_mul.py

result:

6 passed, 15 warnings in 42.26s

Efficiency

  • fused_sigmoid_mul element-wise
bs hidden native(us) npu(us) old(us) vs_native vs_old
16 3584 9.89 5.92 7.07 1.67x 1.20x
16 4096 12.97 6.14 7.90 2.11x 1.29x
16 5120 14.69 8.93 8.81 1.64x 0.99x
32 3584 14.74 6.22 8.59 2.37x 1.38x
32 4096 10.69 8.80 10.38 1.21x 1.18x
32 5120 16.57 9.50 11.66 1.74x 1.23x
  • fused_sigmoid_mul_broadcast
bs hidden native(us) npu(us) old(us) vs_native vs_old
16 3584 8.22 4.58 4.34 1.79x 0.95x
16 4096 10.28 5.33 4.59 1.93x 0.86x
16 5120 9.09 4.94 5.05 1.84x 1.02x
32 3584 9.40 5.07 7.22 1.85x 1.42x
32 4096 11.28 7.96 5.59 1.42x 0.70x
32 5120 10.76 5.82 6.36 1.85x 1.09x

Answer Issue:

  1. Radix Cache
    There is no accuracy loss when radix-cache turned on
qwen35_radixcache (1)
  1. MTP
    The following image shows the baseline answer of a problem in AIME26
qwen35_mtp Notice that the current baseline does not provide an acceptable accuracy. It also shows that there is no accuracy difference between the pr and the baseline
        --speculative-algorithm NEXTN \
        --speculative-num-steps 3 \
        --speculative-eagle-topk 1 \
        --speculative-num-draft-tokens 4 \
        --speculative-draft-model-quantization unquant \

Validation

  • Affected-file pre-commit hooks: PASSED.
  • git diff --check: PASSED.
  • Source wheel build for Ascend910B1: passed on the combined kernel snapshot.

@MatsueYu
MatsueYu force-pushed the feature/npu-perf-opt branch 4 times, most recently from 8abe3fe to ae8f38f Compare August 25, 2026 08:05
@MatsueYu
MatsueYu force-pushed the feature/npu-perf-opt branch from ae8f38f to 7cfde05 Compare August 25, 2026 08:07
@MatsueYu
MatsueYu marked this pull request as ready for review August 25, 2026 08:19
sglang-npu-bot
sglang-npu-bot previously approved these changes Sep 16, 2026
@HEX1A0A
HEX1A0A merged commit 36d611b into sgl-project:main Sep 17, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants