Repository navigation
perf(musa): fuse DeepSeek-V4 shared-expert SwiGLU FP8 down-projection - #156
Merged
Joey-gvwal merged 2 commits intoAug 3, 2026
Merged
Joey-gvwal merged 2 commits into
Joey-gvwal merged 2 commits into
Conversation
Joey-gvwal
force-pushed
the
perf/musa3508-dsv4-tps60-c13c3a38
branch
from
July 31, 2026 08:20
699a7b2 to
9450c73
Compare
Collaborator
Author
|
I will clean up the DeepSeek-V4 related environment variables in this PR and submit the corresponding commit later. |
Collaborator
Author
Fuse the shared-expert SwiGLU clamp, FP8 quantization, and down-projection into the existing DeepGEMM path for the supported block-FP8 layout. Keep CUDA-compatible spellings in the native source and let torchada perform the CUDA-to-MUSA mapping. The mapped source was independently compiled and linked with torchada 0.1.77 on an MTT S5000.
Joey-gvwal
force-pushed
the
perf/musa3508-dsv4-tps60-c13c3a38
branch
from
August 3, 2026 07:53
4c376bc to
b48d53e
Compare
This was referenced Aug 3, 2026
Joey-gvwal
added a commit
that referenced
this pull request
Aug 4, 2026
…#156) * perf(musa): fuse DeepSeek-V4 shared SwiGLU FP8 down-proj Fuse the shared-expert SwiGLU clamp, FP8 quantization, and down-projection into the existing DeepGEMM path for the supported block-FP8 layout. Keep CUDA-compatible spellings in the native source and let torchada perform the CUDA-to-MUSA mapping. The mapped source was independently compiled and linked with torchada 0.1.77 on an MTT S5000. * perf(musa): make DeepSeek-V4 optimized paths default (cherry picked from commit a0e139f)
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
This PR adds a MUSA fast path for the DeepSeek-V4 dense/shared-expert MLP. It
fuses the clamp-aware SwiGLU activation and per-token group-128 FP8
quantization that feed the existing DeepGEMM down-projection.
The change removes the materialized BF16 activation and replaces the previous
sequence of clamp, sigmoid, multiply, copy, absmax, scale, and FP8 conversion
kernels with one native MUSA kernel. The generated FP8 activations and FP32
scales are then consumed by the existing
fp8_gemm_ntdown-projection, and theexisting tensor-parallel all-reduce semantics are preserved.
No environment-variable gate is added. Unsupported shapes or configurations
return to the original vLLM activation plus linear path.
Motivation
When the DeepSeek-V4 dense/shared-expert MLP path runs, it executes:
For BS1 decode, the activation and quantization stages are small, launch-bound
kernels repeated once per layer. A four-step profile attributed roughly 5 ms
to the related
ClipOp,SigmoidOp,MulOp, quantization, and activation-copyfamily. The intermediate BF16 activation was written to global memory and
immediately read back by the quantizer.
The new path executes:
This reduces kernel-launch and intermediate-memory traffic without changing
the DeepGEMM implementation or the model's tensor-parallel contract.
Implementation
silu_and_mul_clamp_per_token_group_fp8_quant, a clamp-aware variant ofthe native MUSA activation/quantization kernel.
before group absmax calculation.
musa_silu_clamp_deepgemm_fp8_op, which invokes the fused quantizationkernel and then the existing
fp8_gemm_ntprovider.RowParallelLinear.forward_swiglu_clamp()OOT hook and preservereduce_resultsthroughtensor_model_parallel_all_reduce().DeepseekV4MLP.forward()to try the optional hook before materializingthe ordinary activation.
inverse-scale selection, fallback behavior, model-hook ordering, and TP
reduction.
The fast path is selected only when all of the following hold:
gate_upinput;(128, 128)and activation group size is 128;swiglu_limit == 10.0;All other configurations use the unchanged fallback path.
Single-batch service command
Benchmark command
Performance
Controlled BS1 A/B
The control and candidate were built from the same
upstream/v0.24.0-dev@11825fc1source and measured with the same TP8,capture-
[1], no-MTP service configuration.Latest-upstream integration confirmation
After rebasing the optimization as
699a7b28ontoupstream/v0.24.0-dev@c13c3a38, the same BS1 direct-path command produced:The latest-upstream rows are integration/no-regression evidence. The claimed
optimization gain is taken from the controlled A/B table above.