repo
stringclasses
3 values
commit
stringlengths
40
40
date
stringdate
2023-04-02 02:30:17-0500
2026-10-18 07:42:16-0500
pr_number
int64
20
61.9k
⌀
pr_url
stringlengths
44
53
⌀
title
stringlengths
8
263
message
stringlengths
8
8k
path
stringlengths
10
155
language
stringclasses
4 values
license
stringclasses
4 values
before_code
stringlengths
160
118k
after_code
stringlengths
340
120k
diff
stringlengths
149
51k
lines_added
int64
0
729
lines_removed
int64
0
488
files_in_commit
int64
1
10
models_mentioned
listlengths
0
4
hardware_mentioned
listlengths
0
16
speedup_claims
listlengths
0
10
prompt
stringlengths
569
119k
pr_body
stringlengths
0
24k
gains
stringlengths
2
197k
kernel_speedup
float64
0.78
150
⌀
e2e_speedup
float64
0.76
136
⌀
sglang
daae3acb3642f99f8ef0393c74188eea6d31b60d
2026-08-12T16:27:44+08:00
34,507
https://github.com/sgl-project/sglang/pull/34507
[Diffusion][Z-Image] Tune native QK RMSNorm launch for SM103 (#34507)
[Diffusion][Z-Image] Tune native QK RMSNorm launch for SM103 (#34507)
python/sglang/kernels/ops/diffusion/triton/zimage_native_norm.py
triton
Apache-2.0
# SPDX-License-Identifier: Apache-2.0 """Z-Image-specific bit-exact per-head RMSNorm kernel.""" from __future__ import annotations import torch import triton # type: ignore import triton.language as tl # type: ignore @triton.jit def _qk_rmsnorm_native_kernel( y_ptr, x_ptr, weight_ptr, token_stride...
# SPDX-License-Identifier: Apache-2.0 """Z-Image-specific bit-exact per-head RMSNorm kernel.""" from __future__ import annotations import torch import triton # type: ignore import triton.language as tl # type: ignore from sglang.kernels.jit.utils import get_jit_cuda_arch @triton.jit def _qk_rmsnorm_native_kernel...
--- python/sglang/kernels/ops/diffusion/triton/zimage_native_norm.py +++ python/sglang/kernels/ops/diffusion/triton/zimage_native_norm.py @@ -6,6 +6,8 @@ import torch import triton # type: ignore import triton.language as tl # type: ignore + +from sglang.kernels.jit.utils import get_jit_cuda_arch @triton.jit ...
10
2
1
[]
[ "SM103" ]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/diffusion/triton/zimage_native_norm.py). Goal: [Diffusion][Z-Image] Tune native QK RMSNorm launch for SM103 Target hardware: SM103 Target models: unspecified Current file: ```python # SPDX-License-Identifier: Apache-2.0 """Z-Image-specific bit-ex...
## Motivation The bit-exact native Z-Image Q/K RMSNorm kernel used a single launch configuration on every GPU. At the production Z-Image shape, B300 is launch-bound with `rows_per_prog=8, num_warps=8`. ## Modifications - Use `rows_per_prog=16, num_warps=4` on SM103. - Preserve `rows_per_prog=8, num_warps=8` on every...
[{"scope": "kernel", "hardware": "B300", "model": null, "shape": "N=1,K=4096", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 24.58, "optimized": 14.33, "stated_speedup": 1.72, "speedup": 1.7153}, {"scope": "kernel", "hardware": "B300", "model": null, "shape": "N=1,K=4096", "...
2.0446
null
sglang
45f706333536466479d8977be14768abda11e438
2026-08-12T16:24:18+08:00
34,503
https://github.com/sgl-project/sglang/pull/34503
[Diffusion] Tune QK head LayerNorm for SM103 (#34503)
[Diffusion] Tune QK head LayerNorm for SM103 (#34503)
python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py
triton
Apache-2.0
# SPDX-License-Identifier: Apache-2.0 """Fused LayerNorm + adaLN modulate Triton kernels for bf16 activations. Two fusions, each replacing an eager multi-kernel chain with a single launch while reproducing the eager results bit for bit (``torch.equal``), so callers need no quality gate: - ``fused_layernorm_modulate``...
# SPDX-License-Identifier: Apache-2.0 """Fused LayerNorm + adaLN modulate Triton kernels for bf16 activations. Two fusions, each replacing an eager multi-kernel chain with a single launch while reproducing the eager results bit for bit (``torch.equal``), so callers need no quality gate: - ``fused_layernorm_modulate``...
--- python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py +++ python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py @@ -341,9 +341,13 @@ return t.is_cuda and t.dtype is torch.bfloat16 -def _is_sm120_or_newer() -> bool: +def _qk_head_launch_config() -> tuple[int, int]: arch = get_jit_...
11
9
1
[]
[ "SM103" ]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py). Goal: [Diffusion] Tune QK head LayerNorm for SM103 Target hardware: SM103 Target models: unspecified Current file: ```python # SPDX-License-Identifier: Apache-2.0 """Fused LayerNorm + adaLN modulate Triton...
## Motivation PR #34349 tuned the exact Q/K head LayerNorm launch for SM120 while preserving the H100/H200 launch. B300 (SM103) also suffers from register pressure with the SM90 `ROWS=64, num_warps=2` configuration, but its best launch is different from SM120. ## Modifications - Use `ROWS=16, num_warps=1` on SM103. ...
[{"scope": "kernel", "hardware": "B300", "model": null, "shape": "N=4360,K=32", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 44.97, "optimized": 30.78, "stated_speedup": 1.46, "speedup": 1.461}]
1.461
null
sglang
3f9d184833a4626e06d72bf099cc00a8c4258886
2026-08-12T10:41:54+08:00
34,349
https://github.com/sgl-project/sglang/pull/34349
[Diffusion] Tune QK head LayerNorm for SM120 (#34349)
[Diffusion] Tune QK head LayerNorm for SM120 (#34349)
python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py
triton
Apache-2.0
# SPDX-License-Identifier: Apache-2.0 """Fused LayerNorm + adaLN modulate Triton kernels for bf16 activations. Two fusions, each replacing an eager multi-kernel chain with a single launch while reproducing the eager results bit for bit (``torch.equal``), so callers need no quality gate: - ``fused_layernorm_modulate``...
# SPDX-License-Identifier: Apache-2.0 """Fused LayerNorm + adaLN modulate Triton kernels for bf16 activations. Two fusions, each replacing an eager multi-kernel chain with a single launch while reproducing the eager results bit for bit (``torch.equal``), so callers need no quality gate: - ``fused_layernorm_modulate``...
--- python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py +++ python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py @@ -46,6 +46,7 @@ import triton # type: ignore import triton.language as tl # type: ignore +from sglang.kernels.jit.utils import get_jit_cuda_arch from sglang.kernels.ops.diff...
13
2
1
[]
[ "SM120" ]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/diffusion/triton/layernorm_modulate.py). Goal: [Diffusion] Tune QK head LayerNorm for SM120 Target hardware: SM120 Target models: unspecified Current file: ```python # SPDX-License-Identifier: Apache-2.0 """Fused LayerNorm + adaLN modulate Triton...
## Motivation The exact Q/K head LayerNorm launch was tuned for H200 with 64 rows per Triton program. On RTX 5090, this configuration uses 142 registers per thread and limits the kernel to 25% theoretical / 23.11% achieved occupancy, making it materially slower than a smaller SM120 row group. ## Modifications - Sele...
[{"scope": "kernel", "hardware": "RTX 5090", "model": null, "shape": "1, 4360, 32, 128", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 93.66, "optimized": 83.42, "stated_speedup": null, "speedup": 1.1228}, {"scope": "kernel", "hardware": "H200", "model": null, "shape": "1, 4...
1.0006
null
sglang
ca0f8a0f4ced5fc107f27a3be386d12bc7850711
2026-08-11T05:30:15+08:00
33,484
https://github.com/sgl-project/sglang/pull/33484
perf(hisparse): fuse the DSv4 value and scale swap-in copy on ROCm (#33484)
perf(hisparse): fuse the DSv4 value and scale swap-in copy on ROCm (#33484)
python/sglang/kernels/jit/csrc/hisparse.cuh
cuda
Apache-2.0
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/deepseek_v4/kvcacheio.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/container/tensor.h> #include <stdexcept> #include <stdint.h> #include <string> namespace sglang { #ifdef USE_ROCM constexpr int ...
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/deepseek_v4/kvcacheio.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/container/tensor.h> #include <stdexcept> #include <stdint.h> #include <string> namespace sglang { #ifdef USE_ROCM constexpr int ...
--- python/sglang/kernels/jit/csrc/hisparse.cuh +++ python/sglang/kernels/jit/csrc/hisparse.cuh @@ -84,6 +84,56 @@ const int64_t tail_start = word_count * static_cast<int64_t>(sizeof(uint64_t)); for (int64_t i = tail_start + lane_id; i < item_size_bytes; i += WARP_SIZE) { dst[i] = src[i]; + } +} + +// Copie...
53
4
1
[ "deepseek" ]
[ "ROCM" ]
[]
Optimize this cuda kernel file from sglang (python/sglang/kernels/jit/csrc/hisparse.cuh). Goal: perf(hisparse): fuse the DSv4 value and scale swap-in copy on ROCm Target hardware: ROCM Target models: deepseek Current file: ```cuda #include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/util...
## Motivation A DeepSeek-V4 C4 token is 584 bytes, but it is **not one contiguous range**. A page row holds 64 values of 576B followed by 64 scales of 8B: ``` /// Paged C4 cache layout: /// VALUE 0, VALUE 1, ..., VALUE 63, /// SCALE 0, SCALE 1, ..., SCALE 63, /// [Padding to align to 576 bytes] ``` So the ROCm swap-...
[{"scope": "kernel", "hardware": "MI355X", "model": "DSv4", "shape": "miss_rate=0.2,hot_buffer_size=4096,top_k=2048", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 102.4, "optimized": 87.8, "stated_speedup": null, "speedup": 1.1663}, {"scope": "kernel", "hardware": "MI355X",...
1.1299
null
sglang
1a8e4876b6ddccc5f2712efdca7f87fdc5514c7b
2026-08-11T04:27:15+08:00
33,085
https://github.com/sgl-project/sglang/pull/33085
perf(hisparse): 128-bit non-temporal swap-in copy on ROCm (#33085)
perf(hisparse): 128-bit non-temporal swap-in copy on ROCm (#33085)
python/sglang/kernels/jit/csrc/hisparse.cuh
cuda
Apache-2.0
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/deepseek_v4/kvcacheio.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/container/tensor.h> #include <stdexcept> #include <stdint.h> #include <string> namespace sglang { #ifdef USE_ROCM constexpr int ...
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/deepseek_v4/kvcacheio.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/container/tensor.h> #include <stdexcept> #include <stdint.h> #include <string> namespace sglang { #ifdef USE_ROCM constexpr int ...
--- python/sglang/kernels/jit/csrc/hisparse.cuh +++ python/sglang/kernels/jit/csrc/hisparse.cuh @@ -32,15 +32,52 @@ } #ifdef USE_ROCM +// 128-bit vector type used by the wide copy path below. +using TransferVec4 = __attribute__((__vector_size__(4 * sizeof(uint32_t)))) uint32_t; + __device__ __forceinline__ void tr...
38
1
1
[]
[ "ROCM" ]
[]
Optimize this cuda kernel file from sglang (python/sglang/kernels/jit/csrc/hisparse.cuh). Goal: perf(hisparse): 128-bit non-temporal swap-in copy on ROCm Target hardware: ROCM Target models: unspecified Current file: ```cuda #include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh>...
## Motivation `transfer_item_warp` exists **twice** in the tree: | file | used by | ROCm today | |---|---|---| | `python/sglang/kernels/aot/csrc/kvcacheio/transfer.cu` | HiCache L2→L1 gather (prefill/TTFT) | being widened in #30024 | | `python/sglang/kernels/jit/csrc/hisparse.cuh` | **HiSparse swap-in miss copy (deco...
[{"scope": "kernel", "hardware": "MI355X", "model": "DeepSeek-V4", "shape": "ITEM_SIZE_BYTES=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 105.9, "optimized": 84.8, "stated_speedup": null, "speedup": 1.2488}, {"scope": "kernel", "hardware": "MI355X", "model": "DeepSee...
1.0034
null
sglang
18e6c61c21ad39725522c008190d2b540dd6228d
2026-08-06T14:46:10-07:00
29,677
https://github.com/sgl-project/sglang/pull/29677
[AMD] perf: compact Triton extend-attention for ragged prefill (AMD/HIP-only) (#29677)
[AMD] perf: compact Triton extend-attention for ragged prefill (AMD/HIP-only) (#29677)
python/sglang/kernels/ops/attention/extend_attention.py
triton
Apache-2.0
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
--- python/sglang/kernels/ops/attention/extend_attention.py +++ python/sglang/kernels/ops/attention/extend_attention.py @@ -25,6 +25,7 @@ context_attention_fwd, ) from sglang.kernels.ops.attention.score_mod import unpack_aux_tensors +from sglang.srt.environ import envs from sglang.srt.utils import is_cuda, is_g...
100
4
3
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/extend_attention.py). Goal: [AMD] perf: compact Triton extend-attention for ragged prefill (AMD/HIP-only) Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under...
## Motivation This PR improves Triton extend-attention performance for ragged mixed-prefill batches by adding an optional **compact query-tile launch grid**. The legacy grid is rectangular and sized by `max_len_extend`: ```python grid = (batch_size, head_num, ceil(max_len_extend / BLOCK_M)) ``` In a mixed batch, ev...
[{"scope": "e2e", "hardware": "MI355X", "model": "Qwen/Qwen2.5-7B-Instruct", "shape": null, "batch_size": 64, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 14581, "optimized": 49877, "stated_speedup": null, "speedup": 3.4207}, {"scope": "e2e", "hardware": "MI355X", "model": "Qwen/Qwen2....
6.4
2.0246
sglang
18e6c61c21ad39725522c008190d2b540dd6228d
2026-08-06T14:46:10-07:00
29,677
https://github.com/sgl-project/sglang/pull/29677
[AMD] perf: compact Triton extend-attention for ragged prefill (AMD/HIP-only) (#29677)
[AMD] perf: compact Triton extend-attention for ragged prefill (AMD/HIP-only) (#29677)
python/sglang/kernels/ops/attention/verify_splitkv.py
triton
Apache-2.0
"""Split-KV (flash-decode) attention for EAGLE speculative *verify*. Only valid when speculative ``topk == 1`` (the EAGLE tree reduces to a pure causal chain); the caller gates on that. ``topk > 1`` trees fall back to ``extend_attention_fwd``. On the Triton backend, EAGLE target-verify runs through the prefill ``exte...
"""Split-KV (flash-decode) attention for EAGLE speculative *verify*. Only valid when speculative ``topk == 1`` (the EAGLE tree reduces to a pure causal chain); the caller gates on that. ``topk > 1`` trees fall back to ``extend_attention_fwd``. On the Triton backend, EAGLE target-verify runs through the prefill ``exte...
--- python/sglang/kernels/ops/attention/verify_splitkv.py +++ python/sglang/kernels/ops/attention/verify_splitkv.py @@ -707,6 +707,12 @@ return False if v_extend.shape[2] != v_buffer.shape[2]: return False + # MLA (head_dim != v_head_dim, e.g. DeepSeek 576 vs 512) uses a shared + # latent K...
6
0
3
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/verify_splitkv.py). Goal: [AMD] perf: compact Triton extend-attention for ragged prefill (AMD/HIP-only) Target hardware: unspecified Target models: unspecified Current file: ```python """Split-KV (flash-decode) attention for EAGLE specu...
## Motivation This PR improves Triton extend-attention performance for ragged mixed-prefill batches by adding an optional **compact query-tile launch grid**. The legacy grid is rectangular and sized by `max_len_extend`: ```python grid = (batch_size, head_num, ceil(max_len_extend / BLOCK_M)) ``` In a mixed batch, ev...
[{"scope": "e2e", "hardware": "MI355X", "model": "Qwen/Qwen2.5-7B-Instruct", "shape": null, "batch_size": 64, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 14581, "optimized": 49877, "stated_speedup": null, "speedup": 3.4207}, {"scope": "e2e", "hardware": "MI355X", "model": "Qwen/Qwen2....
6.4
2.0246
sglang
afeaeccfa2f1f2fe9e245fabef2b2e58c34d13f3
2026-07-31T12:09:44+08:00
32,483
https://github.com/sgl-project/sglang/pull/32483
perf(hisparse): eliminate redundant swap output fill (#32483)
perf(hisparse): eliminate redundant swap output fill (#32483) Co-authored-by: Xiaoyu Zhang <1182563586@qq.com>
python/sglang/kernels/jit/csrc/hisparse.cuh
cuda
Apache-2.0
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/deepseek_v4/kvcacheio.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/container/tensor.h> #include <stdexcept> #include <stdint.h> #include <string> namespace { #ifdef USE_ROCM constexpr int WARP_SI...
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/deepseek_v4/kvcacheio.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/container/tensor.h> #include <stdexcept> #include <stdint.h> #include <string> namespace { #ifdef USE_ROCM constexpr int WARP_SI...
--- python/sglang/kernels/jit/csrc/hisparse.cuh +++ python/sglang/kernels/jit/csrc/hisparse.cuh @@ -217,10 +217,18 @@ constexpr int NUM_BUFFER_CHUNKS = (HOT_BUFFER_SIZE + WARP_SIZE - 1) / WARP_SIZE; const int bid = blockIdx.x; - // Early exit for padded blocks (CUDA graph pads batch to a captured size) - if (...
20
9
1
[]
[]
[]
Optimize this cuda kernel file from sglang (python/sglang/kernels/jit/csrc/hisparse.cuh). Goal: perf(hisparse): eliminate redundant swap output fill Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/utils.cu...
## Motivation `HiSparseCoordinator.swap_in_selected_pages()` currently clears `top_k_device_locs` with `fill_(-1)` before launching `load_cache_to_device_buffer_mla`. The fill is needed only because the short-sequence path and CUDA Graph padded rows did not overwrite every output entry. It adds one GPU kernel launch ...
[{"scope": "kernel", "hardware": "NVIDIA H20", "model": null, "shape": "top_k=2048, hot buffer=4096/8192", "batch_size": 1, "metric": "GPU-time improvement", "unit": "%", "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.4125, "speedup": 1.4125}, {"scope": "kernel", "hardware": "NVIDIA ...
1.0755
null
sglang
5558dbad003768d01e1c9b8f3e13245bf145d8a6
2026-07-28T19:45:46+08:00
31,931
https://github.com/sgl-project/sglang/pull/31931
[NPU] Optimize DeepSeek-V4 performance (#31931)
[NPU] Optimize DeepSeek-V4 performance (#31931)
python/sglang/kernels/ops/attention/deepseek_v4_rope.py
triton
Apache-2.0
import logging import math from functools import lru_cache from typing import Optional import torch import triton import triton.language as tl logger = logging.getLogger(__name__) # This module is imported during model-registry discovery. Keep it free of # TileLang imports so discovery does not load TileLang's nativ...
import logging import math from functools import lru_cache from typing import Optional import torch import triton import triton.language as tl logger = logging.getLogger(__name__) # This module is imported during model-registry discovery. Keep it free of # TileLang imports so discovery does not load TileLang's nativ...
--- python/sglang/kernels/ops/attention/deepseek_v4_rope.py +++ python/sglang/kernels/ops/attention/deepseek_v4_rope.py @@ -649,123 +649,3 @@ HAS_WEIGHT=(weight is not None), USE_POS=(positions is not None), ) - - -# Cache contiguous real/imag halves of each freqs_cis (its .real/.imag are -# stri...
0
120
2
[ "deepseek" ]
[ "NPU" ]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/deepseek_v4_rope.py). Goal: [NPU] Optimize DeepSeek-V4 performance Target hardware: NPU Target models: deepseek Current file: ```python import logging import math from functools import lru_cache from typing import Optional import torch...
## Motivation This PR improves DeepSeek-V4 serving performance on Ascend NPU by adding PD disaggregation and chunked prefill support, together with optimizations for the prefill and decode execution paths. All hardware-specific behavior is gated to the NPU + DeepSeek-V4 path, leaving CUDA, ROCm, and other model archi...
[]
null
null
sglang
1054060ef1192bceab0e844b8a51fd083cab1b39
2026-07-25T19:38:11+08:00
31,552
https://github.com/sgl-project/sglang/pull/31552
perf: speed up marlin moe with occupancy-aware launch specialization (#31552)
perf: speed up marlin moe with occupancy-aware launch specialization (#31552)
python/sglang/kernels/jit/csrc/gemm/marlin_moe/kernel.h
cpp
Apache-2.0
#include <sgl_kernel/scalar_type.hpp> #include "../marlin/marlin.cuh" #include "../marlin/marlin_dtypes.cuh" #define MARLIN_KERNEL_PARAMS \ const int4 *__restrict__ A, const int4 *__restrict__ B, int4 *__restrict__ C, int4 *__r...
#include <sgl_kernel/scalar_type.hpp> #include "../marlin/marlin.cuh" #include "../marlin/marlin_dtypes.cuh" #define MARLIN_KERNEL_PARAMS \ const int4 *__restrict__ A, const int4 *__restrict__ B, int4 *__restrict__ C, int4 *__r...
--- python/sglang/kernels/jit/csrc/gemm/marlin_moe/kernel.h +++ python/sglang/kernels/jit/csrc/gemm/marlin_moe/kernel.h @@ -30,7 +30,9 @@ // fetch pipeline const int group_blocks, // number of consecutive 16x16 blocks ...
3
1
4
[]
[]
[]
Optimize this cpp kernel file from sglang (python/sglang/kernels/jit/csrc/gemm/marlin_moe/kernel.h). Goal: perf: speed up marlin moe with occupancy-aware launch specialization Target hardware: unspecified Target models: unspecified Current file: ```cpp #include <sgl_kernel/scalar_type.hpp> #include "../marlin/marli...
## Summary - specialize Marlin MoE kernels for expert-parallel and bias launch paths at JIT compile time, removing per-block branches from the hot loop - choose large-M Marlin launch configs using register/shared-memory occupancy and available problem parallelism instead of accepting the first valid config - cover bot...
[{"scope": "e2e", "hardware": "H200", "model": "moonshotai/Kimi-K2.7-Code", "shape": null, "batch_size": null, "metric": "prefill", "unit": "ms", "higher_is_better": false, "baseline": 213.285, "optimized": 204.726, "stated_speedup": null, "speedup": 1.0418}, {"scope": "e2e", "hardware": "H200", "model": "moonshotai/Ki...
1.0595
1.0391
sglang
1054060ef1192bceab0e844b8a51fd083cab1b39
2026-07-25T19:38:11+08:00
31,552
https://github.com/sgl-project/sglang/pull/31552
perf: speed up marlin moe with occupancy-aware launch specialization (#31552)
perf: speed up marlin moe with occupancy-aware launch specialization (#31552)
python/sglang/kernels/jit/csrc/gemm/marlin_moe/marlin_template.h
cpp
Apache-2.0
/* * Modified by Neural Magic * Copyright (C) Marlin.2024 Elias Frantar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Un...
/* * Modified by Neural Magic * Copyright (C) Marlin.2024 Elias Frantar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Un...
--- python/sglang/kernels/jit/csrc/gemm/marlin_moe/marlin_template.h +++ python/sglang/kernels/jit/csrc/gemm/marlin_moe/marlin_template.h @@ -51,7 +51,9 @@ // fetch pipeline const int group_blocks, // number of consecutive 16x16 blocks ...
49
32
4
[]
[]
[]
Optimize this cpp kernel file from sglang (python/sglang/kernels/jit/csrc/gemm/marlin_moe/marlin_template.h). Goal: perf: speed up marlin moe with occupancy-aware launch specialization Target hardware: unspecified Target models: unspecified Current file: ```cpp /* * Modified by Neural Magic * Copyright (C) Marlin.2...
## Summary - specialize Marlin MoE kernels for expert-parallel and bias launch paths at JIT compile time, removing per-block branches from the hot loop - choose large-M Marlin launch configs using register/shared-memory occupancy and available problem parallelism instead of accepting the first valid config - cover bot...
[{"scope": "e2e", "hardware": "H200", "model": "moonshotai/Kimi-K2.7-Code", "shape": null, "batch_size": null, "metric": "prefill", "unit": "ms", "higher_is_better": false, "baseline": 213.285, "optimized": 204.726, "stated_speedup": null, "speedup": 1.0418}, {"scope": "e2e", "hardware": "H200", "model": "moonshotai/Ki...
1.0595
1.0391
sglang
1054060ef1192bceab0e844b8a51fd083cab1b39
2026-07-25T19:38:11+08:00
31,552
https://github.com/sgl-project/sglang/pull/31552
perf: speed up marlin moe with occupancy-aware launch specialization (#31552)
perf: speed up marlin moe with occupancy-aware launch specialization (#31552)
python/sglang/kernels/jit/csrc/gemm/marlin_moe/moe_wna16_marlin.cuh
cuda
Apache-2.0
/* * Modified by Neural Magic * Copyright (C) Marlin.2024 Elias Frantar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Un...
/* * Modified by Neural Magic * Copyright (C) Marlin.2024 Elias Frantar * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Un...
--- python/sglang/kernels/jit/csrc/gemm/marlin_moe/moe_wna16_marlin.cuh +++ python/sglang/kernels/jit/csrc/gemm/marlin_moe/moe_wna16_marlin.cuh @@ -154,6 +154,9 @@ thread_config_t tb_cfg; } exec_config_t; +constexpr int kSharedMemoryValidityMargin = 512; +constexpr int kSharedMemoryLaunchReserve = 1024; + int ge...
42
25
4
[]
[]
[]
Optimize this cuda kernel file from sglang (python/sglang/kernels/jit/csrc/gemm/marlin_moe/moe_wna16_marlin.cuh). Goal: perf: speed up marlin moe with occupancy-aware launch specialization Target hardware: unspecified Target models: unspecified Current file: ```cuda /* * Modified by Neural Magic * Copyright (C) Mar...
## Summary - specialize Marlin MoE kernels for expert-parallel and bias launch paths at JIT compile time, removing per-block branches from the hot loop - choose large-M Marlin launch configs using register/shared-memory occupancy and available problem parallelism instead of accepting the first valid config - cover bot...
[{"scope": "e2e", "hardware": "H200", "model": "moonshotai/Kimi-K2.7-Code", "shape": null, "batch_size": null, "metric": "prefill", "unit": "ms", "higher_is_better": false, "baseline": 213.285, "optimized": 204.726, "stated_speedup": null, "speedup": 1.0418}, {"scope": "e2e", "hardware": "H200", "model": "moonshotai/Ki...
1.0595
1.0391
sglang
9402012f0f19857ed9a5a0922dafebaf6382a0e3
2026-07-25T08:17:12+08:00
32,296
https://github.com/sgl-project/sglang/pull/32296
[Perf] Halve the non-finite sanitization overhead in per_token_group_quant (#32296)
[Perf] Halve the non-finite sanitization overhead in per_token_group_quant (#32296) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
python/sglang/kernels/jit/csrc/gemm/per_token_group_quant.cuh
cuda
Apache-2.0
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/math.cuh> #include <sgl_kernel/type.cuh> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/vec.cuh> #include <sgl_kernel/warp.cuh> #include <sgl_kernel/deepseek_v4/fp8_utils.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/containe...
#include <sgl_kernel/tensor.h> #include <sgl_kernel/utils.h> #include <sgl_kernel/math.cuh> #include <sgl_kernel/type.cuh> #include <sgl_kernel/utils.cuh> #include <sgl_kernel/vec.cuh> #include <sgl_kernel/warp.cuh> #include <sgl_kernel/deepseek_v4/fp8_utils.cuh> #include <dlpack/dlpack.h> #include <tvm/ffi/containe...
--- python/sglang/kernels/jit/csrc/gemm/per_token_group_quant.cuh +++ python/sglang/kernels/jit/csrc/gemm/per_token_group_quant.cuh @@ -48,14 +48,16 @@ using packed2_t = fp8x2_e4m3_t; static constexpr float kMaxValue = DTypeTrait<fp8_e4m3_t>::kFloatMax; // SATFINITE saturates +-inf / out-of-range values, but c...
17
14
1
[]
[]
[]
Optimize this cuda kernel file from sglang (python/sglang/kernels/jit/csrc/gemm/per_token_group_quant.cuh). Goal: [Perf] Halve the non-finite sanitization overhead in per_token_group_quant Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <sgl_kernel/tensor.h> #include <sgl_kernel...
## Motivation #32188 fixed the H100 deepep TBO CI break by sanitizing non-finite quant inputs with a **two-sided clamp** before the fp8 conversion. That fix is correct, but it costs more than it needs to: the trait-driven quant kernel is latency-bound at decode batch sizes, and the clamp added 16 `HMNMX2` (ue8m0 path)...
[{"scope": "kernel", "hardware": "B200", "model": null, "shape": "gs=32/64/128", "batch_size": null, "metric": "speedup", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.009, "speedup": 1.009}, {"scope": "kernel", "hardware": "B200", "model": null, "shape": "gs=32/64/128...
1.009
null
sglang
1b63155efead7494843f6db8681851ba94611f73
2026-07-22T22:00:25-07:00
32,109
https://github.com/sgl-project/sglang/pull/32109
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
python/sglang/kernels/ops/attention/dsa/index_buf_accessor.py
triton
Apache-2.0
from typing import TYPE_CHECKING import torch import triton import triton.language as tl from sglang.kernels.ops.quantization.fp8_kernel import is_fp8_fnuz from sglang.srt.layers.attention.dsa.utils import aiter_can_use_preshuffle_paged_mqa from sglang.srt.utils import get_bool_env_var, is_hip _is_hip = is_hip() _is...
from typing import TYPE_CHECKING import torch import triton import triton.language as tl from sglang.kernels.ops.quantization.fp8_kernel import is_fp8_fnuz from sglang.srt.layers.attention.dsa.utils import aiter_can_use_preshuffle_paged_mqa from sglang.srt.utils import get_bool_env_var, is_hip _is_hip = is_hip() _is...
--- python/sglang/kernels/ops/attention/dsa/index_buf_accessor.py +++ python/sglang/kernels/ops/attention/dsa/index_buf_accessor.py @@ -639,6 +639,9 @@ k_offsets = thread_idx * BLOCK_SIZE_K + tl.arange(0, BLOCK_SIZE_K) seq_len = tl.load(seq_len_ptr + batch_id) + # Grid axis 1 spans the batch-max seq len;...
3
0
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/dsa/index_buf_accessor.py). Goal: [Perf] Skip blocks past per-request live length in full-width Triton kernels Target hardware: unspecified Target models: unspecified Current file: ```python from typing import TYPE_CHECKING import torc...
Extend the per-request early-exit pattern from #31981 to the remaining kernels whose grid or inner loop spans the full captured width: DSA decode / target-verify metadata, FA3 decode metadata, TRTLLM MHA graph metadata, extend attention (regular and unified), the DSA indexer K+S gather, and the sparse prefill index tra...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "width=16384,seq=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 5.87, "optimized": 5.73, "stated_speedup": null, "speedup": 1.0244}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batc...
1.0227
null
sglang
1b63155efead7494843f6db8681851ba94611f73
2026-07-22T22:00:25-07:00
32,109
https://github.com/sgl-project/sglang/pull/32109
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
python/sglang/kernels/ops/attention/dsa/transform_index.py
triton
Apache-2.0
from itertools import accumulate from typing import List, Optional import torch import triton import triton.language as tl def transform_index_page_table_prefill(**kwargs): return transform_index_page_table_prefill_fast(**kwargs) def transform_index_page_table_decode(**kwargs): return transform_index_page_...
from itertools import accumulate from typing import List, Optional import torch import triton import triton.language as tl def transform_index_page_table_prefill(**kwargs): return transform_index_page_table_prefill_fast(**kwargs) def transform_index_page_table_decode(**kwargs): return transform_index_page_...
--- python/sglang/kernels/ops/attention/dsa/transform_index.py +++ python/sglang/kernels/ops/attention/dsa/transform_index.py @@ -87,6 +87,9 @@ query_start = tl.load(cu_seqlens_q_ptr + request_id) query_end = tl.load(cu_seqlens_q_ptr + request_id + 1) + # Grid axis 1 spans the batch-max extend len; fully...
3
0
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/dsa/transform_index.py). Goal: [Perf] Skip blocks past per-request live length in full-width Triton kernels Target hardware: unspecified Target models: unspecified Current file: ```python from itertools import accumulate from typing imp...
Extend the per-request early-exit pattern from #31981 to the remaining kernels whose grid or inner loop spans the full captured width: DSA decode / target-verify metadata, FA3 decode metadata, TRTLLM MHA graph metadata, extend attention (regular and unified), the DSA indexer K+S gather, and the sparse prefill index tra...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "width=16384,seq=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 5.87, "optimized": 5.73, "stated_speedup": null, "speedup": 1.0244}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batc...
1.0227
null
sglang
1b63155efead7494843f6db8681851ba94611f73
2026-07-22T22:00:25-07:00
32,109
https://github.com/sgl-project/sglang/pull/32109
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
python/sglang/kernels/ops/attention/dsa_metadata.py
triton
Apache-2.0
from typing import Optional import torch import triton import triton.language as tl @triton.jit( do_not_specialize=[ "page_table_stride_0", "real_page_table_stride_0", "max_len", ] ) def _fused_dsa_decode_metadata_kernel( seq_lens, req_pool_indices, req_to_token, cache...
from typing import Optional import torch import triton import triton.language as tl @triton.jit( do_not_specialize=[ "page_table_stride_0", "real_page_table_stride_0", "max_len", ] ) def _fused_dsa_decode_metadata_kernel( seq_lens, req_pool_indices, req_to_token, cache...
--- python/sglang/kernels/ops/attention/dsa_metadata.py +++ python/sglang/kernels/ops/attention/dsa_metadata.py @@ -71,6 +71,16 @@ mask=row < bs, other=0, ) + # Skip column blocks past the request's kv length: no consumer reads there + # (attention and the indexer both stay within cache_seq...
28
0
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/dsa_metadata.py). Goal: [Perf] Skip blocks past per-request live length in full-width Triton kernels Target hardware: unspecified Target models: unspecified Current file: ```python from typing import Optional import torch import triton...
Extend the per-request early-exit pattern from #31981 to the remaining kernels whose grid or inner loop spans the full captured width: DSA decode / target-verify metadata, FA3 decode metadata, TRTLLM MHA graph metadata, extend attention (regular and unified), the DSA indexer K+S gather, and the sparse prefill index tra...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "width=16384,seq=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 5.87, "optimized": 5.73, "stated_speedup": null, "speedup": 1.0244}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batc...
1.0227
null
sglang
1b63155efead7494843f6db8681851ba94611f73
2026-07-22T22:00:25-07:00
32,109
https://github.com/sgl-project/sglang/pull/32109
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
python/sglang/kernels/ops/attention/extend_attention.py
triton
Apache-2.0
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
--- python/sglang/kernels/ops/attention/extend_attention.py +++ python/sglang/kernels/ops/attention/extend_attention.py @@ -313,6 +313,10 @@ cur_seq_len_prefix = tl.load(kv_indptr + cur_seq + 1) - cur_seq_kv_start_idx cur_seq_len = cur_seq_len_prefix + cur_seq_len_extend + # Grid axis 2 spans the batch-m...
8
0
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/extend_attention.py). Goal: [Perf] Skip blocks past per-request live length in full-width Triton kernels Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under ...
Extend the per-request early-exit pattern from #31981 to the remaining kernels whose grid or inner loop spans the full captured width: DSA decode / target-verify metadata, FA3 decode metadata, TRTLLM MHA graph metadata, extend attention (regular and unified), the DSA indexer K+S gather, and the sparse prefill index tra...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "width=16384,seq=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 5.87, "optimized": 5.73, "stated_speedup": null, "speedup": 1.0244}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batc...
1.0227
null
sglang
1b63155efead7494843f6db8681851ba94611f73
2026-07-22T22:00:25-07:00
32,109
https://github.com/sgl-project/sglang/pull/32109
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
python/sglang/kernels/ops/attention/metadata.py
triton
Apache-2.0
from typing import TYPE_CHECKING, Optional import torch import triton import triton.language as tl if TYPE_CHECKING: from sglang.srt.mem_cache.swa_memory_pool import SWAKVPool @triton.jit def get_num_kv_splits_triton( num_kv_splits_ptr, seq_lens_ptr, num_seq, num_group, num_head, num_kv_...
from typing import TYPE_CHECKING, Optional import torch import triton import triton.language as tl if TYPE_CHECKING: from sglang.srt.mem_cache.swa_memory_pool import SWAKVPool @triton.jit def get_num_kv_splits_triton( num_kv_splits_ptr, seq_lens_ptr, num_seq, num_group, num_head, num_kv_...
--- python/sglang/kernels/ops/attention/metadata.py +++ python/sglang/kernels/ops/attention/metadata.py @@ -213,13 +213,25 @@ return i = pid_b + # Self-guard on the device-side seq_len: skip column chunks past the + # request's live pages (tails keep stale values the attention kernels + # never...
28
4
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/metadata.py). Goal: [Perf] Skip blocks past per-request live length in full-width Triton kernels Target hardware: unspecified Target models: unspecified Current file: ```python from typing import TYPE_CHECKING, Optional import torch im...
Extend the per-request early-exit pattern from #31981 to the remaining kernels whose grid or inner loop spans the full captured width: DSA decode / target-verify metadata, FA3 decode metadata, TRTLLM MHA graph metadata, extend attention (regular and unified), the DSA indexer K+S gather, and the sparse prefill index tra...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "width=16384,seq=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 5.87, "optimized": 5.73, "stated_speedup": null, "speedup": 1.0244}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batc...
1.0227
null
sglang
1b63155efead7494843f6db8681851ba94611f73
2026-07-22T22:00:25-07:00
32,109
https://github.com/sgl-project/sglang/pull/32109
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
[Perf] Skip blocks past per-request live length in full-width Triton kernels (#32109)
python/sglang/kernels/ops/kvcache/trtllm_mha_graph_metadata.py
triton
Apache-2.0
"""Fused CUDA-graph metadata update for the TRTLLM MHA backend. `TRTLLMHAAttnBackend._apply_cuda_graph_metadata` used to rebuild the page table(s) and seqlen buffers with ~25 small aten ops per graph replay (index gathers, floor_divide, cumsum, dtype casts, copies). On some CPUs that is ~0.7-1.0 ms of pure host dispat...
"""Fused CUDA-graph metadata update for the TRTLLM MHA backend. `TRTLLMHAAttnBackend._apply_cuda_graph_metadata` used to rebuild the page table(s) and seqlen buffers with ~25 small aten ops per graph replay (index gathers, floor_divide, cumsum, dtype casts, copies). On some CPUs that is ~0.7-1.0 ms of pure host dispat...
--- python/sglang/kernels/ops/kvcache/trtllm_mha_graph_metadata.py +++ python/sglang/kernels/ops/kvcache/trtllm_mha_graph_metadata.py @@ -75,9 +75,12 @@ row_out = page_table_ptr + pid.to(tl.int64) * page_table_stride if HAS_SWA: swa_row_out = swa_page_table_ptr + pid.to(tl.int64) * swa_pa...
11
3
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/kvcache/trtllm_mha_graph_metadata.py). Goal: [Perf] Skip blocks past per-request live length in full-width Triton kernels Target hardware: unspecified Target models: unspecified Current file: ```python """Fused CUDA-graph metadata update for the ...
Extend the per-request early-exit pattern from #31981 to the remaining kernels whose grid or inner loop spans the full captured width: DSA decode / target-verify metadata, FA3 decode metadata, TRTLLM MHA graph metadata, extend attention (regular and unified), the DSA indexer K+S gather, and the sparse prefill index tra...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "width=16384,seq=1024", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 5.87, "optimized": 5.73, "stated_speedup": null, "speedup": 1.0244}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batc...
1.0227
null
sglang
08cb081ed0bbb75d61233d343b52fb306801db74
2026-07-21T16:20:14-07:00
31,981
https://github.com/sgl-project/sglang/pull/31981
[Perf] Skip page-table columns past kv length in DSA draft-extend metadata kernel (#31981)
[Perf] Skip page-table columns past kv length in DSA draft-extend metadata kernel (#31981)
python/sglang/kernels/ops/attention/dsa_metadata.py
triton
Apache-2.0
from typing import Optional import torch import triton import triton.language as tl @triton.jit( do_not_specialize=[ "page_table_stride_0", "real_page_table_stride_0", "max_len", ] ) def _fused_dsa_decode_metadata_kernel( seq_lens, req_pool_indices, req_to_token, cache...
from typing import Optional import torch import triton import triton.language as tl @triton.jit( do_not_specialize=[ "page_table_stride_0", "real_page_table_stride_0", "max_len", ] ) def _fused_dsa_decode_metadata_kernel( seq_lens, req_pool_indices, req_to_token, cache...
--- python/sglang/kernels/ops/attention/dsa_metadata.py +++ python/sglang/kernels/ops/attention/dsa_metadata.py @@ -524,6 +524,15 @@ mask=req_row < bs, other=0, ).to(tl.int32) + # Skip column blocks past the request's kv length: no consumer reads there + # (attention and the indexer both st...
9
0
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/kernels/ops/attention/dsa_metadata.py). Goal: [Perf] Skip page-table columns past kv length in DSA draft-extend metadata kernel Target hardware: unspecified Target models: unspecified Current file: ```python from typing import Optional import torch import t...
The DSA draft-extend metadata kernel copies the page table over the full captured context width, but each request's real kv length is far smaller. Add a per-program early-exit: skip whole column blocks whose start is past the request's kv length (downstream attention and the indexer both bound their reads by `cache_seq...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 74.9, "optimized": 40.9, "stated_speedup": null, "speedup": 1.8313}]
1.8313
null
sglang
5ce5e1ee3efe934d9737d382e410165381572af8
2026-07-10T09:09:38+08:00
30,716
https://github.com/sgl-project/sglang/pull/30716
[Diffusion] Revert CPU AMX optimizations (#30716)
[Diffusion] Revert CPU AMX optimizations (#30716)
sgl-kernel/csrc/cpu/flash_attn.cpp
cpp
BSD-3-Clause
/***************************************************************************************** * Copyright (c) 2025 - 2025 Codeplay Software Ltd. All rights reserved. * Copyright (C) 2025 Intel Corporation, All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary for...
/***************************************************************************************** * Copyright (c) 2025 - 2025 Codeplay Software Ltd. All rights reserved. * Copyright (C) 2025 Intel Corporation, All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary for...
--- sgl-kernel/csrc/cpu/flash_attn.cpp +++ sgl-kernel/csrc/cpu/flash_attn.cpp @@ -443,8 +443,7 @@ const at::Tensor& cu_seqlens_k, int64_t max_seqlen_q, int64_t max_seqlen_k, - bool causal, - const std::optional<double>& sm_scale) { + bool causal) { CHECK_LAST_DIM_CONTIGUOUS_INPUT(q); CHECK...
4
5
3
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/flash_attn.cpp). Goal: [Diffusion] Revert CPU AMX optimizations Target hardware: CPU Target models: unspecified Current file: ```cpp /***************************************************************************************** * Copyright (c) 2025 - 2025 Co...
Reverts #28527 (`177c048c68`). That change adds a second unconditional `process_weights_after_loading()` pass in the diffusion FSDP loader. The hook is not idempotent for quantized weights, and the added `device_loading_context` also breaks FSDP inference by attempting to restore CUDA-backed parameters to CPU storage....
[]
null
null
sglang
5ce5e1ee3efe934d9737d382e410165381572af8
2026-07-10T09:09:38+08:00
30,716
https://github.com/sgl-project/sglang/pull/30716
[Diffusion] Revert CPU AMX optimizations (#30716)
[Diffusion] Revert CPU AMX optimizations (#30716)
sgl-kernel/csrc/cpu/torch_extension_cpu.cpp
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/cpu/torch_extension_cpu.cpp +++ sgl-kernel/csrc/cpu/torch_extension_cpu.cpp @@ -235,8 +235,7 @@ const at::Tensor& cu_seqlens_k, int64_t max_seqlen_q, int64_t max_seqlen_k, - bool causal, - const std::optional<double>& sm_scale); + bool causal); // linear attention std::tu...
2
3
3
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: [Diffusion] Revert CPU AMX optimizations Target hardware: CPU Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License...
Reverts #28527 (`177c048c68`). That change adds a second unconditional `process_weights_after_loading()` pass in the diffusion FSDP loader. The hook is not idempotent for quantized weights, and the added `device_loading_context` also breaks FSDP inference by attempting to restore CUDA-backed parameters to CPU storage....
[]
null
null
sglang
177c048c68b38930a675fac1e0b860b4c668b95f
2026-07-09T10:26:22+08:00
28,527
https://github.com/sgl-project/sglang/pull/28527
[Diffusion][CPU] Adding AMX optimizations for CPU platform (#28527)
[Diffusion][CPU] Adding AMX optimizations for CPU platform (#28527) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
sgl-kernel/csrc/cpu/flash_attn.cpp
cpp
BSD-3-Clause
/***************************************************************************************** * Copyright (c) 2025 - 2025 Codeplay Software Ltd. All rights reserved. * Copyright (C) 2025 Intel Corporation, All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary for...
/***************************************************************************************** * Copyright (c) 2025 - 2025 Codeplay Software Ltd. All rights reserved. * Copyright (C) 2025 Intel Corporation, All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * * Redistribution and use in source and binary for...
--- sgl-kernel/csrc/cpu/flash_attn.cpp +++ sgl-kernel/csrc/cpu/flash_attn.cpp @@ -443,7 +443,8 @@ const at::Tensor& cu_seqlens_k, int64_t max_seqlen_q, int64_t max_seqlen_k, - bool causal) { + bool causal, + const std::optional<double>& sm_scale) { CHECK_LAST_DIM_CONTIGUOUS_INPUT(q); CHECK...
5
4
3
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/flash_attn.cpp). Goal: [Diffusion][CPU] Adding AMX optimizations for CPU platform Target hardware: CPU Target models: unspecified Current file: ```cpp /***************************************************************************************** * Copyright ...
This pr takes parts of follow-ups (mentioned in https://github.com/sgl-project/sglang/pull/20816) to bring key AMX based optimizations (scoping from LLM models) for CPU platforms, including: - Adding CPU AMX backend, replace SDPA to bring best attention perf. - Similar like for LLM models, adding replacement for amx w...
[{"scope": "e2e", "hardware": null, "model": "Wan-AI/Wan2.2-TI2V-5B-Diffusers", "shape": null, "batch_size": null, "metric": "speedup", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 10.0, "speedup": 10.0}, {"scope": "e2e", "hardware": null, "model": "Wan-AI/Wan2.2-TI2V-5...
null
2
sglang
177c048c68b38930a675fac1e0b860b4c668b95f
2026-07-09T10:26:22+08:00
28,527
https://github.com/sgl-project/sglang/pull/28527
[Diffusion][CPU] Adding AMX optimizations for CPU platform (#28527)
[Diffusion][CPU] Adding AMX optimizations for CPU platform (#28527) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com>
sgl-kernel/csrc/cpu/torch_extension_cpu.cpp
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/cpu/torch_extension_cpu.cpp +++ sgl-kernel/csrc/cpu/torch_extension_cpu.cpp @@ -153,7 +153,8 @@ const at::Tensor& cu_seqlens_k, int64_t max_seqlen_q, int64_t max_seqlen_k, - bool causal); + bool causal, + const std::optional<double>& sm_scale); // linear attention std::tu...
3
2
3
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: [Diffusion][CPU] Adding AMX optimizations for CPU platform Target hardware: CPU Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version...
This pr takes parts of follow-ups (mentioned in https://github.com/sgl-project/sglang/pull/20816) to bring key AMX based optimizations (scoping from LLM models) for CPU platforms, including: - Adding CPU AMX backend, replace SDPA to bring best attention perf. - Similar like for LLM models, adding replacement for amx w...
[{"scope": "e2e", "hardware": null, "model": "Wan-AI/Wan2.2-TI2V-5B-Diffusers", "shape": null, "batch_size": null, "metric": "speedup", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 10.0, "speedup": 10.0}, {"scope": "e2e", "hardware": null, "model": "Wan-AI/Wan2.2-TI2V-5...
null
2
sglang
a2d7eb303eb8fef99276cbf126dded16a0c23bc8
2026-07-03T11:18:59+08:00
26,771
https://github.com/sgl-project/sglang/pull/26771
[MoE] Consolidate ungrouped + grouped gate/topk onto one Triton router (#26771) — faster than AOT on B200/H100/H200, at parity with flashinfer (#29771)
[MoE] Consolidate ungrouped + grouped gate/topk onto one Triton router (#26771) — faster than AOT on B200/H100/H200, at parity with flashinfer (#29771) Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
python/sglang/srt/layers/moe/topk.py
triton
Apache-2.0
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
--- python/sglang/srt/layers/moe/topk.py +++ python/sglang/srt/layers/moe/topk.py @@ -789,6 +789,24 @@ num_token_non_padded=num_token_non_padded, ) # ===== END TO BE REFACTORED ==== + elif _is_cuda and envs.SGLANG_OPT_USE_JIT_KERNEL_FUSED_TOPK.get(): + # Unified ...
80
14
1
[]
[ "B200", "H100", "H200" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/topk.py). Goal: [MoE] Consolidate ungrouped + grouped gate/topk onto one Triton router (#26771) — faster than AOT on B200/H100/H200, at parity with flashinfer Target hardware: B200, H100, H200 Target models: unspecified Current file: ```python...
[]
null
null
sglang
56f22cd520cbdf58cb89c688d7847c1186df6bc3
2026-07-01T10:11:29+08:00
28,612
https://github.com/sgl-project/sglang/pull/28612
Optimize C128 state pool allocation using request state pool (#28612)
Optimize C128 state pool allocation using request state pool (#28612)
python/sglang/srt/layers/attention/dsv4/compress_hip.py
triton
Apache-2.0
from __future__ import annotations import os from functools import cached_property from typing import TYPE_CHECKING, Any import torch import torch.nn as nn import triton import triton.language as tl from sglang.srt.environ import envs from sglang.srt.layers.attention.dsa.dsa_indexer import rotate_activation from sgl...
from __future__ import annotations import os from functools import cached_property from typing import TYPE_CHECKING, Any import torch import torch.nn as nn import triton import triton.language as tl from sglang.srt.environ import envs from sglang.srt.layers.attention.dsa.dsa_indexer import rotate_activation from sgl...
--- python/sglang/srt/layers/attention/dsv4/compress_hip.py +++ python/sglang/srt/layers/attention/dsv4/compress_hip.py @@ -210,13 +210,18 @@ pre_state_indices = self.compute_state_len_indices( seq_len=prefix_lens[i], ratio=self.ratio ).to(device) - raw_loc = torch....
54
31
5
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/dsv4/compress_hip.py). Goal: Optimize C128 state pool allocation using request state pool Target hardware: unspecified Target models: deepseek Current file: ```python from __future__ import annotations import os from functools import ca...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Co-authored-by: [shiyu7](https://github.com/s...
[]
null
null
sglang
56f22cd520cbdf58cb89c688d7847c1186df6bc3
2026-07-01T10:11:29+08:00
28,612
https://github.com/sgl-project/sglang/pull/28612
Optimize C128 state pool allocation using request state pool (#28612)
Optimize C128 state pool allocation using request state pool (#28612)
python/sglang/srt/layers/attention/dsv4/compressor_v2.py
triton
Apache-2.0
from __future__ import annotations from typing import TYPE_CHECKING, List, Literal, Optional, TypeAlias, Union, cast import torch from sglang.jit_kernel.dsv4 import ( CompressorDecodePlan, CompressorPrefillPlan, compress_forward, compress_norm_rope_store, ) from sglang.jit_kernel.utils import is_hip_...
from __future__ import annotations from typing import TYPE_CHECKING, List, Literal, Optional, TypeAlias, Union, cast import torch from sglang.jit_kernel.dsv4 import ( CompressorDecodePlan, CompressorPrefillPlan, compress_forward, compress_norm_rope_store, ) from sglang.jit_kernel.utils import is_hip_...
--- python/sglang/srt/layers/attention/dsv4/compressor_v2.py +++ python/sglang/srt/layers/attention/dsv4/compressor_v2.py @@ -731,7 +731,7 @@ seq_lens=seq_lens_planner, extend_lens=extend_lens_planner, req_to_token=req_to_token, - full_to_swa=full_to_swa, + f...
2
8
5
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/dsv4/compressor_v2.py). Goal: Optimize C128 state pool allocation using request state pool Target hardware: unspecified Target models: deepseek Current file: ```python from __future__ import annotations from typing import TYPE_CHECKING,...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Co-authored-by: [shiyu7](https://github.com/s...
[]
null
null
sglang
bd3b252e0af0e7bfbcc1f329a672a7ee47a36721
2026-06-29T09:38:30+08:00
29,382
https://github.com/sgl-project/sglang/pull/29382
[CPU] use faster exp in silu_and_mul (#29382)
[CPU] use faster exp in silu_and_mul (#29382)
sgl-kernel/csrc/cpu/activation.cpp
cpp
Apache-2.0
#include "common.h" #include "vec.h" namespace { template <typename scalar_t, typename func_t, typename vec_func_t> void act_and_mul_kernel_impl( scalar_t* __restrict__ output, const scalar_t* __restrict__ input, int64_t num_tokens, int64_t dim, const func_t& f, const vec_func_t& vf) { using...
#include "common.h" #include "vec.h" namespace { template <typename scalar_t, typename func_t, typename vec_func_t> void act_and_mul_kernel_impl( scalar_t* __restrict__ output, const scalar_t* __restrict__ input, int64_t num_tokens, int64_t dim, const func_t& f, const vec_func_t& vf) { using...
--- sgl-kernel/csrc/cpu/activation.cpp +++ sgl-kernel/csrc/cpu/activation.cpp @@ -121,7 +121,7 @@ num_tokens, d, [](float x) { return x / (1.f + std::exp(-x)); }, - [](Vec x) { return x / (Vec(1.f) + x.neg().exp()); }); + [](Vec x) { return x / (Vec(1.f) + x.neg().exp_u20()); })...
1
1
1
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/activation.cpp). Goal: [CPU] use faster exp in silu_and_mul Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "vec.h" namespace { template <typename scalar_t, typename func_t, typename vec_func_t> void act...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation This PR speeds up the CPU `silu_and_mul_cpu` ...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "N=1,K=18432", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 10.311, "optimized": 9.103, "stated_speedup": 1.133, "speedup": 1.1327}, {"scope": "kernel", "hardware": null, "model": null, "shape": "N=17,K=18432", ...
1.1635
null
sglang
2c3f007a656b8c9414d15320f9a49f15420950b9
2026-06-25T09:04:34+08:00
29,117
https://github.com/sgl-project/sglang/pull/29117
[CPU] optimize GDN prefill performance (#29117)
[CPU] optimize GDN prefill performance (#29117)
sgl-kernel/csrc/cpu/vec.h
cpp
Apache-2.0
#pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #include <ATen/cpu/vec/functional.h> #include <ATen/cpu/vec/vec.h> namespace { using namespace at::vec; template <typename scalar_t, typename std::enable_if_t<is_reduced_floating_point_v<s...
#pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #include <ATen/cpu/vec/functional.h> #include <ATen/cpu/vec/vec.h> namespace { using namespace at::vec; template <typename scalar_t, typename std::enable_if_t<is_reduced_floating_point_v<s...
--- sgl-kernel/csrc/cpu/vec.h +++ sgl-kernel/csrc/cpu/vec.h @@ -287,6 +287,77 @@ // transpose utils // taken from my PR in ggml: https://github.com/ggml-org/llama.cpp/pull/8998 #if defined(CPU_CAPABILITY_AVX512) +inline void transpose_16x16_16bit(__m256i* v) { + __m256i v1[16]; + v1[0] = _mm256_unpacklo_epi16(v[0]...
71
0
2
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/vec.h). Goal: [CPU] optimize GDN prefill performance Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #inc...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Optimize the CPU GDN (Gated Delta Network) ke...
[]
null
null
sglang
d5e9176f6581e3c9274dd33a95315033aa194df5
2026-06-24T22:13:35+02:00
27,053
https://github.com/sgl-project/sglang/pull/27053
[BCG][GLM5] perf: BCG support and prefill enhancements (#27053)
[BCG][GLM5] perf: BCG support and prefill enhancements (#27053)
python/sglang/srt/layers/attention/dsa/utils.py
triton
Apache-2.0
from functools import lru_cache from typing import TYPE_CHECKING, List, Tuple, Union import torch import triton import triton.language as tl from sglang.srt.environ import envs from sglang.srt.layers.dp_attention import ( DpPaddingMode, ) from sglang.srt.runtime_context import get_parallel from sglang.srt.server_...
from functools import lru_cache from typing import TYPE_CHECKING, List, Tuple, Union import torch import triton import triton.language as tl from sglang.srt.environ import envs from sglang.srt.layers.dp_attention import ( DpPaddingMode, ) from sglang.srt.model_executor.runner_backend_utils.breakable_cuda_graph im...
--- python/sglang/srt/layers/attention/dsa/utils.py +++ python/sglang/srt/layers/attention/dsa/utils.py @@ -9,9 +9,15 @@ from sglang.srt.layers.dp_attention import ( DpPaddingMode, ) +from sglang.srt.model_executor.runner_backend_utils.breakable_cuda_graph import ( + is_in_breakable_cuda_graph, +) +from sglan...
20
1
3
[ "glm" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/dsa/utils.py). Goal: [BCG][GLM5] perf: BCG support and prefill enhancements Target hardware: unspecified Target models: glm Current file: ```python from functools import lru_cache from typing import TYPE_CHECKING, List, Tuple, Union imp...
## Motivation https://github.com/sgl-project/sglang/pull/23351 introduced PCG for GLM5 (`nsa_indexer`). As the current implementation runs the full indexer path, which is not fully captured by a CUDA graph, we found that running the fast indexer in eager mode yields better performance. Moreover, the current PCG split...
[{"scope": "e2e", "hardware": "B200", "model": null, "shape": "1k1k", "batch_size": 4, "metric": "TTFT", "unit": "ms", "higher_is_better": false, "baseline": 88.74, "optimized": 78.18, "stated_speedup": null, "speedup": 1.1351}, {"scope": "e2e", "hardware": "B200", "model": null, "shape": "1k1k", "batch_size": 8, "metr...
null
1.011
sglang
af9027f6c938b07995e507ac78496ceef3014d31
2026-06-23T17:20:48+08:00
28,938
https://github.com/sgl-project/sglang/pull/28938
[AMD] Improve performance of dsv4 in high concurrency (#28938)
[AMD] Improve performance of dsv4 in high concurrency (#28938) Co-authored-by: wunhuang <wunhuang@amd.com>
python/sglang/srt/layers/deepseek_v4_rope.py
triton
Apache-2.0
import logging import math from functools import lru_cache from typing import Optional import torch import triton import triton.language as tl logger = logging.getLogger(__name__) # tilelang isn't shipped on every platform (e.g. Ascend NPU images) and the # only tilelang artifacts in this file are pass_configs that ...
import logging import math from functools import lru_cache from typing import Optional import torch import triton import triton.language as tl logger = logging.getLogger(__name__) # tilelang isn't shipped on every platform (e.g. Ascend NPU images) and the # only tilelang artifacts in this file are pass_configs that ...
--- python/sglang/srt/layers/deepseek_v4_rope.py +++ python/sglang/srt/layers/deepseek_v4_rope.py @@ -161,7 +161,7 @@ BLOCK_M: tl.constexpr, BLOCK_P: tl.constexpr, ): - # Batched variant: BLOCK_M tokens per program (mirrors ATOM's inverse_rope_gptj + # Batched variant: BLOCK_M tokens per program #...
43
32
2
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/deepseek_v4_rope.py). Goal: [AMD] Improve performance of dsv4 in high concurrency Target hardware: unspecified Target models: deepseek Current file: ```python import logging import math from functools import lru_cache from typing import Optional ...
## Motivation DeepSeek-V4 on AMD (MI35X, HIP) under high concurrency (TP8 + DP-attention, c512) trails. Per-layer trace analysis (pure-prefill + a c512/ISL8192 mixed trace) showed the gap was **not** the heavy GEMM/MoE kernels but a few avoidable overheads in the prefill / dp-attention path: - the attention-output (i...
[{"scope": "e2e", "hardware": "MI35X", "model": "DeepSeek-V4-Pro", "shape": null, "batch_size": 512, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 17800, "optimized": 18088, "stated_speedup": null, "speedup": 1.0162}, {"scope": "e2e", "hardware": "MI35X", "model": "DeepSeek-V4-Pro", "sh...
2.8475
1.0589
sglang
af9027f6c938b07995e507ac78496ceef3014d31
2026-06-23T17:20:48+08:00
28,938
https://github.com/sgl-project/sglang/pull/28938
[AMD] Improve performance of dsv4 in high concurrency (#28938)
[AMD] Improve performance of dsv4 in high concurrency (#28938) Co-authored-by: wunhuang <wunhuang@amd.com>
python/sglang/srt/layers/dp_attention.py
triton
Apache-2.0
from __future__ import annotations import functools import logging from contextlib import contextmanager from enum import IntEnum, auto from typing import TYPE_CHECKING, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.distributed import ( GroupCoordinator, get_at...
from __future__ import annotations import functools import logging from contextlib import contextmanager from enum import IntEnum, auto from typing import TYPE_CHECKING, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.distributed import ( GroupCoordinator, get_at...
--- python/sglang/srt/layers/dp_attention.py +++ python/sglang/srt/layers/dp_attention.py @@ -580,13 +580,11 @@ else: local_real = local_tokens.new_zeros((local_rows, *local_tokens.shape[1:])) local_real[: local_tokens.shape[0]].copy_(local_tokens) - gathered = get_tp_group().all_gatherv(local...
5
7
2
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/dp_attention.py). Goal: [AMD] Improve performance of dsv4 in high concurrency Target hardware: unspecified Target models: deepseek Current file: ```python from __future__ import annotations import functools import logging from contextlib import c...
## Motivation DeepSeek-V4 on AMD (MI35X, HIP) under high concurrency (TP8 + DP-attention, c512) trails. Per-layer trace analysis (pure-prefill + a c512/ISL8192 mixed trace) showed the gap was **not** the heavy GEMM/MoE kernels but a few avoidable overheads in the prefill / dp-attention path: - the attention-output (i...
[{"scope": "e2e", "hardware": "MI35X", "model": "DeepSeek-V4-Pro", "shape": null, "batch_size": 512, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 17800, "optimized": 18088, "stated_speedup": null, "speedup": 1.0162}, {"scope": "e2e", "hardware": "MI35X", "model": "DeepSeek-V4-Pro", "sh...
2.8475
1.0589
sglang
47cad39f345a28c4b70069c02c27d08b603c7aa7
2026-06-20T17:11:01+08:00
28,722
https://github.com/sgl-project/sglang/pull/28722
[AMD] Optimize o_proj gemm and attn output rope performance (#28722)
[AMD] Optimize o_proj gemm and attn output rope performance (#28722) Co-authored-by: wunhuang <wunhuang@amd.com>
python/sglang/srt/layers/deepseek_v4_rope.py
triton
Apache-2.0
import logging import math from functools import lru_cache from typing import Optional import torch import triton import triton.language as tl logger = logging.getLogger(__name__) # tilelang isn't shipped on every platform (e.g. Ascend NPU images) and the # only tilelang artifacts in this file are pass_configs that ...
import logging import math from functools import lru_cache from typing import Optional import torch import triton import triton.language as tl logger = logging.getLogger(__name__) # tilelang isn't shipped on every platform (e.g. Ascend NPU images) and the # only tilelang artifacts in this file are pass_configs that ...
--- python/sglang/srt/layers/deepseek_v4_rope.py +++ python/sglang/srt/layers/deepseek_v4_rope.py @@ -143,12 +143,209 @@ tl.store(x_ptr + offs_x_imag, out_imag, mask=mask) +@triton.jit +def apply_rotary_emb_triton_kernel_batched( + x_ptr, + freqs_ptr, + positions_ptr, + rope_dim, + n_tokens, + ...
197
0
2
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/deepseek_v4_rope.py). Goal: [AMD] Optimize o_proj gemm and attn output rope performance Target hardware: unspecified Target models: deepseek Current file: ```python import logging import math from functools import lru_cache from typing import Opti...
## Motivation 1. **The MLA output / q / kv projection w8a8-block FP8 GEMM uses the Triton kernel.** `apply_w8a8_block_fp8_linear` selects `triton_gemm_a8w8_blockscale` for the MLA projection shapes (they are in the hard-coded `use_aiter_triton_gemm_w8a8_tuned_gfx950` list). On gfx950 + HIP≥7.2 the CK bpreshuffle kerne...
[{"scope": "e2e", "hardware": "MI355X", "model": "DeepSeek-V4", "shape": null, "batch_size": 512, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 48291, "optimized": 52560, "stated_speedup": null, "speedup": 1.0884}, {"scope": "e2e", "hardware": "MI355X", "model": "DeepSeek-V4", "shape": ...
null
1.0692
sglang
c1067f88d6970562525d0385b80c7916aa8ea2a8
2026-06-19T05:16:52+07:00
27,793
https://github.com/sgl-project/sglang/pull/27793
[AMD][Perf] Tune extend attention block sizes for gfx950 (head_dim > 128) (#27793)
[AMD][Perf] Tune extend attention block sizes for gfx950 (head_dim > 128) (#27793)
python/sglang/srt/layers/attention/triton_ops/extend_attention.py
triton
Apache-2.0
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
--- python/sglang/srt/layers/attention/triton_ops/extend_attention.py +++ python/sglang/srt/layers/attention/triton_ops/extend_attention.py @@ -23,13 +23,14 @@ from sglang.srt.layers.attention.triton_ops.prefill_attention import ( context_attention_fwd, ) -from sglang.srt.utils import is_cuda, is_hip +from sglan...
13
3
1
[]
[ "GFX950" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_ops/extend_attention.py). Goal: [AMD][Perf] Tune extend attention block sizes for gfx950 (head_dim > 128) Target hardware: GFX950 Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed unde...
## Motivation While profiling long-context prefill on MI350X (Qwen3.5-style GQA models, head_dim 256), the Triton extend kernel turned out to be the dominant cost: about 62% of GPU time at roughly 28% MFU, far below what the memory system allows. The reason is that `_get_block_sizes_for_extend_attention` uses one har...
[{"scope": "kernel", "hardware": "MI350X", "model": null, "shape": "M=32768, prefix=67k", "batch\u6e38\u620f\u526f\u672c_size": null, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 137.2, "optimized": 87.5, "stated_speedup": null, "speedup": 1.568}, {"scope": "kernel", "hardware": "MI350X", "...
1.5851
1.3178
sglang
c80d8fe78ae22411d660c58dd4024fbfa2edb8f2
2026-06-13T00:01:53+08:00
27,896
https://github.com/sgl-project/sglang/pull/27896
[Perf] Skip per-call mat_a/scales_a padding in cutlass FP8 blockwise GEMM (#27896)
[Perf] Skip per-call mat_a/scales_a padding in cutlass FP8 blockwise GEMM (#27896) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/quantization/fp8_kernel.py
triton
Apache-2.0
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
--- python/sglang/srt/layers/quantization/fp8_kernel.py +++ python/sglang/srt/layers/quantization/fp8_kernel.py @@ -565,6 +565,59 @@ return x_q, x_s +def sglang_per_token_group_quant_fp8_row_padded( + x: torch.Tensor, + group_size: int, + eps: float = 1e-10, + row_alignment: int = 4, +) -> Tuple[to...
53
0
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: [Perf] Skip per-call mat_a/scales_a padding in cutlass FP8 blockwise GEMM Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache L...
## Summary The cutlass FP8 blockwise linear path (`cutlass_w8a8_block_fp8_linear_with_fallback`) quantizes the activation, then calls `fp8_blockwise_scaled_mm`, whose sgl-kernel wrapper pads `mat_a` and `scales_a` up to a multiple of 4 rows on every invocation. Each pad is a `torch.zeros` fill plus a `torch.cat`, so e...
[{"scope": "kernel", "hardware": "H20-3e", "model": "Qwen3.5-122B-A10B-FP8", "shape": null, "batch_size": null, "metric": "GPU time", "unit": "ms", "higher_is_better": false, "baseline": 69, "optimized": 0.4, "stated_speedup": null, "speedup": 172.5}, {"scope": "kernel", "hardware": "H20-3e", "model": "Qwen3.5-122B-A10...
149.8214
1.0206
sglang
f57f8a8afd845ca5f03e229f41d891b727890fd3
2026-06-06T14:14:25+08:00
26,588
https://github.com/sgl-project/sglang/pull/26588
Optimize Gemma4 H200 MoE and extend attention (#26588)
Optimize Gemma4 H200 MoE and extend attention (#26588) Co-authored-by: BBuf <xiaoyu.zhang@radixark.net>
python/sglang/srt/layers/attention/triton_ops/extend_attention.py
triton
Apache-2.0
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
--- python/sglang/srt/layers/attention/triton_ops/extend_attention.py +++ python/sglang/srt/layers/attention/triton_ops/extend_attention.py @@ -82,8 +82,10 @@ BLOCK_M, BLOCK_N = (16, 64) elif _is_cuda and CUDA_CAPABILITY[0] >= 9: # Hopper architecture (H100, etc.) - if ...
3
1
2
[ "gemma" ]
[ "H200" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_ops/extend_attention.py). Goal: Optimize Gemma4 H200 MoE and extend attention Target hardware: H200 Target models: gemma Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (t...
## Summary - Add H200 Triton fused MoE configs for Gemma4 `E=128,N=704` normal and down projections. - Tune Hopper extend-attention block sizes for `Lq=129..256` to reduce TTFT/TPOT on Gemma4 prefill-heavy serving. - Add a small-batch (M ≤ 256) per-head Triton kernel for Gemma4 QKV RMSNorm to lower MTP draft latency. ...
[{"scope": "e2e", "hardware": "NVIDIA H200", "model": "google/gemma-4-26B-A4B-it", "shape": null, "batch_size": 80, "metric": "output tok/s", "unit": "tok/s", "higher_is_better": true, "baseline": 1670.72, "optimized": 1725.5, "stated_speedup": 1.0328, "speedup": 1.0328}, {"scope": "e2e", "hardware": "NVIDIA H200", "mo...
null
1.1267
sglang
f57f8a8afd845ca5f03e229f41d891b727890fd3
2026-06-06T14:14:25+08:00
26,588
https://github.com/sgl-project/sglang/pull/26588
Optimize Gemma4 H200 MoE and extend attention (#26588)
Optimize Gemma4 H200 MoE and extend attention (#26588) Co-authored-by: BBuf <xiaoyu.zhang@radixark.net>
python/sglang/srt/layers/gemma4_fused_ops.py
triton
Apache-2.0
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ from typing import Optional import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual...
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ from typing import Optional import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual...
--- python/sglang/srt/layers/gemma4_fused_ops.py +++ python/sglang/srt/layers/gemma4_fused_ops.py @@ -133,6 +133,29 @@ @triton.jit +def _gemma_qkv_rmsnorm_store( + X_ptr, + W_ptr, + stride_m, + m, + h, + cols, + mask, + HEAD_DIM: tl.constexpr, + eps, + HAS_WEIGHT: tl.constexpr, +): + ...
107
35
2
[ "gemma" ]
[ "H200" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/gemma4_fused_ops.py). Goal: Optimize Gemma4 H200 MoE and extend attention Target hardware: H200 Target models: gemma Current file: ```python """Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ opt...
## Summary - Add H200 Triton fused MoE configs for Gemma4 `E=128,N=704` normal and down projections. - Tune Hopper extend-attention block sizes for `Lq=129..256` to reduce TTFT/TPOT on Gemma4 prefill-heavy serving. - Add a small-batch (M ≤ 256) per-head Triton kernel for Gemma4 QKV RMSNorm to lower MTP draft latency. ...
[{"scope": "e2e", "hardware": "NVIDIA H200", "model": "google/gemma-4-26B-A4B-it", "shape": null, "batch_size": 80, "metric": "output tok/s", "unit": "tok/s", "higher_is_better": true, "baseline": 1670.72, "optimized": 1725.5, "stated_speedup": 1.0328, "speedup": 1.0328}, {"scope": "e2e", "hardware": "NVIDIA H200", "mo...
null
1.1267
sglang
38ae22e08c73ae549245eebac229f6888089cc35
2026-06-05T22:31:46-07:00
26,733
https://github.com/sgl-project/sglang/pull/26733
Nemotron perf changes (#26733)
Nemotron perf changes (#26733) Co-authored-by: Brayden Zhong <brayden@radixark.ai>
python/sglang/srt/layers/attention/fla/layernorm_gated.py
triton
Apache-2.0
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
--- python/sglang/srt/layers/attention/fla/layernorm_gated.py +++ python/sglang/srt/layers/attention/fla/layernorm_gated.py @@ -14,6 +14,7 @@ import triton.language as tl from einops import rearrange +from sglang.jit_kernel.utils import is_arch_support_pdl from sglang.srt.server_args import get_global_server_args ...
10
0
9
[ "nemotron" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/layernorm_gated.py). Goal: Nemotron perf changes Target hardware: unspecified Target models: nemotron Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # C...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## TODOs: This PR aims to address the very obvious issues. T...
[{"scope": "e2e", "hardware": null, "model": "NVIDIA-Nemotron-3-Super-120B-A12B-BF16", "shape": null, "batch_size": 1, "metric": "throughput", "unit": "TPS", "higher_is_better": true, "baseline": 127.67, "optimized": 130.61, "stated_speedup": null, "speedup": 1.023}, {"scope": "e2e", "hardware": null, "model": "NVIDIA-...
null
1.0135
sglang
38ae22e08c73ae549245eebac229f6888089cc35
2026-06-05T22:31:46-07:00
26,733
https://github.com/sgl-project/sglang/pull/26733
Nemotron perf changes (#26733)
Nemotron perf changes (#26733) Co-authored-by: Brayden Zhong <brayden@radixark.ai>
python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py
triton
Apache-2.0
import logging from typing import Optional, Union import torch import triton import triton.language as tl from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.mamba.causal_conv1d_triton import PAD_SLOT_ID from sglang.srt.layers.attention.mamba.mamba import MambaM...
import logging from typing import Optional, Union import torch import triton import triton.language as tl from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.mamba.causal_conv1d_triton import PAD_SLOT_ID from sglang.srt.layers.attention.mamba.mamba import MambaM...
--- python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py +++ python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py @@ -710,7 +710,7 @@ self, mixer: MambaMixer2, hidden_states: torch.Tensor, - output: torch.Tensor, + output: Optional[torch.Tensor], ...
4
2
9
[ "nemotron" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py). Goal: Nemotron perf changes Target hardware: unspecified Target models: nemotron Current file: ```python import logging from typing import Optional, Union import torch import triton import triton.language...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## TODOs: This PR aims to address the very obvious issues. T...
[{"scope": "e2e", "hardware": null, "model": "NVIDIA-Nemotron-3-Super-120B-A12B-BF16", "shape": null, "batch_size": 1, "metric": "throughput", "unit": "TPS", "higher_is_better": true, "baseline": 127.67, "optimized": 130.61, "stated_speedup": null, "speedup": 1.023}, {"scope": "e2e", "hardware": null, "model": "NVIDIA-...
null
1.0135
sglang
38ae22e08c73ae549245eebac229f6888089cc35
2026-06-05T22:31:46-07:00
26,733
https://github.com/sgl-project/sglang/pull/26733
Nemotron perf changes (#26733)
Nemotron perf changes (#26733) Co-authored-by: Brayden Zhong <brayden@radixark.ai>
python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py
triton
Apache-2.0
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao. # Adapted from https://github.com/Dao-AILab/causal-conv1d/blob/main/causal_conv1d/causal_conv1d_interface.py # and https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/...
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao. # Adapted from https://github.com/Dao-AILab/causal-conv1d/blob/main/causal_conv1d/causal_conv1d_interface.py # and https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/...
--- python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py +++ python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py @@ -9,6 +9,8 @@ import torch import triton import triton.language as tl + +from sglang.jit_kernel.utils import is_arch_support_pdl PAD_SLOT_ID = -1 @@ -629,8 +631,12 @@ ...
12
0
9
[ "mamba", "nemotron" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py). Goal: Nemotron perf changes Target hardware: unspecified Target models: mamba, nemotron Current file: ```python # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## TODOs: This PR aims to address the very obvious issues. T...
[{"scope": "e2e", "hardware": null, "model": "NVIDIA-Nemotron-3-Super-120B-A12B-BF16", "shape": null, "batch_size": 1, "metric": "throughput", "unit": "TPS", "higher_is_better": true, "baseline": 127.67, "optimized": 130.61, "stated_speedup": null, "speedup": 1.023}, {"scope": "e2e", "hardware": null, "model": "NVIDIA-...
null
1.0135
sglang
38ae22e08c73ae549245eebac229f6888089cc35
2026-06-05T22:31:46-07:00
26,733
https://github.com/sgl-project/sglang/pull/26733
Nemotron perf changes (#26733)
Nemotron perf changes (#26733) Co-authored-by: Brayden Zhong <brayden@radixark.ai>
python/sglang/srt/layers/attention/mamba/ops/mamba_ssm.py
triton
Apache-2.0
# Adapted from: https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/mamba/ops/mamba_ssm.py # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao, Albert Gu. # Adapted from https://github.com/state-spaces/mamba/blo...
# Adapted from: https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/mamba/ops/mamba_ssm.py # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Copyright (c) 2024, Tri Dao, Albert Gu. # Adapted from https://github.com/state-spaces/mamba/blo...
--- python/sglang/srt/layers/attention/mamba/ops/mamba_ssm.py +++ python/sglang/srt/layers/attention/mamba/ops/mamba_ssm.py @@ -10,6 +10,8 @@ import triton import triton.language as tl from packaging import version + +from sglang.jit_kernel.utils import is_arch_support_pdl PAD_SLOT_ID = -1 @@ -141,7 +143,11 @@ ...
12
0
9
[ "mamba", "nemotron" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/mamba/ops/mamba_ssm.py). Goal: Nemotron perf changes Target hardware: unspecified Target models: mamba, nemotron Current file: ```python # Adapted from: https://github.com/vllm-project/vllm/tree/main/vllm/model_executor/layers/mamba/ops/...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## TODOs: This PR aims to address the very obvious issues. T...
[{"scope": "e2e", "hardware": null, "model": "NVIDIA-Nemotron-3-Super-120B-A12B-BF16", "shape": null, "batch_size": 1, "metric": "throughput", "unit": "TPS", "higher_is_better": true, "baseline": 127.67, "optimized": 130.61, "stated_speedup": null, "speedup": 1.023}, {"scope": "e2e", "hardware": null, "model": "NVIDIA-...
null
1.0135
sglang
bd47869ba4121ca18cf60acc946985a68bf75eb4
2026-06-04T22:11:43-07:00
27,320
https://github.com/sgl-project/sglang/pull/27320
[perf] parallelize create_flashmla_kv_indices over page-blocks (#27320)
[perf] parallelize create_flashmla_kv_indices over page-blocks (#27320)
python/sglang/srt/layers/attention/triton_ops/kv_indices.py
triton
Apache-2.0
import triton import triton.language as tl _FLASHMLA_CREATE_KV_BLOCK_SIZE = 4096 FLASHMLA_CREATE_KV_BLOCK_SIZE_TRITON = tl.constexpr(_FLASHMLA_CREATE_KV_BLOCK_SIZE) @triton.jit def create_flashinfer_kv_indices_triton( req_to_token_ptr, # [max_batch, max_context_len] req_pool_indices_ptr, page_kernel_len...
import triton import triton.language as tl _FLASHMLA_CREATE_KV_BLOCK_SIZE = 4096 FLASHMLA_CREATE_KV_BLOCK_SIZE_TRITON = tl.constexpr(_FLASHMLA_CREATE_KV_BLOCK_SIZE) @triton.jit def create_flashinfer_kv_indices_triton( req_to_token_ptr, # [max_batch, max_context_len] req_pool_indices_ptr, page_kernel_len...
--- python/sglang/srt/layers/attention/triton_ops/kv_indices.py +++ python/sglang/srt/layers/attention/triton_ops/kv_indices.py @@ -49,6 +49,15 @@ return num_page_per_block +def get_num_kv_index_blocks_flashmla(kv_indices_width: int, page_size: int) -> int: + """Grid axis-1 size for create_flashmla_kv_indic...
13
1
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_ops/kv_indices.py). Goal: [perf] parallelize create_flashmla_kv_indices over page-blocks Target hardware: unspecified Target models: unspecified Current file: ```python import triton import triton.language as tl _FLASHMLA_CREATE_...
Launch one CTA per page-block (grid axis 1) instead of a single CTA looping over every block, so building the kv-index page table scales with context length instead of serializing it (a large win at long context, where bs=1 left one CTA to walk the whole table). Add get_num_kv_index_blocks_flashmla to size grid axis 1...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 15, "optimized": 1.5, "stated_speedup": null, "speedup": 10.0}]
10
null
sglang
bd47869ba4121ca18cf60acc946985a68bf75eb4
2026-06-04T22:11:43-07:00
27,320
https://github.com/sgl-project/sglang/pull/27320
[perf] parallelize create_flashmla_kv_indices over page-blocks (#27320)
[perf] parallelize create_flashmla_kv_indices over page-blocks (#27320)
python/sglang/srt/layers/attention/trtllm_mla_backend.py
triton
Apache-2.0
from __future__ import annotations """ Support attention backend for TRTLLM MLA kernels from flashinfer. """ import logging import math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.jit_kernel.fixup_zero_kv imp...
from __future__ import annotations """ Support attention backend for TRTLLM MLA kernels from flashinfer. """ import logging import math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.jit_kernel.fixup_zero_kv imp...
--- python/sglang/srt/layers/attention/trtllm_mla_backend.py +++ python/sglang/srt/layers/attention/trtllm_mla_backend.py @@ -23,6 +23,7 @@ from sglang.srt.layers.attention.utils import ( concat_mla_absorb_q_general, create_flashmla_kv_indices_triton, + get_num_kv_index_blocks_flashmla, get_num_page_...
15
2
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/trtllm_mla_backend.py). Goal: [perf] parallelize create_flashmla_kv_indices over page-blocks Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations """ Support attention backen...
Launch one CTA per page-block (grid axis 1) instead of a single CTA looping over every block, so building the kv-index page table scales with context length instead of serializing it (a large win at long context, where bs=1 left one CTA to walk the whole table). Add get_num_kv_index_blocks_flashmla to size grid axis 1...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 15, "optimized": 1.5, "stated_speedup": null, "speedup": 10.0}]
10
null
sglang
3ea1ba5b1531daaaedd6ae55bb32a2a7fe0fd7b6
2026-06-02T16:48:31+08:00
26,206
https://github.com/sgl-project/sglang/pull/26206
[GDN] Optimize prefill QKV split dispatch (#26206)
[GDN] Optimize prefill QKV split dispatch (#26206) Co-authored-by: BBuf <xiaoyu.zhang@radixark.net>
python/sglang/srt/layers/attention/fla/chunk_delta_h.py
triton
Apache-2.0
# Adapted from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/common/chunk_delta_h.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.index im...
# Adapted from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/common/chunk_delta_h.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang import os from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.layers.attention.fl...
--- python/sglang/srt/layers/attention/fla/chunk_delta_h.py +++ python/sglang/srt/layers/attention/fla/chunk_delta_h.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang +import os from typing import Optional, Tuple import torch @@ -20,6 +21,9 @@ NUM_WARPS = [2, 4] if ...
14
2
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/chunk_delta_h.py). Goal: [GDN] Optimize prefill QKV split dispatch Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/com...
## Summary This patch reduces Qwen3.6 GDN prefill QKV split overhead observed during profiling: - add a Triton `fused_qkv_split_gdn_prefill_kernel` to split post-conv GDN Q/K/V into contiguous FLA prefill tensors in one launch; - route CUDA GDN prefill tensors, including strided post-conv views, through that fused sp...
[{"scope": "e2e", "hardware": "B200", "model": "Qwen/Qwen3.6-35B-A3B-FP8", "shape": null, "batch_size": null, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 7205.38, "optimized": 7396.73, "stated_speedup": null, "speedup": 1.0266}, {"scope": "e2e", "hardware": "B200", "model": "Qwen/Qwen...
1.8029
1.0262
sglang
5ae8d286d2b851a188aa753b46efc45e5322949e
2026-06-02T01:00:17-07:00
26,502
https://github.com/sgl-project/sglang/pull/26502
perf(gemma4): single-launch fused router (topk + softmax + scale) (#26502)
perf(gemma4): single-launch fused router (topk + softmax + scale) (#26502)
python/sglang/srt/layers/gemma4_fused_ops.py
triton
Apache-2.0
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ from typing import Optional import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual...
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ from typing import Optional import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual...
--- python/sglang/srt/layers/gemma4_fused_ops.py +++ python/sglang/srt/layers/gemma4_fused_ops.py @@ -283,3 +283,117 @@ BLOCK_SIZE=BLOCK_SIZE, ) return out + + +@triton.jit +def _gemma4_routing_kernel( + gating_ptr, # [T, E] router logits, any float dtype + per_expert_scale_ptr, # [E] per-exp...
114
0
1
[ "gemma" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/gemma4_fused_ops.py). Goal: perf(gemma4): single-launch fused router (topk + softmax + scale) Target hardware: unspecified Target models: gemma Current file: ```python """Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RM...
## Motivation `Gemma4MoE.routing_function` emits four per-layer GPU kernels for every MoE forward pass (one decode step touches ~30 routed-MoE layers): | Kernel | Decode share (Gemma-4-26B-A4B-IT + MTP, B200) | |---|---| | `at::native::sbtopk::gatherTopK<bf16,uint,2,false>` (torch.topk) | 2.4% | | `at::native::bitoni...
[{"scope": "e2e", "hardware": "B200", "model": "Gemma-4-26B-A4B-IT", "shape": null, "batch_size": null, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 2729.3, "optimized": 2880.94, "stated_speedup": null, "speedup": 1.0556}, {"scope": "e2e", "hardware": "B200", "model": "Gemma-4-26B-A4B-...
null
1.0447
sglang
deaba74745d7f98485211ce8db406ecefb63512d
2026-05-28T06:23:35+08:00
26,383
https://github.com/sgl-project/sglang/pull/26383
[AMD][DSV4] DSV4 MTP graph + sparse triton attn optimizations (#26383)
[AMD][DSV4] DSV4 MTP graph + sparse triton attn optimizations (#26383) Co-authored-by: wunhuang <wunhuang@amd.com> Co-authored-by: Thomas Wang <1am9trash@gmail.com> Co-authored-by: Xinyi Song <86638975+RolaoDenthu@users.noreply.github.com> Co-authored-by: HaiShaw <hixiao@gmail.com> Co-authored-by: amd-danli103 <danli1...
python/sglang/srt/layers/attention/nsa/triton_decode/triton_mla_kernels_decode_fused.py
triton
Apache-2.0
""" Fused Gather+Dequant+Attention Kernel for DSV4 (d_qk=512) This module implements a fused kernel that combines: 1. Gather: Load KV from sparse indices 2. Dequant: FP8 to BF16 dequantization 3. Attention: Compute attention scores and output Benefits for workloads without extra scope: - Eliminates intermediate buffe...
""" Fused Gather+Dequant+Attention Kernel for DSV4 (d_qk=512) This module implements a fused kernel that combines: 1. Gather: Load KV from sparse indices 2. Dequant: FP8 to BF16 dequantization 3. Attention: Compute attention scores and output Benefits for workloads without extra scope: - Eliminates intermediate buffe...
--- python/sglang/srt/layers/attention/nsa/triton_decode/triton_mla_kernels_decode_fused.py +++ python/sglang/srt/layers/attention/nsa/triton_decode/triton_mla_kernels_decode_fused.py @@ -1208,6 +1208,9 @@ triton.Config({"BLOCK_H": 64, "BLOCK_N": 128}, num_warps=4, num_stages=1), triton.Config({"BLOCK...
12
1
4
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/nsa/triton_decode/triton_mla_kernels_decode_fused.py). Goal: [AMD][DSV4] DSV4 MTP graph + sparse triton attn optimizations Target hardware: unspecified Target models: deepseek Current file: ```python """ Fused Gather+Dequant+Attention Ke...
Co-authored-by: @1am9trash @RolaoDenthu @yichiche @hubertlu-tw @sogalin @HaiShaw @yctseng0211 @bingxche @amd-danli103 @Raiden-Makoto ## Motivation The long-standing draft #25552 collected 85 commits of AMD / DSV4 work over several rebases. Most of the optimization PRs it tracked (compressor opts, fused topk, sparse M...
[]
null
null
sglang
e27d4fb70f33d6a86533a5dc3e14114c480b4d2f
2026-05-25T16:08:21+08:00
25,775
https://github.com/sgl-project/sglang/pull/25775
[Perf][Qwen3.5] Add case 512 to topkGatingSoftmaxKernelLauncher, (#25775)
[Perf][Qwen3.5] Add case 512 to topkGatingSoftmaxKernelLauncher, (#25775)
sgl-kernel/csrc/moe/moe_topk_softmax_kernels.cu
cuda
Apache-2.0
// Adapt from https://github.com/vllm-project/vllm/blob/v0.7.3/csrc/moe/topk_softmax_kernels.cu // which is originally adapted from // https://github.com/NVIDIA/TensorRT-LLM/blob/v0.7.1/cpp/tensorrt_llm/kernels/mixtureOfExperts/moe_kernels.cu /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apach...
// Adapt from https://github.com/vllm-project/vllm/blob/v0.7.3/csrc/moe/topk_softmax_kernels.cu // which is originally adapted from // https://github.com/NVIDIA/TensorRT-LLM/blob/v0.7.1/cpp/tensorrt_llm/kernels/mixtureOfExperts/moe_kernels.cu /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apach...
--- sgl-kernel/csrc/moe/moe_topk_softmax_kernels.cu +++ sgl-kernel/csrc/moe/moe_topk_softmax_kernels.cu @@ -696,6 +696,9 @@ case 256: LAUNCH_SOFTMAX(T, 256, WARPS_PER_TB); break; + case 512: + LAUNCH_SOFTMAX(T, 512, WARPS_PER_TB); + break; default: { TORCH_CHECK( s...
4
1
1
[ "qwen" ]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/moe_topk_softmax_kernels.cu). Goal: [Perf][Qwen3.5] Add case 512 to topkGatingSoftmaxKernelLauncher, Target hardware: unspecified Target models: qwen Current file: ```cuda // Adapt from https://github.com/vllm-project/vllm/blob/v0.7.3/csrc/moe/topk_softm...
## Motivation <!-- Describe the purpose and goals of this pull request. --> ## Modifications Add case 512 to topkGatingSoftmaxKernelLauncher, enabling the fused single-kernel path for models with 512 experts (e.g. Qwen3.5-397B-A17B). ## Accuracy Tests <!-- If this pull request affects model outputs (e.g., changes t...
[{"scope": "kernel", "hardware": "H200", "model": "Qwen3.5-397B-A17B", "shape": "num_experts=512,topk=10,dtype=bf16", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 18.63, "optimized": 10.39, "stated_speedup": 1.79, "speedup": 1.7931}, {"scope": "kernel", "hardware": "H200", ...
1.8183
1.0144
sglang
ec6fcb93cb8b100e26db2bcf6a43613e9b05c7d1
2026-05-24T21:36:16-07:00
26,241
https://github.com/sgl-project/sglang/pull/26241
[perf][spec decoding] Skip common_template in TRTLLMMLAMultiStepDraftBackend init (#26241)
[perf][spec decoding] Skip common_template in TRTLLMMLAMultiStepDraftBackend init (#26241)
python/sglang/srt/layers/attention/trtllm_mla_backend.py
triton
Apache-2.0
from __future__ import annotations """ Support attention backend for TRTLLM MLA kernels from flashinfer. """ import logging import math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.jit_kernel.fixup_zero_kv imp...
from __future__ import annotations """ Support attention backend for TRTLLM MLA kernels from flashinfer. """ import logging import math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.jit_kernel.fixup_zero_kv imp...
--- python/sglang/srt/layers/attention/trtllm_mla_backend.py +++ python/sglang/srt/layers/attention/trtllm_mla_backend.py @@ -1235,3 +1235,22 @@ kv_indptr_buf=self.kv_indptr[i], q_indptr_decode_buf=self.q_indptr_decode, ) + + def init_forward_metadata(self, forward_batc...
19
0
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/trtllm_mla_backend.py). Goal: [perf][spec decoding] Skip common_template in TRTLLMMLAMultiStepDraftBackend init Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations """ Suppo...
`FlashInferMLAMultiStepDraftBackend.{init_forward_metadata, init_forward_metadata_replay_cuda_graph}` go through `common_template`, which launches the `generate_draft_decode_kv_indices` triton kernel and slices `spec_info.kv_indptr/kv_indices` for each draft step. Both are unnecessary for the trtllm_mla path used by EA...
[{"scope": "e2e", "hardware": "Kimi-K2.5-NVFP4", "model": null, "shape": "TP=4, 80K ctx, EAGLE3 3-step, topk=1", "batch_size": null, "metric": "Mean TPOT", "unit": "ms", "higher_is_better": false, "baseline": 2.47, "optimized": 2.41, "stated_speedup": null, "speedup": 1.0249}, {"scope": "e2e", "hardware": "Kimi-K2.5-NV...
null
1.025
sglang
821d5f4a5b2550bd6a9fa60fded40568d2c7344c
2026-05-25T10:28:52+08:00
25,874
https://github.com/sgl-project/sglang/pull/25874
[CPU] add faster KV-cache writes (#25874)
[CPU] add faster KV-cache writes (#25874)
sgl-kernel/csrc/cpu/common.h
cpp
Apache-2.0
#pragma once #include <ATen/ATen.h> #include <ATen/Parallel.h> #if defined(_OPENMP) #include <omp.h> #endif namespace { // dispatch bool #define AT_DISPATCH_BOOL(BOOL_V, BOOL_NAME, ...) \ [&] { \ if (BOOL_V) { \ constexpr bool BOOL_...
#pragma once #include <ATen/ATen.h> #include <ATen/Dispatch.h> #include <ATen/Parallel.h> #if defined(_OPENMP) #include <omp.h> #endif namespace { // dispatch bool #define AT_DISPATCH_BOOL(BOOL_V, BOOL_NAME, ...) \ [&] { \ if (BOOL_V) { \...
--- sgl-kernel/csrc/cpu/common.h +++ sgl-kernel/csrc/cpu/common.h @@ -1,6 +1,7 @@ #pragma once #include <ATen/ATen.h> +#include <ATen/Dispatch.h> #include <ATen/Parallel.h> #if defined(_OPENMP) @@ -43,6 +44,14 @@ } \ } ...
9
0
2
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/common.h). Goal: [CPU] add faster KV-cache writes Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #include <ATen/ATen.h> #include <ATen/Parallel.h> #if defined(_OPENMP) #include <omp.h> #endif namespace { // dispatch ...
## Motivation Faster KV-cache writes on CPU: replace slow `index_put_` scatter for MHA with a dedicated row-copy kernel, matching the CUDA `store_cache` idea. ## Modifications - **sgl-kernel**: Add `store_cache_cpu` (OpenMP parallel row copy); 3D tensors `[B, H, D]`; `int32`/`int64` indices; dtypes `fp16`, `bf16`, `...
[]
null
null
sglang
821d5f4a5b2550bd6a9fa60fded40568d2c7344c
2026-05-25T10:28:52+08:00
25,874
https://github.com/sgl-project/sglang/pull/25874
[CPU] add faster KV-cache writes (#25874)
[CPU] add faster KV-cache writes (#25874)
sgl-kernel/csrc/cpu/torch_extension_cpu.cpp
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/cpu/torch_extension_cpu.cpp +++ sgl-kernel/csrc/cpu/torch_extension_cpu.cpp @@ -410,6 +410,15 @@ bool disable_grouping, at::ScalarType out_dtype); +// kvcache +void store_cache_cpu( + const at::Tensor& k, + const at::Tensor& v, + const at::Tensor& k_cache, + const at::Tensor&...
15
0
2
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: [CPU] add faster KV-cache writes Target hardware: CPU Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you ...
## Motivation Faster KV-cache writes on CPU: replace slow `index_put_` scatter for MHA with a dedicated row-copy kernel, matching the CUDA `store_cache` idea. ## Modifications - **sgl-kernel**: Add `store_cache_cpu` (OpenMP parallel row copy); 3D tensors `[B, H, D]`; `int32`/`int64` indices; dtypes `fp16`, `bf16`, `...
[]
null
null
sglang
ff70aeac3051b5f85559f382d0622716831895c8
2026-05-14T00:57:46+08:00
24,491
https://github.com/sgl-project/sglang/pull/24491
[diffusion] feat: add performance mode server args (#24491)
[diffusion] feat: add performance mode server args (#24491)
python/sglang/srt/layers/attention/triton_ops/rocm_mla_decode_rope.py
triton
Apache-2.0
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
# Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
--- python/sglang/srt/layers/attention/triton_ops/rocm_mla_decode_rope.py +++ python/sglang/srt/layers/attention/triton_ops/rocm_mla_decode_rope.py @@ -395,7 +395,7 @@ IS_NEOX_STYLE=is_neox_style, num_warps=4, num_stages=num_stages, - **extra_kargs + **extra_kargs, )
1
1
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_ops/rocm_mla_decode_rope.py). Goal: [diffusion] feat: add performance mode server args Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Apache L...
## Summary - Add `--performance-mode` / `--mode` for diffusion server defaults: `auto`, `throughput`, `memory`, and `balanced`, with `aggressive`, `conservative`, and `balance` aliases. - Auto-select FSDP+CFG only for high-confidence multi-GPU Qwen/Wan CFG cases, gated by the least available memory across selected GPU...
[]
null
null
sglang
bfc2eda42d478affdce6dbc642f5b14cd17164fb
2026-05-12T08:55:27+08:00
23,633
https://github.com/sgl-project/sglang/pull/23633
[MUSA] Use MUSA-optimized operators in piecewise CUDA graph (#23633)
[MUSA] Use MUSA-optimized operators in piecewise CUDA graph (#23633) Signed-off-by: popsiclexu <zhenxuexu@gmail.com>
python/sglang/srt/layers/quantization/fp8_kernel.py
triton
Apache-2.0
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
--- python/sglang/srt/layers/quantization/fp8_kernel.py +++ python/sglang/srt/layers/quantization/fp8_kernel.py @@ -93,6 +93,24 @@ except ImportError: # Fallback: vllm not available, will use native PyTorch implementation _has_vllm = False + +if _is_musa: + + @register_fake_if_exis...
18
0
4
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: [MUSA] Use MUSA-optimized operators in piecewise CUDA graph Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, Versio...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation MUSA devices previously could not use piecewis...
[]
null
null
sglang
d3fd91ed9726cc87d3f2e67e758202d3982cde32
2026-05-10T15:24:12+08:00
24,696
https://github.com/sgl-project/sglang/pull/24696
[Gemma4] Optimize Gemm4 with fused Q/K/V RMSNorm + per-expert FP8 ckpt loader (#24696)
[Gemma4] Optimize Gemm4 with fused Q/K/V RMSNorm + per-expert FP8 ckpt loader (#24696) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/gemma4_fused_ops.py
triton
Apache-2.0
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual_kernel( X_ptr, W_ptr...
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ from typing import Optional import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual...
--- python/sglang/srt/layers/gemma4_fused_ops.py +++ python/sglang/srt/layers/gemma4_fused_ops.py @@ -3,6 +3,8 @@ Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ + +from typing import Optional import torch import triton @@ -130,6 ...
115
0
1
[ "gemma" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/gemma4_fused_ops.py). Goal: [Gemma4] Optimize Gemm4 with fused Q/K/V RMSNorm + per-expert FP8 ckpt loader Target hardware: unspecified Target models: gemma Current file: ```python """Fused triton kernels for Gemma4 decoder layer operations. Fuses...
## Motivation The original motivation is to speedup Gemm4 model. Two unrelated issues on the Gemma4 FP8-MoE path: 1. **Attention RMSNorm is launch-bound.** Each Gemma4 attention layer issues three separate sgl-kernel `rmsnorm` launches (q/k/v). At small token counts the per-launch host overhead dominates — three back...
[{"scope": "kernel", "hardware": "H100", "model": null, "shape": "Q=8h,KV=2h,head_dim=128", "batch_size": 1, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 44.4, "optimized": 19.8, "stated_speedup": 2.25, "speedup": 2.2424}, {"scope": "kernel", "hardware": "H100", "model": null, "shape": "Q=8...
2.9189
1.0077
sglang
a61a14f416c4003809a82112b4a591eec38a0a10
2026-05-09T08:52:51+08:00
24,271
https://github.com/sgl-project/sglang/pull/24271
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271)
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/attention/fla/chunk_delta_h.py
triton
Apache-2.0
# Adapted from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/common/chunk_delta_h.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.index im...
# Adapted from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/common/chunk_delta_h.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.index im...
--- python/sglang/srt/layers/attention/fla/chunk_delta_h.py +++ python/sglang/srt/layers/attention/fla/chunk_delta_h.py @@ -13,22 +13,30 @@ prepare_chunk_offsets, ) from sglang.srt.layers.attention.fla.op import exp, safe_exp -from sglang.srt.layers.attention.fla.utils import is_nvidia_hopper +from sglang.srt.la...
21
14
4
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/chunk_delta_h.py). Goal: [KDA] Optimize prefill kernels with diagonal and recompute fuse Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted from https://github.com/fla-org/flash-linear-attention...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A3B-Instruct", "shape": "B=1,T=8192", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 5.0, "optimized": 3.3, "stated_speedup": null, "speedup": 1.5152}, {"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A...
1.3088
1.1744
sglang
a61a14f416c4003809a82112b4a591eec38a0a10
2026-05-09T08:52:51+08:00
24,271
https://github.com/sgl-project/sglang/pull/24271
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271)
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/attention/fla/chunk_intra.py
triton
Apache-2.0
# Adapted from flash-linear-attention project. # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.chunk_intra_token_parallel import ( chunk_kda_fwd_intra_token_parallel, ) from sglang.srt.layers.attention.fla.index import ...
# Adapted from flash-linear-attention project. # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.chunk_intra_token_parallel import ( chunk_kda_fwd_intra_token_parallel, ) from sglang.srt.layers.attention.fla.index import ...
--- python/sglang/srt/layers/attention/fla/chunk_intra.py +++ python/sglang/srt/layers/attention/fla/chunk_intra.py @@ -11,7 +11,7 @@ from sglang.srt.layers.attention.fla.index import ( prepare_chunk_indices, ) -from sglang.srt.layers.attention.fla.op import exp2, gather +from sglang.srt.layers.attention.fla.op ...
495
104
4
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/chunk_intra.py). Goal: [KDA] Optimize prefill kernels with diagonal and recompute fuse Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted from flash-linear-attention project. # Copyright (c) 202...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A3B-Instruct", "shape": "B=1,T=8192", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 5.0, "optimized": 3.3, "stated_speedup": null, "speedup": 1.5152}, {"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A...
1.3088
1.1744
sglang
a61a14f416c4003809a82112b4a591eec38a0a10
2026-05-09T08:52:51+08:00
24,271
https://github.com/sgl-project/sglang/pull/24271
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271)
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/attention/fla/cumsum.py
triton
Apache-2.0
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/utils/cumsum.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.index import prepare_chun...
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/utils/cumsum.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.index import prepare_chun...
--- python/sglang/srt/layers/attention/fla/cumsum.py +++ python/sglang/srt/layers/attention/fla/cumsum.py @@ -70,9 +70,10 @@ @triton.autotune( configs=[ - triton.Config({"BS": BS}, num_warps=num_warps) + triton.Config({"BS": BS}, num_warps=num_warps, num_stages=num_stages) for BS in BS_LI...
2
1
4
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/cumsum.py). Goal: [KDA] Optimize prefill kernels with diagonal and recompute fuse Target hardware: unspecified Target models: unspecified Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/mai...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A3B-Instruct", "shape": "B=1,T=8192", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 5.0, "optimized": 3.3, "stated_speedup": null, "speedup": 1.5152}, {"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A...
1.3088
1.1744
sglang
a61a14f416c4003809a82112b4a591eec38a0a10
2026-05-09T08:52:51+08:00
24,271
https://github.com/sgl-project/sglang/pull/24271
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271)
[KDA] Optimize prefill kernels with diagonal and recompute fuse (#24271) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/attention/fla/kda.py
triton
Apache-2.0
# Adapted from https://github.com/vllm-project/vllm/blob/0384aa7150c4c9778efca041ffd1beb3ad2bd694/vllm/model_executor/layers/fla/ops/kda.py # This file contains code copied from the flash-linear-attention project. # The original source code was licensed under the MIT license and included # the following copyright notic...
# Adapted from https://github.com/vllm-project/vllm/blob/0384aa7150c4c9778efca041ffd1beb3ad2bd694/vllm/model_executor/layers/fla/ops/kda.py # This file contains code copied from the flash-linear-attention project. # The original source code was licensed under the MIT license and included # the following copyright notic...
--- python/sglang/srt/layers/attention/fla/kda.py +++ python/sglang/srt/layers/attention/fla/kda.py @@ -17,10 +17,14 @@ from sglang.srt.layers.attention.fla.fused_recurrent import ( fused_recurrent_gated_delta_rule_fwd_kernel, ) -from sglang.srt.layers.attention.fla.index import prepare_chunk_indices +from sglan...
36
14
4
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/kda.py). Goal: [KDA] Optimize prefill kernels with diagonal and recompute fuse Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted from https://github.com/vllm-project/vllm/blob/0384aa7150c4c9778...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A3B-Instruct", "shape": "B=1,T=8192", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 5.0, "optimized": 3.3, "stated_speedup": null, "speedup": 1.5152}, {"scope": "e2e", "hardware": null, "model": "Kimi-Linear-48B-A...
1.3088
1.1744
sglang
15e6572f21980e906c568fa82f9677edec601eaa
2026-05-08T11:38:33+08:00
23,255
https://github.com/sgl-project/sglang/pull/23255
[MUSA][18/N] Add MUSA-optimized kernel implementations for hot ops (#23255)
[MUSA][18/N] Add MUSA-optimized kernel implementations for hot ops (#23255) Signed-off-by: Joey-gvwal <joey_gvwal@yeah.net> Co-authored-by: R0CKSTAR <yeahdongcn@gmail.com>
sgl-kernel/csrc/common_extension_musa.cc
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/common_extension_musa.cc +++ sgl-kernel/csrc/common_extension_musa.cc @@ -72,6 +72,12 @@ m.def("concat_mla_k(Tensor! k, Tensor k_nope, Tensor k_rope) -> ()"); m.impl("concat_mla_k", torch::kMUSA, &concat_mla_k); + m.def( + "rotary_embedding(Tensor positions, Tensor! query," + " ...
42
0
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension_musa.cc). Goal: [MUSA][18/N] Add MUSA-optimized kernel implementations for hot ops Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Lic...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation This PR continues the ongoing effort (tracked...
[]
null
null
sglang
15e6572f21980e906c568fa82f9677edec601eaa
2026-05-08T11:38:33+08:00
23,255
https://github.com/sgl-project/sglang/pull/23255
[MUSA][18/N] Add MUSA-optimized kernel implementations for hot ops (#23255)
[MUSA][18/N] Add MUSA-optimized kernel implementations for hot ops (#23255) Signed-off-by: Joey-gvwal <joey_gvwal@yeah.net> Co-authored-by: R0CKSTAR <yeahdongcn@gmail.com>
sgl-kernel/include/sgl_kernel_ops.h
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/include/sgl_kernel_ops.h +++ sgl-kernel/include/sgl_kernel_ops.h @@ -26,6 +26,10 @@ #include <vector> #include "scalar_type.hpp" + +#ifdef USE_MUSA +#include "sgl_kernel_musa_ops.h" +#endif #define _CONCAT(A, B) A##B #define CONCAT(A, B) _CONCAT(A, B)
4
0
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [MUSA][18/N] Add MUSA-optimized kernel implementations for hot ops Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License,...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation This PR continues the ongoing effort (tracked...
[]
null
null
sglang
e5c58eb9d627421236f78053137562b97c14984e
2026-05-05T00:36:26+08:00
24,048
https://github.com/sgl-project/sglang/pull/24048
[VLM] Optimize Gemma4 VLM with PCG and fuse RMSNorm + residual add + scalar (#24048)
[VLM] Optimize Gemma4 VLM with PCG and fuse RMSNorm + residual add + scalar (#24048) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/gemma4_fused_ops.py
triton
Apache-2.0
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual_kernel( X_ptr, W_ptr...
"""Fused triton kernels for Gemma4 decoder layer operations. Fuses standard RMSNorm + residual-add (+ optional scalar multiply) into a single kernel pass to reduce kernel launch overhead. """ import torch import triton import triton.language as tl @triton.jit def _gemma_rmsnorm_residual_kernel( X_ptr, W_ptr...
--- python/sglang/srt/layers/gemma4_fused_ops.py +++ python/sglang/srt/layers/gemma4_fused_ops.py @@ -77,3 +77,94 @@ BLOCK_SIZE=BLOCK_SIZE, ) return out + + +@triton.jit +def _gemma_dual_rmsnorm_residual_kernel( + X1_ptr, + W1_ptr, + X2_ptr, + W2_ptr, + W3_ptr, + Residual_ptr, + ...
91
0
1
[ "gemma", "llava/vlm" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/gemma4_fused_ops.py). Goal: [VLM] Optimize Gemma4 VLM with PCG and fuse RMSNorm + residual add + scalar Target hardware: unspecified Target models: gemma, llava/vlm Current file: ```python """Fused triton kernels for Gemma4 decoder layer operation...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "Gemma4", "shape": null, "batch_size": 93, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 35.6, "optimized": 16.5, "stated_speedup": null, "speedup": 2.1576}, {"scope": "e2e", "hardware": null, "model": "Gemma4", "shape": null, "batch_size": 189, "...
null
1.3865
sglang
587fd15bd272d03f78dcc58a3e771a88d0c40f64
2026-04-24T12:05:16-07:00
21,985
https://github.com/sgl-project/sglang/pull/21985
perf: eliminate attention DtoD copy by passing pre-allocated output to FA (#21985)
perf: eliminate attention DtoD copy by passing pre-allocated output to FA (#21985) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
sgl-kernel/csrc/flash_extension.cc
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/flash_extension.cc +++ sgl-kernel/csrc/flash_extension.cc @@ -29,7 +29,7 @@ " Tensor? k_new," // (b, s_k_new, h_k, d) or (total_k_new, h_k, d) " Tensor? v_new," // (b, s_k_new, h_k, dv) or (total_k_new, h_k, dv) " Tensor? q_v," /...
2
2
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/flash_extension.cc). Goal: perf: eliminate attention DtoD copy by passing pre-allocated output to FA Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Li...
## Summary Eliminate a ~14µs DtoD memcpy per decoder layer by passing the pre-allocated output tensor directly to Flash Attention, rather than letting FA allocate internally and then copying. ### Root Cause `unified_attention_with_output` pre-allocates an output tensor, calls `attn_backend.forward()` which invokes F...
[{"scope": "e2e", "hardware": "H200", "model": "Qwen3-0.6B FP8", "shape": null, "batch_size": null, "metric": "throughput", "unit": "items/sec", "higher_is_better": true, "baseline": 30.77, "optimized": 37.83, "stated_speedup": null, "speedup": 1.2294}, {"scope": "e2e", "hardware": "H200", "model": "Qwen3-0.6B FP8", "s...
6.6
1.122
sglang
b2af34be5404c3ca8f69642ea464470901871711
2026-04-14T23:50:32-07:00
22,844
https://github.com/sgl-project/sglang/pull/22844
[AMD] Optimize _append_shared_to_topk_output by a single fused Triton kernel for Qwen3.5 (#22844)
[AMD] Optimize _append_shared_to_topk_output by a single fused Triton kernel for Qwen3.5 (#22844) Co-authored-by: HaiShaw <hixiao@gmail.com>
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py
triton
Apache-2.0
from __future__ import annotations import functools from collections import OrderedDict from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.batch_invariant_ops import is_batch_invariant_mode_enabled from sglang.srt.layers.moe.utils import get_moe_paddi...
from __future__ import annotations import functools from collections import OrderedDict from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.batch_invariant_ops import is_batch_invariant_mode_enabled from sglang.srt.layers.moe.utils import get_moe_paddi...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py @@ -1194,3 +1194,79 @@ num_warps=1, ) return out_ids, out_weights + + +@triton.jit +def _fused_append_shared_experts_with_weights_kernel( + to...
76
0
1
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py). Goal: [AMD] Optimize _append_shared_to_topk_output by a single fused Triton kernel for Qwen3.5 Target hardware: unspecified Target models: qwen Current file: ```python from __future__ import annot...
## Motivation - `_append_shared_to_topk_output` previously used 4 separate kernel launches (2 elementwise + 2 concat) to append shared expert IDs and weights. - This path is on the critical MoE routing path and adds avoidable launch overhead. - Qwen3.5 requires per-token shared weights from learned `shared_expert_gate...
[{"scope": "e2e", "hardware": null, "model": "Qwen3.5", "shape": "ilen=8192,olen=8192", "batch_size": 4, "metric": "TTT", "unit": "tok/s", "higher_is_better": true, "baseline": 834.29, "optimized": 868.99, "stated_speedup": null, "speedup": 1.0416}, {"scope": "e2e", "hardware": null, "model": "Qwen3.5", "shape": "ilen=...
null
1.0195
sglang
18f41ac427461b75ba769d8589196fe2a9a2fcb5
2026-04-10T14:56:05+08:00
22,316
https://github.com/sgl-project/sglang/pull/22316
[Reland] DeepSeek-R1-0528-w4a8: DeepEP Low Latency Dispatch Adopts FP8 Communication (#22316)
[Reland] DeepSeek-R1-0528-w4a8: DeepEP Low Latency Dispatch Adopts FP8 Communication (#22316) Co-authored-by: undefined <zhouchen.arrebol@jd.com> Co-authored-by: xq25478 <xq25478@qq.com>
python/sglang/srt/layers/moe/ep_moe/kernels.py
triton
Apache-2.0
import logging import torch import triton from sglang.srt.utils import ceil_div, is_cuda logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _is_cuda: from sglang.srt.layers.quantization.fp8_kernel import ( sglang_per_token_group_quant_fp8 as per_token_group_quant_fp8, ) import triton.lang...
import logging import torch import triton from sglang.srt.utils import ceil_div, is_cuda logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _is_cuda: from sglang.srt.layers.quantization.fp8_kernel import ( sglang_per_token_group_quant_fp8 as per_token_group_quant_fp8, ) import triton.lang...
--- python/sglang/srt/layers/moe/ep_moe/kernels.py +++ python/sglang/srt/layers/moe/ep_moe/kernels.py @@ -1381,3 +1381,76 @@ NUM_STAGE=NUM_STAGES, ) return output + + +@triton.jit +def _fp8_per_token_quant_to_per_tensor_quant_kernel( + x_ptr, + x_scale_ptr, + x_scale_stride0, + x_scale_st...
73
0
5
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: [Reland] DeepSeek-R1-0528-w4a8: DeepEP Low Latency Dispatch Adopts FP8 Communication Target hardware: unspecified Target models: deepseek Current file: ```python import logging import torch import triton from sglang...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": "H20", "model": "DeepSeek-R1-0528-W4AFP8", "shape": null, "batch_size": null, "metric": "throughput", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.1, "speedup": 1.1}]
null
1.1
sglang
7119d5974798d157bc3a16cc9074e84c2b9c4c9a
2026-03-30T22:27:28+08:00
14,162
https://github.com/sgl-project/sglang/pull/14162
DeepSeek-R1-0528-w4a8: DeepEP Low Latency Dispatch Adopts FP8 Communication (#14162)
DeepSeek-R1-0528-w4a8: DeepEP Low Latency Dispatch Adopts FP8 Communication (#14162) Co-authored-by: undefined <zhouchen.arrebol@jd.com>
python/sglang/srt/layers/moe/ep_moe/kernels.py
triton
Apache-2.0
import logging import torch import triton from sglang.srt.utils import ceil_div, is_cuda logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _is_cuda: from sglang.srt.layers.quantization.fp8_kernel import ( sglang_per_token_group_quant_fp8 as per_token_group_quant_fp8, ) import triton.lang...
import logging import torch import triton from sglang.srt.utils import ceil_div, is_cuda logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _is_cuda: from sglang.srt.layers.quantization.fp8_kernel import ( sglang_per_token_group_quant_fp8 as per_token_group_quant_fp8, ) import triton.lang...
--- python/sglang/srt/layers/moe/ep_moe/kernels.py +++ python/sglang/srt/layers/moe/ep_moe/kernels.py @@ -1381,3 +1381,76 @@ NUM_STAGE=NUM_STAGES, ) return output + + +@triton.jit +def _fp8_per_token_quant_to_per_tensor_quant_kernel( + x_ptr, + x_scale_ptr, + x_scale_stride0, + x_scale_st...
73
0
5
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: DeepSeek-R1-0528-w4a8: DeepEP Low Latency Dispatch Adopts FP8 Communication Target hardware: unspecified Target models: deepseek Current file: ```python import logging import torch import triton from sglang.srt.util...
## Motivation profiling: deepseek-R1-0528: <img width="3170" height="510" alt="ME1764483666809" src="https://github.com/user-attachments/assets/d2a2c921-7c41-4308-8420-a75bdf40cb83" /> deepseek-R1-0528-w4afp8: <img width="3092" height="576" alt="ME1764483641467" src="https://github.com/user-attachments/assets/6489b43...
[{"scope": "e2e", "hardware": "H20", "model": "DeepSeek-R1-0528-W4AFP8", "shape": null, "batch_size": null, "metric": "throughput", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.1, "speedup": 1.1}]
null
1.1
sglang
6da8f5f69e0f74fa4555234f8bd016b092af9592
2026-03-30T14:43:16+08:00
14,702
https://github.com/sgl-project/sglang/pull/14702
fix topk softmax performance issue (#14702)
fix topk softmax performance issue (#14702)
sgl-kernel/csrc/cpu/topk.cpp
cpp
Apache-2.0
#include "common.h" #include "vec.h" namespace { template <typename scalar_t, int SIZE> inline void softmax(float* __restrict__ out, const scalar_t* __restrict__ input) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::size(); // step 1: ge...
#include "common.h" #include "vec.h" namespace { template <typename scalar_t, int SIZE> inline void softmax(float* __restrict__ out, const scalar_t* __restrict__ input) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::size(); // step 1: ge...
--- sgl-kernel/csrc/cpu/topk.cpp +++ sgl-kernel/csrc/cpu/topk.cpp @@ -227,11 +227,9 @@ queue[e] = {scores[e], e}; } - std::partial_sort( - queue.begin(), - queue.begin() + num_experts_per_group, - queue.end(), - [](const elem_t& x, const elem_t& y) -> bool { re...
3
5
1
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/topk.cpp). Goal: fix topk softmax performance issue Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "vec.h" namespace { template <typename scalar_t, int SIZE> inline void softmax(float* __restrict__ out,...
This is a minor change to fix performance issue of topk softmax. orginal code uses full sort but we only need topk. ## Checklist - [ ] Format your code according to the [Format code with pre-commit](https://docs.sglang.io/developer_guide/contribution_guide.html#format-code-with-pre-commit). - [ ] Add unit tests acco...
[]
null
null
sglang
a12fea21ed08f1a5a808de2ed21bf8e43165e159
2026-03-25T13:17:27-07:00
21,103
https://github.com/sgl-project/sglang/pull/21103
perf(sgl-kernel): expose get_scheduler_metadata for FA3 decode optimization (#21103)
perf(sgl-kernel): expose get_scheduler_metadata for FA3 decode optimization (#21103)
sgl-kernel/csrc/flash_extension.cc
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/flash_extension.cc +++ sgl-kernel/csrc/flash_extension.cc @@ -61,6 +61,40 @@ ") -> (Tensor, Tensor, Tensor, Tensor)"); // NEW return type: tuple of 4 tensors m.impl("fwd", torch::kCUDA, make_pytorch_shim(&mha_fwd)); + + /* + * From flash-attention: get_scheduler_metadata + * Precom...
34
0
3
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/flash_extension.cc). Goal: perf(sgl-kernel): expose get_scheduler_metadata for FA3 decode optimization Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache ...
## Summary Register `mha_fwd_get_scheduler_metadata` as a torch op in sgl_kernel namespace. This function precomputes FA3 tile scheduling metadata so that the `prepare_varlen_num_blocks` kernel does not need to run per-layer during decode. The C++ symbol already exists in `flash_ops.so` (compiled from sgl-attn) but w...
[]
null
null
sglang
a12fea21ed08f1a5a808de2ed21bf8e43165e159
2026-03-25T13:17:27-07:00
21,103
https://github.com/sgl-project/sglang/pull/21103
perf(sgl-kernel): expose get_scheduler_metadata for FA3 decode optimization (#21103)
perf(sgl-kernel): expose get_scheduler_metadata for FA3 decode optimization (#21103)
sgl-kernel/include/sgl_flash_kernel_ops.h
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/include/sgl_flash_kernel_ops.h +++ sgl-kernel/include/sgl_flash_kernel_ops.h @@ -83,3 +83,34 @@ std::optional<bool> pack_gqa_, int64_t sm_margin, std::optional<const at::Tensor>& sinks_); // (h) + +/* + * From flash-attention: get_scheduler_metadata + * Precomputes tile scheduling metadat...
31
0
3
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_flash_kernel_ops.h). Goal: perf(sgl-kernel): expose get_scheduler_metadata for FA3 decode optimization Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the ...
## Summary Register `mha_fwd_get_scheduler_metadata` as a torch op in sgl_kernel namespace. This function precomputes FA3 tile scheduling metadata so that the `prepare_varlen_num_blocks` kernel does not need to run per-layer during decode. The C++ symbol already exists in `flash_ops.so` (compiled from sgl-attn) but w...
[]
null
null
sglang
126cd5cfae7afbc9c7efb2b00dd52807ff17b842
2026-03-19T13:30:03+08:00
20,392
https://github.com/sgl-project/sglang/pull/20392
gpt-oss decode performance optimization (#20392)
gpt-oss decode performance optimization (#20392) Co-authored-by: wunhuang <wunhuang@amd.com>
python/sglang/srt/layers/attention/utils.py
triton
Apache-2.0
import torch import triton import triton.language as tl from sglang.srt.utils import is_cuda _FLASHMLA_CREATE_KV_BLOCK_SIZE = 4096 FLASHMLA_CREATE_KV_BLOCK_SIZE_TRITON = tl.constexpr(_FLASHMLA_CREATE_KV_BLOCK_SIZE) _is_cuda = is_cuda() if _is_cuda: from sgl_kernel import concat_mla_absorb_q @triton.jit def cr...
import torch import triton import triton.language as tl from sglang.srt.utils import is_cuda _FLASHMLA_CREATE_KV_BLOCK_SIZE = 4096 FLASHMLA_CREATE_KV_BLOCK_SIZE_TRITON = tl.constexpr(_FLASHMLA_CREATE_KV_BLOCK_SIZE) _is_cuda = is_cuda() if _is_cuda: from sgl_kernel import concat_mla_absorb_q @triton.jit def cr...
--- python/sglang/srt/layers/attention/utils.py +++ python/sglang/srt/layers/attention/utils.py @@ -472,3 +472,189 @@ return concat_mla_absorb_q(q_nope, q_rope) else: return torch.cat([q_nope, q_rope], dim=-1) + + +@triton.jit +def reshape_and_cache_flash( + key_ptr, + value_ptr, + key_c...
186
0
3
[ "gpt-oss" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/utils.py). Goal: gpt-oss decode performance optimization Target hardware: unspecified Target models: gpt-oss Current file: ```python import torch import triton import triton.language as tl from sglang.srt.utils import is_cuda _FLASHMLA...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Improve the performance for gpt-oss model run...
[]
null
null
sglang
687d9eb66f4c853f7eb772b830f1181a102a8364
2026-03-19T13:18:15+08:00
15,168
https://github.com/sgl-project/sglang/pull/15168
[CPU] Optimize image preprocessor performance for Qwen2VLImageProcessorFast (#15168)
[CPU] Optimize image preprocessor performance for Qwen2VLImageProcessorFast (#15168)
sgl-kernel/csrc/cpu/common.h
cpp
Apache-2.0
#pragma once #include <ATen/ATen.h> #include <ATen/Parallel.h> #include <ATen/record_function.h> #if defined(_OPENMP) #include <omp.h> #endif namespace { // dispatch bool #define AT_DISPATCH_BOOL(BOOL_V, BOOL_NAME, ...) \ [&] { \ if (BOOL_V) { ...
#pragma once #include <ATen/ATen.h> #include <ATen/Parallel.h> #include <ATen/record_function.h> #if defined(_OPENMP) #include <omp.h> #endif namespace { // dispatch bool #define AT_DISPATCH_BOOL(BOOL_V, BOOL_NAME, ...) \ [&] { \ if (BOOL_V) { ...
--- sgl-kernel/csrc/cpu/common.h +++ sgl-kernel/csrc/cpu/common.h @@ -127,6 +127,8 @@ #define CHECK_DIM(d, x) TORCH_CHECK(x.dim() == d, #x " must be a " #d "D tensor") #define CHECK_EQ(a, b) TORCH_CHECK((a) == (b), "CHECK_EQ(" #a ", " #b ") failed. ", a, " vs ", b) +#define CHECK_GT(a, b) TORCH_CHECK((a) > (b), "CH...
2
1
2
[ "qwen" ]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/common.h). Goal: [CPU] Optimize image preprocessor performance for Qwen2VLImageProcessorFast Target hardware: CPU Target models: qwen Current file: ```cpp #pragma once #include <ATen/ATen.h> #include <ATen/Parallel.h> #include <ATen/record_function.h> #...
## Motivation Optimize the performance image preprocessor on intel Xeon CPU with AMX support. ## Modifications Add kernel implementation of ``` std::tuple<at::Tensor, at::Tensor> image_preprocess_cpu( at::TensorList images, bool do_convert_rgb, bool do_resize, int64_t shortest_edge, int64_t ...
[]
null
null
sglang
687d9eb66f4c853f7eb772b830f1181a102a8364
2026-03-19T13:18:15+08:00
15,168
https://github.com/sgl-project/sglang/pull/15168
[CPU] Optimize image preprocessor performance for Qwen2VLImageProcessorFast (#15168)
[CPU] Optimize image preprocessor performance for Qwen2VLImageProcessorFast (#15168)
sgl-kernel/csrc/cpu/torch_extension_cpu.cpp
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/cpu/torch_extension_cpu.cpp +++ sgl-kernel/csrc/cpu/torch_extension_cpu.cpp @@ -359,6 +359,25 @@ int64_t head_qk, int64_t head_v); +// image preprocessor +std::tuple<at::Tensor, at::Tensor> image_preprocess_cpu( + at::TensorList images, + bool do_convert_rgb, + bool do_resize, +...
27
0
2
[ "qwen" ]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: [CPU] Optimize image preprocessor performance for Qwen2VLImageProcessorFast Target hardware: CPU Target models: qwen Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Licens...
## Motivation Optimize the performance image preprocessor on intel Xeon CPU with AMX support. ## Modifications Add kernel implementation of ``` std::tuple<at::Tensor, at::Tensor> image_preprocess_cpu( at::TensorList images, bool do_convert_rgb, bool do_resize, int64_t shortest_edge, int64_t ...
[]
null
null
sglang
62d74549762a2c3684addc71353357f1e219bbc7
2026-03-19T13:17:53+08:00
16,040
https://github.com/sgl-project/sglang/pull/16040
optimize conv3d used in patch embedding (#16040)
optimize conv3d used in patch embedding (#16040)
sgl-kernel/csrc/cpu/torch_extension_cpu.cpp
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/cpu/torch_extension_cpu.cpp +++ sgl-kernel/csrc/cpu/torch_extension_cpu.cpp @@ -294,6 +294,11 @@ int64_t pad_slot_id, bool is_vnni); +// conv3d fast path for patch embedding +at::Tensor conv3d_embed_weight_pack(const at::Tensor& weight); + +at::Tensor conv3d_embed_cpu(const at::Tensor& i...
11
0
1
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: optimize conv3d used in patch embedding Target hardware: CPU Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Optimize `nn.Conv3d` used in patch embedding ...
[]
null
null
sglang
3d58cd16d940e2437e58e146d780f54e1112e2b9
2026-03-16T18:44:42+08:00
20,406
https://github.com/sgl-project/sglang/pull/20406
[DP Attention] Optimize dp_padding_mode selection for dp_size=1 in extend mode (#20406)
[DP Attention] Optimize dp_padding_mode selection for dp_size=1 in extend mode (#20406) Signed-off-by: wangfakang <fakangwang@gmail.com>
python/sglang/srt/layers/dp_attention.py
triton
Apache-2.0
from __future__ import annotations import functools import logging from contextlib import contextmanager from enum import IntEnum, auto from typing import TYPE_CHECKING, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.distributed import ( GroupCoordinator, get_at...
from __future__ import annotations import functools import logging from contextlib import contextmanager from enum import IntEnum, auto from typing import TYPE_CHECKING, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.distributed import ( GroupCoordinator, get_at...
--- python/sglang/srt/layers/dp_attention.py +++ python/sglang/srt/layers/dp_attention.py @@ -64,13 +64,20 @@ def get_dp_padding_mode( cls, is_extend_in_batch, global_num_tokens: List[int] ) -> DpPaddingMode: - if is_extend_in_batch: + dp_size = get_attention_dp_size() + + # When...
9
2
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/dp_attention.py). Goal: [DP Attention] Optimize dp_padding_mode selection for dp_size=1 in extend mode Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations import functools import logg...
CC @yizhang2077 @ShangmingCai @nvcastet @ch-wan @merrymercy @Fridge003 PTAL, thx. ## Motivation When dp_size=1, the `MAX_LEN` and `SUM_LEN` modes have identical communication overhead since max_len equals sum_len. Previously, extend mode(`get_dp_padding_mode`) unconditionally used `SUM_LEN`, which prevented symmetri...
[]
null
null
sglang
80a6b32703db7f0fe1ef69fa9b5e2154f3e51258
2026-03-01T04:59:26-05:00
19,536
https://github.com/sgl-project/sglang/pull/19536
[Perf] Optimize NSA backend metadata under MTP (#19536)
[Perf] Optimize NSA backend metadata under MTP (#19536) Co-authored-by: Baidu-AIAK <Baidu_AIAK@163.com> Co-authored-by: zengpai <zengpai@baidu.com>
python/sglang/srt/layers/attention/utils.py
triton
Apache-2.0
import torch import triton import triton.language as tl from sglang.srt.utils import is_cuda _FLASHMLA_CREATE_KV_BLOCK_SIZE = 4096 FLASHMLA_CREATE_KV_BLOCK_SIZE_TRITON = tl.constexpr(_FLASHMLA_CREATE_KV_BLOCK_SIZE) _is_cuda = is_cuda() if _is_cuda: from sgl_kernel import concat_mla_absorb_q @triton.jit def cr...
import torch import triton import triton.language as tl from sglang.srt.utils import is_cuda _FLASHMLA_CREATE_KV_BLOCK_SIZE = 4096 FLASHMLA_CREATE_KV_BLOCK_SIZE_TRITON = tl.constexpr(_FLASHMLA_CREATE_KV_BLOCK_SIZE) _is_cuda = is_cuda() if _is_cuda: from sgl_kernel import concat_mla_absorb_q @triton.jit def cr...
--- python/sglang/srt/layers/attention/utils.py +++ python/sglang/srt/layers/attention/utils.py @@ -284,6 +284,67 @@ ) return B, output, attn_mask + + +@triton.jit +def seqlens_expand_kernel( + extend_seq_lens_ptr, # [N] + seq_lens_ptr, # [N] + offsets_ptr, # [N+1] + output_ptr, # [sum(exten...
61
0
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/utils.py). Goal: [Perf] Optimize NSA backend metadata under MTP Target hardware: unspecified Target models: unspecified Current file: ```python import torch import triton import triton.language as tl from sglang.srt.utils import is_cuda...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation This PR is authored by @Baidu-AIAK in https:/...
[{"scope": "e2e", "hardware": null, "model": "nvidia/DeepSeek-V3.2-NVFP4", "shape": null, "batch_size": 200, "metric": "latency", "unit": "s", "higher_is_better": false, "baseline": 139.013, "optimized": 153.288, "stated_speedup": null, "speedup": 0.9069}, {"scope": "e2e", "hardware": null, "model": "nvidia/DeepSeek-V3...
null
0.9912
sglang
a1b39c1c26d41203bcce61be35c2676c5c646929
2026-02-25T15:40:55+08:00
18,088
https://github.com/sgl-project/sglang/pull/18088
Perf/fuse mamba state scatter mtp verify (#18088)
Perf/fuse mamba state scatter mtp verify (#18088)
python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py
triton
Apache-2.0
import logging import math from typing import Optional, Union import torch import triton import triton.language as tl from einops import rearrange from sglang.srt.environ import Envs from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.fla.fused_gdn_gating import...
import logging import math from typing import Optional, Union import torch import triton import triton.language as tl from einops import rearrange from sglang.srt.environ import Envs from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.fla.fused_gdn_gating import...
--- python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py +++ python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py @@ -31,6 +31,9 @@ from sglang.srt.layers.attention.mamba.mamba2_metadata import ( ForwardMetadata, Mamba2Metadata, +) +from sglang.srt.layers.attention.mamba.mamba_state_s...
39
37
1
[ "mamba" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py). Goal: Perf/fuse mamba state scatter mtp verify Target hardware: unspecified Target models: mamba Current file: ```python import logging import math from typing import Optional, Union import torch import t...
## Summary This PR introduces a fused Triton kernel for Mamba state scatter operations in MTP (Multi-Token Prediction) verify stage, reducing kernel launch overhead and improving throughput. ## Changes - **New fused kernel**: `fused_mamba_state_scatter_with_mask` in `mamba_state_scatter_triton.py` - Fuses multiple `i...
[{"scope": "e2e", "hardware": "8xH20", "model": "Qwen3-Next-80B-A3B", "shape": null, "batch_size": 48, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 1830.6, "optimized": 1901.81, "stated_speedup": 1.039, "speedup": 1.0389}]
null
1.0389
sglang
fa0ef6e4f7f7c8937e498d8db6fa8599405d2a18
2026-02-14T14:35:26+08:00
18,782
https://github.com/sgl-project/sglang/pull/18782
[VLM][LLM] Optimize fused_moe triton kernel tma (#18782)
[VLM][LLM] Optimize fused_moe triton kernel tma (#18782) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py
triton
Apache-2.0
from __future__ import annotations import functools import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.batch_invariant_ops import is_batch_invariant_mode_enabled from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_qua...
from __future__ import annotations import functools import os from collections import OrderedDict from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.batch_invariant_ops import is_batch_invariant_mode_enabled from sglang.srt.layers.quantization.fp8_ker...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py @@ -2,6 +2,7 @@ import functools import os +from collections import OrderedDict from typing import Any, Dict, List, Optional import torch @@ -610,6 +611,67 ...
68
9
1
[ "llava/vlm" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py). Goal: [VLM][LLM] Optimize fused_moe triton kernel tma Target hardware: unspecified Target models: llava/vlm Current file: ```python from __future__ import annotations import functools import os f...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "Qwen3-VL-30B-A3B-Instruct", "shape": null, "batch_size": 32, "metric": "request throughput", "unit": "req/s", "higher_is_better": true, "baseline": 13.09, "optimized": 14.34, "stated_speedup": null, "speedup": 1.0955}, {"scope": "e2e", "hardware": null, "model": "Qwen3-VL-3...
null
1.0952
sglang
8be18c655d0ff1c2e673395102c97c9d5cbd7d1c
2026-02-13T17:30:50-08:00
17,613
https://github.com/sgl-project/sglang/pull/17613
[Perf] refactor piecewise cuda graph support of Qwen3-Next (#17613)
[Perf] refactor piecewise cuda graph support of Qwen3-Next (#17613)
python/sglang/srt/layers/attention/fla/layernorm_gated.py
triton
Apache-2.0
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
--- python/sglang/srt/layers/attention/fla/layernorm_gated.py +++ python/sglang/srt/layers/attention/fla/layernorm_gated.py @@ -14,6 +14,7 @@ import triton.language as tl from einops import rearrange +from sglang.srt.server_args import get_global_server_args from sglang.srt.utils import ( cdiv, cpu_has_a...
13
1
2
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/layernorm_gated.py). Goal: [Perf] refactor piecewise cuda graph support of Qwen3-Next Target hardware: unspecified Target models: qwen Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/f...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Currently in Qwen3Next, we hide all ops inside...
[{"scope": "e2e", "hardware": null, "model": "Qwen3-Next-80B-A3B-Instruct", "shape": null, "batch_size": null, "metric": "latency", "unit": "s", "higher_is_better": false, "baseline": 12.379, "optimized": 11.041, "stated_speedup": null, "speedup": 1.1212}, {"scope": "e2e", "hardware": null, "model": "Qwen3-Next-80B-A3B...
null
1.143
sglang
9e9e94926162d0b2bf189c9722e97dbdc59b7375
2026-02-12T23:43:22+08:00
18,586
https://github.com/sgl-project/sglang/pull/18586
speed up sgl-kernel build (#18586)
speed up sgl-kernel build (#18586)
sgl-kernel/csrc/elementwise/concat_mla.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <ATen/cuda/CUDADataType.h> #include <cuda_runtime.h> #include "pytorch_extension_utils.h" #include "utils.cuh" constexpr int NUM_LOCAL_HEADS = 128; constexpr int QK_NOPE_HEAD_DIM = 128; constexpr int QK_ROPE_HEAD_DIM = 64; constexpr int K_HEAD_DIM = QK_NOPE_HEAD_DIM + QK_RO...
#include <ATen/cuda/CUDAContext.h> #include <ATen/cuda/CUDADataType.h> #include <cuda_runtime.h> #include "pytorch_extension_utils.h" #include "utils.cuh" constexpr int NUM_LOCAL_HEADS = 128; constexpr int QK_NOPE_HEAD_DIM = 128; constexpr int QK_ROPE_HEAD_DIM = 64; constexpr int K_HEAD_DIM = QK_NOPE_HEAD_DIM + QK_RO...
--- sgl-kernel/csrc/elementwise/concat_mla.cu +++ sgl-kernel/csrc/elementwise/concat_mla.cu @@ -215,3 +215,4 @@ cudaError_t err = cudaGetLastError(); TORCH_CHECK(err == cudaSuccess, "CUDA kernel launch failed: ", cudaGetErrorString(err)); } +// test-1
1
0
1
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/elementwise/concat_mla.cu). Goal: speed up sgl-kernel build Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <ATen/cuda/CUDADataType.h> #include <cuda_runtime.h> #include "pytorch_exte...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <img width="2280" height="1032" alt="e2b78baf...
[]
null
null
sglang
4637970dfb369d900936136c98cb5a6663385884
2026-02-06T19:59:42-08:00
18,271
https://github.com/sgl-project/sglang/pull/18271
[Qwen3Next] Optimize fused_sigmoid_gating_delta_rule_update_kernel (#18271)
[Qwen3Next] Optimize fused_sigmoid_gating_delta_rule_update_kernel (#18271)
python/sglang/srt/layers/attention/fla/fused_sigmoid_gating_recurrent.py
triton
Apache-2.0
from typing import Optional import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.utils import input_guard @triton.jit(do_not_specialize=["T"]) def fused_sigmoid_gating_delta_rule_update_kernel( A_log, a, dt_bias, softplus_beta, softplus_threshold, q, ...
from typing import Optional import torch import triton import triton.language as tl from sglang.srt.layers.attention.fla.utils import input_guard @triton.jit(do_not_specialize=["T"]) def fused_sigmoid_gating_delta_rule_update_kernel( A_log, a, dt_bias, softplus_beta, softplus_threshold, q, ...
--- python/sglang/srt/layers/attention/fla/fused_sigmoid_gating_recurrent.py +++ python/sglang/srt/layers/attention/fla/fused_sigmoid_gating_recurrent.py @@ -190,7 +190,7 @@ B, T, H, K, V = *k.shape, v.shape[-1] HV = v.shape[2] N = B if cu_seqlens is None else len(cu_seqlens) - 1 - BK, BV = triton.nex...
1
1
1
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/fused_sigmoid_gating_recurrent.py). Goal: [Qwen3Next] Optimize fused_sigmoid_gating_delta_rule_update_kernel Target hardware: unspecified Target models: qwen Current file: ```python from typing import Optional import torch import tr...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Apply the same optimization in https://github...
[{"scope": "e2e", "hardware": "B200", "model": null, "shape": null, "batch_size": 512, "metric": "TPOT", "unit": "ms", "higher_is_better": false, "baseline": 35.79, "optimized": 34.64, "stated_speedup": null, "speedup": 1.0332}, {"scope": "kernel", "hardware": "B200", "model": null, "shape": null, "batch_size": null, "...
1.5921
1.0332
sglang
760ae933bb3878a6897e7e552a746929c29e9d90
2026-02-04T19:59:41+08:00
16,043
https://github.com/sgl-project/sglang/pull/16043
optimize get_topk_ragged by fusing get k and k_scale triton kernel (#16043)
optimize get_topk_ragged by fusing get k and k_scale triton kernel (#16043) Co-authored-by: abing <wangbingjia.wbj@alibaba-inc.com>
python/sglang/srt/layers/attention/nsa/index_buf_accessor.py
triton
Apache-2.0
from typing import TYPE_CHECKING import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import is_fp8_fnuz from sglang.srt.utils import is_hip _is_hip = is_hip() _is_fp8_fnuz = is_fp8_fnuz() if TYPE_CHECKING: from sglang.srt.mem_cache.memory_pool import NSATokenTo...
from typing import TYPE_CHECKING import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import is_fp8_fnuz from sglang.srt.utils import is_hip _is_hip = is_hip() _is_fp8_fnuz = is_fp8_fnuz() if TYPE_CHECKING: from sglang.srt.mem_cache.memory_pool import NSATokenTo...
--- python/sglang/srt/layers/attention/nsa/index_buf_accessor.py +++ python/sglang/srt/layers/attention/nsa/index_buf_accessor.py @@ -167,11 +167,20 @@ @classmethod def triton( - cls, pool: "NSATokenToKVPool", buf, seq_len: int, page_indices: torch.Tensor + cls, + pool: "NSATokenToKVPoo...
70
26
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/nsa/index_buf_accessor.py). Goal: optimize get_topk_ragged by fusing get k and k_scale triton kernel Target hardware: unspecified Target models: unspecified Current file: ```python from typing import TYPE_CHECKING import torch import tr...
- **Summary** Optimize the get_index_k_scale_buffer function to reduce the number of concatenation operations of k_fp8 and k_scale. <img width="707" height="328" alt="image" src="https://github.com/user-attachments/assets/a78f6c66-1857-4faa-baea-db31c8a87b05" />
[]
null
null
sglang
afebb7ab7893869ec8cf7ed6dd6f06981bc8ccef
2026-02-01T18:59:31+08:00
17,674
https://github.com/sgl-project/sglang/pull/17674
Optimize custom-all-reduce (#17674)
Optimize custom-all-reduce (#17674) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
sgl-kernel/csrc/allreduce/custom_all_reduce.cuh
cuda
Apache-2.0
// Adapted from https://github.com/vllm-project/vllm/blob/v0.8.2/csrc/custom_all_reduce.cuh #pragma once #include <cuda.h> #include <cuda_bf16.h> #include <cuda_fp16.h> #include <cuda_runtime.h> #include <array> #include <iostream> #include <limits> #include <map> #include <unordered_map> #include <vector> #include ...
// Adapted from https://github.com/vllm-project/vllm/blob/v0.8.2/csrc/custom_all_reduce.cuh #pragma once #include <cuda.h> #include <cuda_bf16.h> #include <cuda_fp16.h> #include <cuda_runtime.h> #include <array> #include <iostream> #include <limits> #include <map> #include <unordered_map> #include <vector> #include ...
--- sgl-kernel/csrc/allreduce/custom_all_reduce.cuh +++ sgl-kernel/csrc/allreduce/custom_all_reduce.cuh @@ -442,21 +442,44 @@ size /= d; auto bytes = size * sizeof(typename packed_t<T>::P); int blocks = std::min(block_limit, (size + threads - 1) / threads); + + // Check environment variable once + ...
35
12
1
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/allreduce/custom_all_reduce.cuh). Goal: Optimize custom-all-reduce Target hardware: unspecified Target models: unspecified Current file: ```cuda // Adapted from https://github.com/vllm-project/vllm/blob/v0.8.2/csrc/custom_all_reduce.cuh #pragma once #includ...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 386, "optimized": 166, "stated_speedup": null, "speedup": 2.3253}]
2.3253
null
sglang
81449b4beebf761eab1ad67ad19e3cab4c0109d4
2026-01-31T01:02:12+08:00
17,094
https://github.com/sgl-project/sglang/pull/17094
Optimize GDN decode for Qwen3 Next (#17094)
Optimize GDN decode for Qwen3 Next (#17094)
python/sglang/srt/layers/attention/fla/fused_recurrent.py
triton
Apache-2.0
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/gated_delta_rule/fused_recurrent.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.layers.attention.fl...
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/gated_delta_rule/fused_recurrent.py # -*- coding: utf-8 -*- # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang from typing import Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.layers.attention.fl...
--- python/sglang/srt/layers/attention/fla/fused_recurrent.py +++ python/sglang/srt/layers/attention/fla/fused_recurrent.py @@ -136,7 +136,7 @@ B, T, H, K, V = *k.shape, v.shape[-1] HV = v.shape[2] N = B if cu_seqlens is None else len(cu_seqlens) - 1 - BK, BV = triton.next_power_of_2(K), min(triton.ne...
1
1
1
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/fused_recurrent.py). Goal: Optimize GDN decode for Qwen3 Next Target hardware: unspecified Target models: qwen Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/ops/gated_delta_rule/...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation As MoE/FullAttn/GEMM has been optimized, the G...
[{"scope": "e2e", "hardware": "B200", "model": "Qwen3", "shape": null, "batch_size": null, "metric": "Latency", "unit": "s", "higher_is_better": false, "baseline": 74.87, "optimized": 67.961, "stated_speedup": null, "speedup": 1.1017}, {"scope": "e2e", "hardware": "B200", "model": "Qwen3", "shape": null, "batch_size": ...
null
1.1013
sglang
88f77594023d6a0c9833c450eddc73b4a146541c
2026-01-30T14:07:05+08:00
15,708
https://github.com/sgl-project/sglang/pull/15708
[CPU] optimize flash_attn_varlen_func (#15708)
[CPU] optimize flash_attn_varlen_func (#15708)
sgl-kernel/csrc/cpu/decode.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE] TODO list for this kernel: // 1. tune the value for BLOCK_N // 2. planning for {batches, num_heads, num_kv_splits} // and use actual num_kv_splits for small seq length // 3. try fast impl of `.tanh()` // 4. provide amx kernel fo...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE] TODO list for this kernel: // 1. tune the value for BLOCK_N // 2. planning for {batches, num_heads, num_kv_splits} // and use actual num_kv_splits for small seq length // 3. try fast impl of `.tanh()` // 4. provide amx kernel fo...
--- sgl-kernel/csrc/cpu/decode.cpp +++ sgl-kernel/csrc/cpu/decode.cpp @@ -1049,7 +1049,7 @@ int64_t k_strideH, int64_t v_strideN, int64_t v_strideH, - float scaling, + float sm_scale, float logit_cap, int64_t max_num_reqs, int64_t max_context_len, @@ -1103,7 +1103,7 @@ /...
7
7
5
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/decode.cpp). Goal: [CPU] optimize flash_attn_varlen_func Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE] TODO list for this kernel: // 1. tune the value ...
## Motivation provide apple to apple function of `flash_attn_varlen_func` on CPU, optimized with intel AMX. Newly enabled models such as omni and sglang diffusion used `flash_attn_varlen_func` directly on CUDA device, so need to provide a counterpart on other devices. ## Modifications Add `flash_attn.cpp` in sgl-ke...
[{"scope": "kernel", "hardware": "Intel(R) Xeon(R) 6979P", "model": "qwen3 omni", "shape": "T=8160,H=6,Hkv=6,K=72", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 23.993, "optimized": 19.787, "stated_speedup": null, "speedup": 1.2126}]
1.2126
null
sglang
88f77594023d6a0c9833c450eddc73b4a146541c
2026-01-30T14:07:05+08:00
15,708
https://github.com/sgl-project/sglang/pull/15708
[CPU] optimize flash_attn_varlen_func (#15708)
[CPU] optimize flash_attn_varlen_func (#15708)
sgl-kernel/csrc/cpu/extend.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" #include "vec_pack.h" namespace { // [NOTE]: extend attention for CPU // 1. tune BLOCK_M and BLOCK_N // 2. can handle non-contiguous k_exttend and v_extend // 3. computes attention for prefix and extend separately // 4. TODO: vectorize `pack_vnni` and `pa...
#include "common.h" #include "flash_attn.h" #include "gemm.h" namespace { // [NOTE]: extend attention for CPU // 1. BLOCK_M and BLOCK_N tuned for various seq lengths // 2. can handle non-contiguous k_extend and v_extend // 3. computes attention for prefix and extend separately // 4. TODO: apply head dimension...
--- sgl-kernel/csrc/cpu/extend.cpp +++ sgl-kernel/csrc/cpu/extend.cpp @@ -1,70 +1,15 @@ #include "common.h" +#include "flash_attn.h" #include "gemm.h" -#include "vec.h" -#include "vec_pack.h" namespace { // [NOTE]: extend attention for CPU -// 1. tune BLOCK_M and BLOCK_N -// 2. can handle non-contiguous k_e...
81
217
5
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/extend.cpp). Goal: [CPU] optimize flash_attn_varlen_func Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" #include "vec_pack.h" namespace { // [NOTE]: extend attention for CPU //...
## Motivation provide apple to apple function of `flash_attn_varlen_func` on CPU, optimized with intel AMX. Newly enabled models such as omni and sglang diffusion used `flash_attn_varlen_func` directly on CUDA device, so need to provide a counterpart on other devices. ## Modifications Add `flash_attn.cpp` in sgl-ke...
[{"scope": "kernel", "hardware": "Intel(R) Xeon(R) 6979P", "model": "qwen3 omni", "shape": "T=8160,H=6,Hkv=6,K=72", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 23.993, "optimized": 19.787, "stated_speedup": null, "speedup": 1.2126}]
1.2126
null
sglang
88f77594023d6a0c9833c450eddc73b4a146541c
2026-01-30T14:07:05+08:00
15,708
https://github.com/sgl-project/sglang/pull/15708
[CPU] optimize flash_attn_varlen_func (#15708)
[CPU] optimize flash_attn_varlen_func (#15708)
sgl-kernel/csrc/cpu/torch_extension_cpu.cpp
cpp
Apache-2.0
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
/* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in...
--- sgl-kernel/csrc/cpu/torch_extension_cpu.cpp +++ sgl-kernel/csrc/cpu/torch_extension_cpu.cpp @@ -108,6 +108,17 @@ int64_t max_len_extend, double sm_scale, double logit_cap); + +// flash attention +at::Tensor flash_attn_varlen_func( + const at::Tensor& q, + const at::Tensor& k, + const at::Ten...
17
0
5
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: [CPU] optimize flash_attn_varlen_func Target hardware: CPU Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License");...
## Motivation provide apple to apple function of `flash_attn_varlen_func` on CPU, optimized with intel AMX. Newly enabled models such as omni and sglang diffusion used `flash_attn_varlen_func` directly on CUDA device, so need to provide a counterpart on other devices. ## Modifications Add `flash_attn.cpp` in sgl-ke...
[{"scope": "kernel", "hardware": "Intel(R) Xeon(R) 6979P", "model": "qwen3 omni", "shape": "T=8160,H=6,Hkv=6,K=72", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 23.993, "optimized": 19.787, "stated_speedup": null, "speedup": 1.2126}]
1.2126
null
sglang
88f77594023d6a0c9833c450eddc73b4a146541c
2026-01-30T14:07:05+08:00
15,708
https://github.com/sgl-project/sglang/pull/15708
[CPU] optimize flash_attn_varlen_func (#15708)
[CPU] optimize flash_attn_varlen_func (#15708)
sgl-kernel/csrc/cpu/vec.h
cpp
Apache-2.0
#pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #include <ATen/cpu/vec/functional.h> #include <ATen/cpu/vec/vec.h> namespace { using namespace at::vec; template <typename scalar_t, typename std::enable_if_t<is_reduced_floating_point_v<s...
#pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #include <ATen/cpu/vec/functional.h> #include <ATen/cpu/vec/vec.h> namespace { using namespace at::vec; template <typename scalar_t, typename std::enable_if_t<is_reduced_floating_point_v<s...
--- sgl-kernel/csrc/cpu/vec.h +++ sgl-kernel/csrc/cpu/vec.h @@ -148,7 +148,7 @@ #endif // vector to scalar reduction -#if defined(CPU_CAPABILITY_AVX512) && 0 +#if defined(CPU_CAPABILITY_AVX512) inline float vec_reduce_sum(const Vectorized<float>& a) { return _mm512_reduce_add_ps(__m512(a)); } @@ -323,6 +323,56...
51
1
5
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/vec.h). Goal: [CPU] optimize flash_attn_varlen_func Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #incl...
## Motivation provide apple to apple function of `flash_attn_varlen_func` on CPU, optimized with intel AMX. Newly enabled models such as omni and sglang diffusion used `flash_attn_varlen_func` directly on CUDA device, so need to provide a counterpart on other devices. ## Modifications Add `flash_attn.cpp` in sgl-ke...
[{"scope": "kernel", "hardware": "Intel(R) Xeon(R) 6979P", "model": "qwen3 omni", "shape": "T=8160,H=6,Hkv=6,K=72", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 23.993, "optimized": 19.787, "stated_speedup": null, "speedup": 1.2126}]
1.2126
null
sglang
88f77594023d6a0c9833c450eddc73b4a146541c
2026-01-30T14:07:05+08:00
15,708
https://github.com/sgl-project/sglang/pull/15708
[CPU] optimize flash_attn_varlen_func (#15708)
[CPU] optimize flash_attn_varlen_func (#15708)
sgl-kernel/csrc/cpu/vec_pack.h
cpp
Apache-2.0
// To use the transpose functions #include <ATen/native/cpu/utils.h> #include "vec.h" namespace { using namespace at::vec; template <typename index_t> inline index_t get_index(index_t* ind, int i) { return (ind == nullptr) ? (index_t)i : ind[i]; } #if defined(CPU_CAPABILITY_AVX512) // key: from [N, 32] to [32/2,...
// To use the transpose functions #include <ATen/native/cpu/utils.h> #include "vec.h" namespace { using namespace at::vec; template <typename index_t> inline index_t get_index(index_t* ind, int i) { return (ind == nullptr) ? (index_t)i : ind[i]; } #if defined(CPU_CAPABILITY_AVX512) // key: from [N, 32] to [32/2,...
--- sgl-kernel/csrc/cpu/vec_pack.h +++ sgl-kernel/csrc/cpu/vec_pack.h @@ -13,30 +13,6 @@ } #if defined(CPU_CAPABILITY_AVX512) -// key: from [N, 32] to [32/2, N, 2] -template <typename scalar_t> -inline void -pack_vnni_Nx32(scalar_t* __restrict__ dst, const scalar_t* __restrict__ src, int N, int ld_src, int ld_dst) ...
144
131
5
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/vec_pack.h). Goal: [CPU] optimize flash_attn_varlen_func Target hardware: CPU Target models: unspecified Current file: ```cpp // To use the transpose functions #include <ATen/native/cpu/utils.h> #include "vec.h" namespace { using namespace at::vec; te...
## Motivation provide apple to apple function of `flash_attn_varlen_func` on CPU, optimized with intel AMX. Newly enabled models such as omni and sglang diffusion used `flash_attn_varlen_func` directly on CUDA device, so need to provide a counterpart on other devices. ## Modifications Add `flash_attn.cpp` in sgl-ke...
[{"scope": "kernel", "hardware": "Intel(R) Xeon(R) 6979P", "model": "qwen3 omni", "shape": "T=8160,H=6,Hkv=6,K=72", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 23.993, "optimized": 19.787, "stated_speedup": null, "speedup": 1.2126}]
1.2126
null
sglang
336dc4579e944728d3efe902a49ad75f195da5e4
2026-01-30T14:03:58+08:00
12,525
https://github.com/sgl-project/sglang/pull/12525
[CPU] Optimize Qwen3-next model on CPU (#12525)
[CPU] Optimize Qwen3-next model on CPU (#12525) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com> Co-authored-by: Fan Yin <1106310035@qq.com>
python/sglang/srt/layers/attention/fla/layernorm_gated.py
triton
Apache-2.0
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
--- python/sglang/srt/layers/attention/fla/layernorm_gated.py +++ python/sglang/srt/layers/attention/fla/layernorm_gated.py @@ -14,9 +14,17 @@ import triton.language as tl from einops import rearrange -from sglang.srt.utils import cdiv, device_context, is_npu, next_power_of_2 +from sglang.srt.utils import ( + cd...
27
11
8
[ "qwen" ]
[ "CPU" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/layernorm_gated.py). Goal: [CPU] Optimize Qwen3-next model on CPU Target hardware: CPU Target models: qwen Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.p...
This PR adds unified CPU optimizations for Qwen3-next models, including: 1. Add CPU paths to call optimized kernels, which is depending on below sgl-kernels: a. chunk_gated_delta_rule https://github.com/sgl-project/sglang/pull/12441 b. fused_sigmoid_gating_delta_rule_update and fused_gdn_gating https://git...
[]
null
null
sglang
336dc4579e944728d3efe902a49ad75f195da5e4
2026-01-30T14:03:58+08:00
12,525
https://github.com/sgl-project/sglang/pull/12525
[CPU] Optimize Qwen3-next model on CPU (#12525)
[CPU] Optimize Qwen3-next model on CPU (#12525) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com> Co-authored-by: Fan Yin <1106310035@qq.com>
python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py
triton
Apache-2.0
from typing import Optional, Tuple, Union import torch import triton import triton.language as tl from einops import rearrange from sglang.jit_kernel.cutedsl_gdn import cutedsl_fused_sigmoid_gating_delta_rule_update from sglang.srt.environ import Envs from sglang.srt.layers.attention.base_attn_backend import Attentio...
from typing import Optional, Tuple, Union import torch import triton import triton.language as tl from einops import rearrange from sglang.srt.environ import Envs from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.fla.fused_gdn_gating import fused_gdn_gating fr...
--- python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py +++ python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py @@ -5,11 +5,8 @@ import triton.language as tl from einops import rearrange -from sglang.jit_kernel.cutedsl_gdn import cutedsl_fused_sigmoid_gating_delta_rule_update from sglang....
35
10
8
[ "qwen" ]
[ "CPU" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/hybrid_linear_attn_backend.py). Goal: [CPU] Optimize Qwen3-next model on CPU Target hardware: CPU Target models: qwen Current file: ```python from typing import Optional, Tuple, Union import torch import triton import triton.language as...
This PR adds unified CPU optimizations for Qwen3-next models, including: 1. Add CPU paths to call optimized kernels, which is depending on below sgl-kernels: a. chunk_gated_delta_rule https://github.com/sgl-project/sglang/pull/12441 b. fused_sigmoid_gating_delta_rule_update and fused_gdn_gating https://git...
[]
null
null
sglang
336dc4579e944728d3efe902a49ad75f195da5e4
2026-01-30T14:03:58+08:00
12,525
https://github.com/sgl-project/sglang/pull/12525
[CPU] Optimize Qwen3-next model on CPU (#12525)
[CPU] Optimize Qwen3-next model on CPU (#12525) Co-authored-by: Ma Mingfei <mingfei.ma@intel.com> Co-authored-by: Fan Yin <1106310035@qq.com>
sgl-kernel/csrc/cpu/topk.cpp
cpp
Apache-2.0
#include "common.h" #include "vec.h" namespace { template <typename scalar_t, int SIZE> inline void softmax(float* __restrict__ out, const scalar_t* __restrict__ input) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::size(); // step 1: ge...
#include "common.h" #include "vec.h" namespace { template <typename scalar_t, int SIZE> inline void softmax(float* __restrict__ out, const scalar_t* __restrict__ input) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::size(); // step 1: ge...
--- sgl-kernel/csrc/cpu/topk.cpp +++ sgl-kernel/csrc/cpu/topk.cpp @@ -524,6 +524,12 @@ break; case 256: LAUNCH_TOPK_SOFTMAX_KERNEL(256); + break; + case 384: + LAUNCH_TOPK_SOFTMAX_KERNEL(384); + break; + case 512: + LAUNCH_TOPK_SOFTMAX_KERNEL(512); ...
6
0
8
[ "qwen" ]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/topk.cpp). Goal: [CPU] Optimize Qwen3-next model on CPU Target hardware: CPU Target models: qwen Current file: ```cpp #include "common.h" #include "vec.h" namespace { template <typename scalar_t, int SIZE> inline void softmax(float* __restrict__ out, co...
This PR adds unified CPU optimizations for Qwen3-next models, including: 1. Add CPU paths to call optimized kernels, which is depending on below sgl-kernels: a. chunk_gated_delta_rule https://github.com/sgl-project/sglang/pull/12441 b. fused_sigmoid_gating_delta_rule_update and fused_gdn_gating https://git...
[]
null
null
sglang
82a1b645bad31c3071220c1acd4171209c524013
2026-01-17T00:10:52+08:00
17,133
https://github.com/sgl-project/sglang/pull/17133
[DeepSeek V3.1/V3.2] Optimize fused moe configs for H20 & H20-3E based on swapab (#17133)
[DeepSeek V3.1/V3.2] Optimize fused moe configs for H20 & H20-3E based on swapab (#17133)
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py
triton
Apache-2.0
from __future__ import annotations import functools import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_quant_fp8, scaled_fp8_quant, sglang_per_token_group_quant_fp8, ) from ...
from __future__ import annotations import functools import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_quant_fp8, scaled_fp8_quant, sglang_per_token_group_quant_fp8, ) from ...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py @@ -744,8 +744,8 @@ B.stride(0), B.stride(2), B.stride(1), - C.stride(1), - C.stride(2), + C...
2
2
1
[ "deepseek" ]
[ "H20" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py). Goal: [DeepSeek V3.1/V3.2] Optimize fused moe configs for H20 & H20-3E based on swapab Target hardware: H20 Target models: deepseek Current file: ```python from __future__ import annotations impo...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation 1. Performance tuning based on the code after ...
[]
null
null
sglang
d1ec93e3acc483d37e33b1378f2b2ff7efbb3cfc
2026-01-10T20:55:31+08:00
16,397
https://github.com/sgl-project/sglang/pull/16397
Optimize layernorm_gated for Qwen3-Next (#16397)
Optimize layernorm_gated for Qwen3-Next (#16397) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/attention/fla/layernorm_gated.py
triton
Apache-2.0
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
# Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernorm_gated.py # Copyright (c) 2024, Tri Dao. # Based on the Triton LayerNorm tutorial: https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html # For the backward pass, we keep weight_grad and bias_grad in registe...
--- python/sglang/srt/layers/attention/fla/layernorm_gated.py +++ python/sglang/srt/layers/attention/fla/layernorm_gated.py @@ -6,13 +6,15 @@ # The models we train have hidden dim up to 8k anyway (e.g. Llama 70B), so this is fine. +from functools import lru_cache + import torch import torch.nn.functional as F i...
90
36
1
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/layernorm_gated.py). Goal: Optimize layernorm_gated for Qwen3-Next Target hardware: unspecified Target models: qwen Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layernor...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "N=128", "batch_size": 65536, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 41.43, "optimized": 18.13, "stated_speedup": null, "speedup": 2.2852}, {"scope": "kernel", "hardware": null, "model": null, "shape": "N=128", "batch_size...
2.3053
1.027
sglang
67b61a4e8d0dba9c8c1d52a42769f658ad20bc0b
2026-01-10T13:57:44+08:00
16,723
https://github.com/sgl-project/sglang/pull/16723
[Rework] Add SwapAB Optimization for triton fused_moe_kernel on SM90. (#16723)
[Rework] Add SwapAB Optimization for triton fused_moe_kernel on SM90. (#16723)
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py
triton
Apache-2.0
from __future__ import annotations import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_quant_fp8, scaled_fp8_quant, sglang_per_token_group_quant_fp8, ) from sglang.srt.layers...
from __future__ import annotations import functools import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_quant_fp8, scaled_fp8_quant, sglang_per_token_group_quant_fp8, ) from ...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py @@ -1,5 +1,6 @@ from __future__ import annotations +import functools import os from typing import Any, Dict, List, Optional @@ -20,9 +21,11 @@ from sglang.s...
46
1
1
[]
[ "SM90" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py). Goal: [Rework] Add SwapAB Optimization for triton fused_moe_kernel on SM90. Target hardware: SM90 Target models: unspecified Current file: ```python from __future__ import annotations import os f...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation Rework of reverted pr https://github.com/sgl-p...
[]
null
null
sglang
ee4d2287ab64a196adb316255eb768cdf826962a
2026-01-07T23:45:35+08:00
15,712
https://github.com/sgl-project/sglang/pull/15712
Add SwapAB Optimization for triton fused_moe_kernel on SM90. (#15712)
Add SwapAB Optimization for triton fused_moe_kernel on SM90. (#15712)
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py
triton
Apache-2.0
from __future__ import annotations import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_quant_fp8, scaled_fp8_quant, sglang_per_token_group_quant_fp8, ) from sglang.srt.layers...
from __future__ import annotations import functools import os from typing import Any, Dict, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.quantization.fp8_kernel import ( per_token_group_quant_fp8, scaled_fp8_quant, sglang_per_token_group_quant_fp8, ) from ...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py @@ -1,5 +1,6 @@ from __future__ import annotations +import functools import os from typing import Any, Dict, List, Optional @@ -20,9 +21,11 @@ from sglang.s...
40
1
1
[]
[ "SM90" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py). Goal: Add SwapAB Optimization for triton fused_moe_kernel on SM90. Target hardware: SM90 Target models: unspecified Current file: ```python from __future__ import annotations import os from typin...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "kernel", "hardware": "H20-3e", "model": "GLM-4.6V-FP8", "shape": null, "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 0.058496, "optimized": 0.051936, "stated_speedup": 1.126309304, "speedup": 1.1263}, {"scope": "kernel", "hardware": "H20-3e", "model": "GLM-4.6V-F...
1.1297
1.16
sglang
9a414b164c5eb538a6b3677e5f3d9dcd27ee9f3d
2026-01-03T15:15:36+08:00
15,640
https://github.com/sgl-project/sglang/pull/15640
[Performance] Optimze the performance of Qwen25VL (#15640)
[Performance] Optimze the performance of Qwen25VL (#15640) Co-authored-by: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com>
python/sglang/srt/layers/rotary_embedding.py
triton
Apache-2.0
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model_executor/layers/rotary_embedding.py """Rotary Positional Embeddings.""" from __future__ import annotations import itertools import math from typing import Any, Dict, List, Optional, Tuple, Union import torch import to...
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model_executor/layers/rotary_embedding.py """Rotary Positional Embeddings.""" from __future__ import annotations import itertools import math from typing import Any, Dict, List, Optional, Tuple, Union import torch import to...
--- python/sglang/srt/layers/rotary_embedding.py +++ python/sglang/srt/layers/rotary_embedding.py @@ -16,6 +16,7 @@ from sglang.srt.utils import ( cpu_has_amx_support, get_bool_env_var, + get_compiler_backend, is_cpu, is_cuda, is_hip, @@ -2748,6 +2749,7 @@ return torch.cat((-x2, x1), d...
2
0
1
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/rotary_embedding.py). Goal: [Performance] Optimze the performance of Qwen25VL Target hardware: unspecified Target models: qwen Current file: ```python # Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/m...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.io to discuss further. --> ## Motivation To improve the performance of Qwen25VL model....
[{"scope": "kernel", "hardware": null, "model": "Qwen25VL", "shape": null, "batch_size": null, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 96, "optimized": 24, "stated_speedup": null, "speedup": 4.0}, {"scope": "kernel", "hardware": null, "model": "Qwen25VL", "shape": null, "batch_size": n...
9.2778
1.2747
sglang
9d878c1f3e1e5bd1ac7be9417e5b3cd6308cd23a
2025-12-25T12:35:39-08:00
15,522
https://github.com/sgl-project/sglang/pull/15522
Optimize FP8 MLA KV cache writes with Triton kernel (#15522)
Optimize FP8 MLA KV cache writes with Triton kernel (#15522)
python/sglang/srt/layers/attention/nsa/quant_k_cache.py
triton
Apache-2.0
import torch import triton import triton.language as tl from sglang.srt.layers.attention.nsa.utils import NSA_QUANT_K_CACHE_FAST def quantize_k_cache(cache_k): # TODO upstream can skip concat([k_nope, k_pe]) since we split them here if NSA_QUANT_K_CACHE_FAST: return _quantize_k_cache_fast_wrapped(cac...
import torch import triton import triton.language as tl from sglang.srt.layers.attention.nsa.utils import NSA_QUANT_K_CACHE_FAST def quantize_k_cache(cache_k): # TODO upstream can skip concat([k_nope, k_pe]) since we split them here if NSA_QUANT_K_CACHE_FAST: return _quantize_k_cache_fast_wrapped(cac...
--- python/sglang/srt/layers/attention/nsa/quant_k_cache.py +++ python/sglang/srt/layers/attention/nsa/quant_k_cache.py @@ -11,6 +11,84 @@ return _quantize_k_cache_fast_wrapped(cache_k) else: return _quantize_k_cache_slow(cache_k) + + +def quantize_k_cache_separate( + k_nope: torch.Tensor, + ...
199
1
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/nsa/quant_k_cache.py). Goal: Optimize FP8 MLA KV cache writes with Triton kernel Target hardware: unspecified Target models: unspecified Current file: ```python import torch import triton import triton.language as tl from sglang.srt.lay...
# Updated Summary Optimize FP8 MLA KV cache writes in NSA decode by: - skipping `torch.cat([k_nope, k_rope])` in the FP8 path, and - reusing the existing `set_mla_kv_buffer_triton` two-tensor write kernel. **No new Triton write kernel is added in the final version.** ## Motivation In DeepSeek-V3.2 dec...
[{"scope": "e2e", "hardware": null, "model": "DeepSeek-V3.2", "shape": null, "batch_size": null, "metric": "Benchmark duration", "unit": "s", "higher_is_better": false, "baseline": 153.09, "optimized": 150.03, "stated_speedup": null, "speedup": 1.0204}, {"scope": "e2e", "hardware": null, "model": "DeepSeek-V3.2", "shap...
null
1.0205
sglang
793c96c3d269086249eb279672fd0475ccab1b82
2025-12-18T18:13:22+08:00
12,921
https://github.com/sgl-project/sglang/pull/12921
[perf]optimize w4afp8 kernel on deepseek-v3-0324 (#12921)
[perf]optimize w4afp8 kernel on deepseek-v3-0324 (#12921) Signed-off-by: bruce.xu <bruce.x@gmicloud.ai>
sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cu
cuda
Apache-2.0
#include <c10/cuda/CUDAGuard.h> #include <cudaTypedefs.h> #include <torch/all.h> #include <type_traits> #include "cutlass/cutlass.h" #include "w4a8_grouped_mm_c3x.cuh" using namespace cute; namespace { enum class Sched { PP, CO }; template <int M, int N, int K, int A, int B, int C, Sched S> struct SM90W4A8Config ...
#include <c10/cuda/CUDAGuard.h> #include <cudaTypedefs.h> #include <torch/all.h> #include <type_traits> #include "cutlass/cutlass.h" #include "w4a8_grouped_mm_c3x.cuh" using namespace cute; namespace { enum class Sched { PP, CO }; template <int M, int N, int K, int A, int B, int C, Sched S> struct SM90W4A8Config ...
--- sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cu +++ sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cu @@ -66,6 +66,25 @@ chunk_size); } +// Helper macro to reduce code duplication +// Note: Config must be wrapped in parentheses when it contains commas (e.g., template parameters) +// ...
69
241
3
[ "deepseek" ]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cu). Goal: [perf]optimize w4afp8 kernel on deepseek-v3-0324 Target hardware: unspecified Target models: deepseek Current file: ```cuda #include <c10/cuda/CUDAGuard.h> #include <cudaTypedefs.h> #include <torch/all.h> ...
## Motivation we use w4afp8 deepseekv3-0324 online, and we find its performance is not good enough when decode batch size < 32 ## Modifications fine-grained tiling config and based on https://github.com/sgl-project/sglang/pull/10027/files I use cuda-int4 memory access to decrease memory-access pressure ## Accuracy ...
[{"scope": "e2e", "hardware": null, "model": "DeepSeek-V3-0324", "shape": null, "batch_size": 20, "metric": "request throughput", "unit": "req/s", "higher_is_better": true, "baseline": 0.69, "optimized": 0.71, "stated_speedup": null, "speedup": 1.029}, {"scope": "e2e", "hardware": null, "model": "DeepSeek-V3-0324", "sh...
1.1165
1.072
sglang
793c96c3d269086249eb279672fd0475ccab1b82
2025-12-18T18:13:22+08:00
12,921
https://github.com/sgl-project/sglang/pull/12921
[perf]optimize w4afp8 kernel on deepseek-v3-0324 (#12921)
[perf]optimize w4afp8 kernel on deepseek-v3-0324 (#12921) Signed-off-by: bruce.xu <bruce.x@gmicloud.ai>
sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_moe_data.cu
cuda
Apache-2.0
#include <c10/cuda/CUDAGuard.h> #include <cudaTypedefs.h> #include <torch/all.h> #include <iostream> constexpr uint64_t THREADS_PER_EXPERT = 512; __global__ void compute_problem_sizes_w4a8( const int32_t* __restrict__ topk_ids, int32_t* problem_sizes1, int32_t* problem_sizes2, int32_t* atomic_buffer,...
#include <c10/cuda/CUDAGuard.h> #include <cudaTypedefs.h> #include <torch/all.h> #include <cub/block/block_reduce.cuh> #include <cub/block/block_scan.cuh> template <int BLOCK_SIZE> __global__ void compute_problem_sizes_w4a8( const int32_t* __restrict__ topk_ids, int32_t* problem_sizes1, int32_t* problem_s...
--- sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_moe_data.cu +++ sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_moe_data.cu @@ -2,29 +2,48 @@ #include <cudaTypedefs.h> #include <torch/all.h> -#include <iostream> +#include <cub/block/block_reduce.cuh> +#include <cub/block/block_scan.cuh> -constexpr uint64_t THREADS_PER_EX...
96
27
3
[ "deepseek" ]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_moe_data.cu). Goal: [perf]optimize w4afp8 kernel on deepseek-v3-0324 Target hardware: unspecified Target models: deepseek Current file: ```cuda #include <c10/cuda/CUDAGuard.h> #include <cudaTypedefs.h> #include <torch/all.h> #inclu...
## Motivation we use w4afp8 deepseekv3-0324 online, and we find its performance is not good enough when decode batch size < 32 ## Modifications fine-grained tiling config and based on https://github.com/sgl-project/sglang/pull/10027/files I use cuda-int4 memory access to decrease memory-access pressure ## Accuracy ...
[{"scope": "e2e", "hardware": null, "model": "DeepSeek-V3-0324", "shape": null, "batch_size": 20, "metric": "request throughput", "unit": "req/s", "higher_is_better": true, "baseline": 0.69, "optimized": 0.71, "stated_speedup": null, "speedup": 1.029}, {"scope": "e2e", "hardware": null, "model": "DeepSeek-V3-0324", "sh...
1.1165
1.072
sglang
d36299ad774fe139b2b9afc85a97d9115e6a3067
2025-12-13T17:39:55+08:00
14,423
https://github.com/sgl-project/sglang/pull/14423
[NPU] perf update with kvcache nz & w4a8 quant (#14423)
[NPU] perf update with kvcache nz & w4a8 quant (#14423)
python/sglang/srt/layers/rotary_embedding.py
triton
Apache-2.0
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model_executor/layers/rotary_embedding.py """Rotary Positional Embeddings.""" import itertools import math from typing import Any, Dict, List, Optional, Tuple, Union import torch import torch.nn as nn import triton import t...
# Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model_executor/layers/rotary_embedding.py """Rotary Positional Embeddings.""" import itertools import math from typing import Any, Dict, List, Optional, Tuple, Union import torch import torch.nn as nn import triton import t...
--- python/sglang/srt/layers/rotary_embedding.py +++ python/sglang/srt/layers/rotary_embedding.py @@ -806,6 +806,10 @@ / yarn_get_mscale(self.scaling_factor, float(mscale_all_dim)) * attn_factor ) + self.cos_cached_total = None + self.sin_cached_total = None + sel...
38
8
1
[]
[ "NPU" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/rotary_embedding.py). Goal: [NPU] perf update with kvcache nz & w4a8 quant Target hardware: NPU Target models: unspecified Current file: ```python # Adapted from https://raw.githubusercontent.com/vllm-project/vllm/refs/tags/v0.6.6.post1/vllm/model...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.ai to discuss further. --> ## Motivation 1、Use the nz format for kv cache, thie method...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.1, "speedup": 1.1}]
null
1.1
sglang
03b835e7d13e4564e2beb72845486b8dc37606b9
2025-12-08T09:24:58+08:00
14,141
https://github.com/sgl-project/sglang/pull/14141
Refactor tuning block wise kernel and opt Qwen/Qwen3-VL-32B-Instruct-FP8 (#14141)
Refactor tuning block wise kernel and opt Qwen/Qwen3-VL-32B-Instruct-FP8 (#14141)
python/sglang/srt/layers/quantization/fp8_kernel.py
triton
Apache-2.0
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
--- python/sglang/srt/layers/quantization/fp8_kernel.py +++ python/sglang/srt/layers/quantization/fp8_kernel.py @@ -719,6 +719,7 @@ BLOCK_SIZE_N: tl.constexpr, BLOCK_SIZE_K: tl.constexpr, GROUP_SIZE_M: tl.constexpr, + needs_masking: tl.constexpr, ): """Triton-accelerated function used to perform...
94
67
1
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: Refactor tuning block wise kernel and opt Qwen/Qwen3-VL-32B-Instruct-FP8 Target hardware: unspecified Target models: qwen Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, ...
<!-- Thank you for your contribution! Please follow these guidelines to enhance your pull request. If anything is unclear, submit your PR and reach out to maintainers for assistance. Join our Slack community at https://slack.sglang.ai to discuss further. --> ## Motivation Add a needs_masking flag to optimize `w8a8_bl...
[{"scope": "e2e", "hardware": null, "model": "Qwen/Qwen3-VL-32B-Instruct-FP8", "shape": null, "batch_size": 1, "metric": "output_throughput", "unit": "token/s", "higher_is_better": true, "baseline": 52.033, "optimized": 56.681, "stated_speedup": null, "speedup": 1.0893}, {"scope": "e2e", "hardware": null, "model": "Qwe...
null
1.0105
sglang
70d25873246bb02335b0a107575e289a35662f96
2025-12-04T16:38:47+08:00
12,446
https://github.com/sgl-project/sglang/pull/12446
[CPU] Optimize small oc GEMM for Qwen3-next on CPU (#12446)
[CPU] Optimize small oc GEMM for Qwen3-next on CPU (#12446) Co-authored-by: Zheng, Beilei <beilei.zheng@intel.com>
sgl-kernel/csrc/cpu/gemm.cpp
cpp
Apache-2.0
#include "gemm.h" #include "common.h" #include "vec.h" namespace { // packed layout: // quants {N, K} int8_t // comp {N} int32_t template <int BLOCK_N> inline void s8s8_compensation(int8_t* __restrict__ packed, int K) { #if defined(CPU_CAPABILITY_AVX512) constexpr int COLS = BLOCK_N / 16; __m512i vc...
#include "gemm.h" #include "common.h" #include "vec.h" namespace { // packed layout: // quants {N, K} int8_t // comp {N} int32_t template <int BLOCK_N> inline void s8s8_compensation(int8_t* __restrict__ packed, int K) { #if defined(CPU_CAPABILITY_AVX512) constexpr int COLS = BLOCK_N / 16; __m512i vc...
--- sgl-kernel/csrc/cpu/gemm.cpp +++ sgl-kernel/csrc/cpu/gemm.cpp @@ -85,6 +85,26 @@ } template <typename scalar_t> +inline void copy_stub(float* __restrict__ out, const scalar_t* __restrict__ input, int64_t size) { + using bVec = at::vec::Vectorized<scalar_t>; + using fVec = at::vec::Vectorized<float>; + conste...
262
11
3
[ "qwen" ]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/gemm.cpp). Goal: [CPU] Optimize small oc GEMM for Qwen3-next on CPU Target hardware: CPU Target models: qwen Current file: ```cpp #include "gemm.h" #include "common.h" #include "vec.h" namespace { // packed layout: // quants {N, K} int8_t // co...
This PR adds optimization for BF16 GEMMs with small oc shapes ( oc < 16), including: 1. `weight_packed_linear`, which is common for all GEMMs with oc < 16 2. `fused_linear_sigmoid_mul`, which is specific for cases found in Qwen3-next (shared_expert_gate, where N = 1 and having post op sigmoid+mul)
[]
null
null