[VLM][LLM] Optimize fused_moe triton kernel tma#18782
Merged
BBuf merged 1 commit intosgl-project:mainfrom Feb 14, 2026
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
8b58110 to
e6b489e
Compare
Collaborator
Author
|
/tag-and-rerun-ci |
BBuf
reviewed
Feb 13, 2026
BBuf
reviewed
Feb 13, 2026
e6b489e to
4cdc472
Compare
Collaborator
Author
|
/rerun-failed-ci |
7 similar comments
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
|
/rerun-failed-ci |
magicYang1573
pushed a commit
to magicYang1573/sglang
that referenced
this pull request
Mar 9, 2026
Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
Wangzheee
pushed a commit
to Wangzheee/sglang
that referenced
this pull request
Mar 21, 2026
Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
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.
Motivation
During profiling Qwen3-VL-30B-A3B, we found that fused_moe had significant GPU bubbles in prefill phase. One reason is CUDA Graph is not enabled by default, many small kernels launch introduces overhead. Some other reason can be scheduler's CPU participates some small ops' calculation, which makes kernel launch delayed. This PR focus on fused_moe optimzation.
Summary
This PR reduces host-side overhead in the Triton TMA path for fused_moe by:
Key improvement details
Set triton.set_allocator(...) once (process-wide)
Previously, triton.set_allocator(alloc_fn) was executed on every invoke_fused_moe_kernel() call whenever a_use_tma or b_use_tma was enabled.
This PR introduces a set-once guard so the allocator is configured only once per process (global within the process), reducing repeated Python overhead on the hot path.
Note: this only affects the TMA path; non-TMA execution is unchanged.
Cache b_desc (weight TensorDescriptor) with a bounded LRU
B is a persistent weight tensor. Previously we created a new TensorDescriptor(B, ...) every invocation when b_use_tma=True.
This PR adds an LRU cache keyed by (weight storage identity / layout, tile shape), i.e. (B.data_ptr, B.shape, B.stride, B.dtype, BLOCK_SIZE_N, BLOCK_SIZE_K) to reuse descriptors across calls.
The cache is bounded by SGLANG_TMA_BDESC_CACHE_MAX (default: 64), so it does not grow unbounded. Setting it to 0 disables caching.
Design considerations
We intentionally do not cache
a_desc:A is activation and typically changes per call (shape/stride/layout), so cache hit rate is low.
Caching activation descriptors can also inadvertently extend the lifetime of temporary tensors.
Locks are not used on the cache to avoid overhead on the hot path. Under Python’s GIL this is safe for correctness; in the worst case under concurrency we may create duplicate descriptors, but results remain correct.
Results
No quality regression observed (gsm8k unchanged).
TTFT improvement: ~5–10% in our serving benchmark.
Server:
Client:
There are still some other parts needs to be emphasized such as jit kernel will always be compiled on each layer. We will keep on optimizing the VL MoE model's performance.
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci