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
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/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 @@ -123,6 +123,14 @@ // gemm at::Tensor weight_packed_linear(at::Tensor& mat1, at::Tensor& mat2, const std::optional<at::Tensor>& bias, bool is_vnni); + +// gemm fusion +at::Tensor fused_linear_sigmoid_mul( + at::Tenso...
13
0
3
[ "qwen" ]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: [CPU] Optimize small oc GEMM for Qwen3-next on CPU Target hardware: CPU Target models: qwen Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "Lic...
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
sglang
46f21a5956f85462208ff005e6cbc86f142f8046
2025-12-04T12:34:05+08:00
12,316
https://github.com/sgl-project/sglang/pull/12316
use faster covnersion from float8_e4m3fn to bfloat16 (#12316)
use faster covnersion from float8_e4m3fn to bfloat16 (#12316)
sgl-kernel/csrc/cpu/gemm_fp8.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const float* __restrict__ input, int64_t size) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::s...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const float* __restrict__ input, int64_t size) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::s...
--- sgl-kernel/csrc/cpu/gemm_fp8.cpp +++ sgl-kernel/csrc/cpu/gemm_fp8.cpp @@ -56,7 +56,8 @@ const int K2 = K >> 1; const int ldb2 = ldb; // ldb * 2 >> 1; const uint16_t* b_ptr = reinterpret_cast<const uint16_t*>(packed_B); - const __m512 vd = _mm512_set1_ps(scale); + const __m512 vexp = _mm512_castsi512_ps(...
9
5
2
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/gemm_fp8.cpp). Goal: use faster covnersion from float8_e4m3fn to bfloat16 Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void co...
<!-- 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 improve float8 gemm performance. the old impl...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.11, "speedup": 1.11}]
1.11
null
sglang
46f21a5956f85462208ff005e6cbc86f142f8046
2025-12-04T12:34:05+08:00
12,316
https://github.com/sgl-project/sglang/pull/12316
use faster covnersion from float8_e4m3fn to bfloat16 (#12316)
use faster covnersion from float8_e4m3fn to bfloat16 (#12316)
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 @@ -121,6 +121,30 @@ #endif } +// faster version of float8_e4m3fn conversion to bfloat16 +// +// we mapped cuda implementation from below link and vectorized with avx512: +// https://github.com/thu-pacman/chitu/blob/1ed2078ec26581ebdca05b7306d4385f86edaa7c...
24
0
2
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/vec.h). Goal: use faster covnersion from float8_e4m3fn to bfloat16 Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX51...
<!-- 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 improve float8 gemm performance. the old impl...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 1.11, "speedup": 1.11}]
1.11
null
sglang
043f13171fb9688b21fc4fa076c57e80cf83c89f
2025-12-02T18:53:06-08:00
13,812
https://github.com/sgl-project/sglang/pull/13812
[Performance] Optimize NSA Indexer K/S Buffer Access with Fused Triton Kernels (#13812)
[Performance] Optimize NSA Indexer K/S Buffer Access with Fused Triton Kernels (#13812) Co-authored-by: Johnsonms <johnson@together.ai>
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 if TYPE_CHECKING: from sglang.srt.mem_cache.memory_pool import NSATokenToKVPool """ k: data, 128 item per token, fp8 s: scale, 1 item per token, fp32 """ class GetK: @classmethod def execute(cls, *args, **kwargs): ...
from typing import TYPE_CHECKING import torch import triton import triton.language as tl if TYPE_CHECKING: from sglang.srt.mem_cache.memory_pool import NSATokenToKVPool """ k: data, 128 item per token, fp8 s: scale, 1 item per token, fp32 """ class GetK: @classmethod def execute(cls, *args, **kwargs): ...
--- python/sglang/srt/layers/attention/nsa/index_buf_accessor.py +++ python/sglang/srt/layers/attention/nsa/index_buf_accessor.py @@ -16,7 +16,7 @@ class GetK: @classmethod def execute(cls, *args, **kwargs): - return cls.torch_fast(*args, **kwargs) + return cls.triton(*args, **kwargs) @c...
318
2
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/nsa/index_buf_accessor.py). Goal: [Performance] Optimize NSA Indexer K/S Buffer Access with Fused Triton Kernels Target hardware: unspecified Target models: unspecified Current file: ```python from typing import TYPE_CHECKING import tor...
<!-- 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 https://github.com/sgl-project/sglang/issues/1...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "CPU time", "unit": "us", "higher_is_better": false, "baseline": 166, "optimized": 63, "stated_speedup": null, "speedup": 2.6349}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "metr...
7
2.6349
sglang
432ecf841e261b6dcaacdf250a8691390b86558e
2025-11-25T19:44:24+08:00
12,078
https://github.com/sgl-project/sglang/pull/12078
[Ascend] qwen optimization (#12078)
[Ascend] qwen optimization (#12078) Co-authored-by: Even Zhou <even.y.zhou@outlook.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.""" 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 @@ -135,6 +135,7 @@ self._apply_rotary_emb_wrapped = torch.compile(dynamic=True)( self._apply_rotary_emb_wrapped ) + self.position_cos, self.position_sin = None, None ...
13
0
8
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/rotary_embedding.py). Goal: [Ascend] qwen optimization 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/model_executor/layers/ro...
<!-- 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 related to #10337 ## Modifications -bugfix: ...
[]
null
null
sglang
9535015d055a1d0a3b1f5fc336d9b5da44565944
2025-11-25T03:05:38+08:00
10,027
https://github.com/sgl-project/sglang/pull/10027
[Perf] Optimize DeepSeek-R1 w4afp8 glue kernels (#10027)
[Perf] Optimize DeepSeek-R1 w4afp8 glue kernels (#10027) Co-authored-by: Fan Yin <1106310035@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 @@ -14,6 +14,60 @@ ) import triton.language as tl + + +def _get_launch_config_1d(device, numel): + MAX_THREADS_PER_BLOCK = 1024 + MIN_THREADS_PER_BLOCK = 512 + MAX_WAVES = 8 # empirical numbers + + ...
239
66
3
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: [Perf] Optimize DeepSeek-R1 w4afp8 glue kernels Target hardware: unspecified Target models: deepseek Current file: ```python import logging import torch import triton from sglang.srt.utils import ceil_div, 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.ai to discuss further. --> ## Motivation <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": "H800", "model": "DeepSeek-R1-W4AFP8", "shape": "ISL=10240,OSL=512", "batch_size": 4, "metric": "E2E Latency", "unit": "ms", "higher_is_better": false, "baseline": 8321.31, "optimized": 6815.18, "stated_speedup": null, "speedup": 1.221}, {"scope": "e2e", "hardware": "H800", "model": "DeepS...
null
1.1161
sglang
3451fc3280892c6555705e24abea8cb047825990
2025-11-01T19:47:56-07:00
11,133
https://github.com/sgl-project/sglang/pull/11133
[Feature] Qwen3-Next & FLA: Support MTP topk>1; Up to 6% faster (#11133)
[Feature] Qwen3-Next & FLA: Support MTP topk>1; Up to 6% faster (#11133) Co-authored-by: Stefan He <hebiaobuaa@gmail.com>
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 @@ -330,11 +330,29 @@ return o, final_state +# HAS_EAGLE_TREE_CUSTOM_ATTN_MASK is added to support eagle tree attention mask +# retrieve_parent_token_ptr: [N, NP2_T], retrieve_next_siblin...
70
0
4
[ "qwen" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/fused_recurrent.py). Goal: [Feature] Qwen3-Next & FLA: Support MTP topk>1; Up to 6% faster Target hardware: unspecified Target models: qwen Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/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.ai to discuss further. --> Co-authored-by: @hebiao064 ## Motivation MTP spec decodin...
[{"scope": "e2e", "hardware": "H100", "model": "Qwen3-Next-80B-A3B-Instruct", "shape": null, "batch_size": null, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 343.33, "optimized": 349.29, "stated_speedup": null, "speedup": 1.0174}]
null
1.0174
sglang
3451fc3280892c6555705e24abea8cb047825990
2025-11-01T19:47:56-07:00
11,133
https://github.com/sgl-project/sglang/pull/11133
[Feature] Qwen3-Next & FLA: Support MTP topk>1; Up to 6% faster (#11133)
[Feature] Qwen3-Next & FLA: Support MTP topk>1; Up to 6% faster (#11133) Co-authored-by: Stefan He <hebiaobuaa@gmail.com>
python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py
triton
Apache-2.0
# 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/layers/mamba/ops/causal_conv1d.py from typing import List, Optional, Union import torch import triton imp...
# 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/layers/mamba/ops/causal_conv1d.py from typing import List, Optional, Union import torch import triton imp...
--- python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py +++ python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py @@ -186,7 +186,7 @@ ) mask = (idx_tokens_conv < state_len)[:, None] & (idx_feats < dim)[None, :] - tl.debug_barrier() # NOTE: use this due to...
251
54
4
[ "qwen", "mamba" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py). Goal: [Feature] Qwen3-Next & FLA: Support MTP topk>1; Up to 6% faster Target hardware: unspecified Target models: qwen, mamba Current file: ```python # Copyright (c) 2024, Tri Dao. # Adapted from https://g...
<!-- 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. --> Co-authored-by: @hebiao064 ## Motivation MTP spec decodin...
[{"scope": "e2e", "hardware": "H100", "model": "Qwen3-Next-80B-A3B-Instruct", "shape": null, "batch_size": null, "metric": "throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 343.33, "optimized": 349.29, "stated_speedup": null, "speedup": 1.0174}]
null
1.0174
sglang
d5b6e50fe8148a851eb9170ced0208132596c615
2025-10-31T22:48:02-07:00
12,435
https://github.com/sgl-project/sglang/pull/12435
perf: trtllm mla performance minor improvements (#12435)
perf: trtllm mla performance minor improvements (#12435)
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 math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.srt.layers.attention.flashinfer_mla_backend...
from __future__ import annotations """ Support attention backend for TRTLLM MLA kernels from flashinfer. """ import math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.srt.layers.attention.flashinfer_mla_backend...
--- python/sglang/srt/layers/attention/trtllm_mla_backend.py +++ python/sglang/srt/layers/attention/trtllm_mla_backend.py @@ -219,6 +219,7 @@ sum_seq_lens_q: Optional[int] = None cu_seqlens_q: Optional[torch.Tensor] = None seq_lens_q: Optional[torch.Tensor] = None + seq_lens_k: Optional[torch.Tensor] ...
70
65
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/trtllm_mla_backend.py). Goal: perf: trtllm mla performance minor improvements Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations """ Support attention backend for TRTLLM ML...
## Motivation The current `trtllm_mla` backend has several minor inefficiencies and confusing parts: 1. Element-wise operations on `seq_lens` are repeatedly executed inside CUDA Graph replay, instead of being done once during metadata initialization. 2. A redundant `torch.cat` operation (`k` + `k_rope`) exists in `...
[{"scope": "e2e", "hardware": null, "model": "nvidia/DeepSeek-V3-0324-FP4", "shape": null, "batch_size": null, "metric": "latency", "unit": "s", "higher_is_better": false, "baseline": 1.939, "optimized": 1.895, "stated_speedup": null, "speedup": 1.0232}, {"scope": "e2e", "hardware": null, "model": "nvidia/DeepSeek-V3-0...
null
1.0232
sglang
cafebef1546e9c869672b9fe12a89f3a34a79f86
2025-10-30T21:52:16+08:00
11,969
https://github.com/sgl-project/sglang/pull/11969
[NPU] bugfix for Qwen3-Next and performance update (#11969)
[NPU] bugfix for Qwen3-Next and performance update (#11969)
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 @@ -12,7 +12,9 @@ import triton.language as tl from einops import rearrange -from sglang.srt.utils import device_context +from sglang.srt.utils import device_context, is_npu + +_is_npu = is_np...
7
1
3
[ "qwen" ]
[ "NPU" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/fla/layernorm_gated.py). Goal: [NPU] bugfix for Qwen3-Next and performance update Target hardware: NPU Target models: qwen Current file: ```python # Adapt from https://github.com/fla-org/flash-linear-attention/blob/main/fla/modules/layer...
<!-- 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 <!-- Describe the purpose and goals of this p...
[]
null
null
sglang
13bf565d60f894acf6a496591c2f2fc0eecc4a98
2025-10-25T08:41:16+08:00
8,464
https://github.com/sgl-project/sglang/pull/8464
[2/N]Support DeepSeek-R1 w4a8 low latency deepep (#8464)
[2/N]Support DeepSeek-R1 w4a8 low latency deepep (#8464) Co-authored-by: Hank Han <hanhan7630@outlook.com> Co-authored-by: Shangchuan Huang <2510421000@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 @@ -1014,3 +1014,197 @@ ) return output + + +@triton.jit +def compute_problem_sizes_w4a8_kernel( + masked_m_ptr, + problem_sizes1_ptr, + problem_sizes2_ptr, + n, + k, + num_experts, + B...
194
0
6
[ "deepseek" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: [2/N]Support DeepSeek-R1 w4a8 low latency deepep Target hardware: unspecified Target models: deepseek Current file: ```python import logging import torch import triton from sglang.srt.utils import ceil_div, is_cuda ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow https://github.com/sgl-project/sglang/pull/82...
[]
null
null
sglang
13bf565d60f894acf6a496591c2f2fc0eecc4a98
2025-10-25T08:41:16+08:00
8,464
https://github.com/sgl-project/sglang/pull/8464
[2/N]Support DeepSeek-R1 w4a8 low latency deepep (#8464)
[2/N]Support DeepSeek-R1 w4a8 low latency deepep (#8464) Co-authored-by: Hank Han <hanhan7630@outlook.com> Co-authored-by: Shangchuan Huang <2510421000@qq.com>
sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_get_group_starts.cuh
cuda
Apache-2.0
#pragma once #include <c10/cuda/CUDAStream.h> #include <cuda.h> #include <torch/all.h> #include "cutlass/bfloat16.h" #include "cutlass/float8.h" template <typename ElementA, typename ElementB, typename ElementC, typename ElementAccumulator> __global__ void int4_fp8_get_group_gemm_starts( int32_t* expert_offsets,...
#pragma once #include <c10/cuda/CUDAStream.h> #include <cuda.h> #include <torch/all.h> #include "cutlass/bfloat16.h" #include "cutlass/float8.h" template <typename ElementA, typename ElementB, typename ElementC, typename ElementAccumulator> __global__ void int4_fp8_get_group_gemm_starts( int32_t* expert_offsets,...
--- sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_get_group_starts.cuh +++ sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_get_group_starts.cuh @@ -34,6 +34,40 @@ b_scales_offsets[expert_id] = b_scales_base_as_int + (per_out_ch ? expert_id * n * k / 128 : expert_id); } +template <typename ElementA, typename ElementB, typen...
72
6
6
[ "deepseek" ]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_get_group_starts.cuh). Goal: [2/N]Support DeepSeek-R1 w4a8 low latency deepep Target hardware: unspecified Target models: deepseek Current file: ```cuda #pragma once #include <c10/cuda/CUDAStream.h> #include <cuda.h> #include <torc...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow https://github.com/sgl-project/sglang/pull/82...
[]
null
null
sglang
13bf565d60f894acf6a496591c2f2fc0eecc4a98
2025-10-25T08:41:16+08:00
8,464
https://github.com/sgl-project/sglang/pull/8464
[2/N]Support DeepSeek-R1 w4a8 low latency deepep (#8464)
[2/N]Support DeepSeek-R1 w4a8 low latency deepep (#8464) Co-authored-by: Hank Han <hanhan7630@outlook.com> Co-authored-by: Shangchuan Huang <2510421000@qq.com>
sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cuh
cuda
Apache-2.0
#pragma once /** * @file w4a8_grouped_mm_c3x.cuh * @brief Implementation of grouped GEMM operation with int4 and fp8 mixed * precision * * This file implements a grouped GEMM operation that multiplies FP8 matrices * (A) with quantized INT4 matrices (B), applying per-block scaling factors. * The implementation i...
#pragma once /** * @file w4a8_grouped_mm_c3x.cuh * @brief Implementation of grouped GEMM operation with int4 and fp8 mixed * precision * * This file implements a grouped GEMM operation that multiplies FP8 matrices * (A) with quantized INT4 matrices (B), applying per-block scaling factors. * The implementation i...
--- sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cuh +++ sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cuh @@ -174,7 +174,7 @@ bool per_out_ch = b_scales.numel() != num_experts; // Check inputs - TORCH_CHECK(a_tensors.dim() == 2, "A tensor must be 2D"); + TORCH_CHECK(a_tensors.dim() == ...
4
2
6
[ "deepseek" ]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/cutlass_moe/w4a8/w4a8_grouped_mm_c3x.cuh). Goal: [2/N]Support DeepSeek-R1 w4a8 low latency deepep Target hardware: unspecified Target models: deepseek Current file: ```cuda #pragma once /** * @file w4a8_grouped_mm_c3x.cuh * @brief Implementation of gr...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow https://github.com/sgl-project/sglang/pull/82...
[]
null
null
sglang
e51046beaa67c3dd39f1814488ffc147ce5e740d
2025-10-24T16:05:44-07:00
12,093
https://github.com/sgl-project/sglang/pull/12093
perf: trtllm_mla attention backend spec decoding speedup w/ cuda graph (#12093)
perf: trtllm_mla attention backend spec decoding speedup w/ cuda graph (#12093)
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 math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.srt.layers.attention.flashinfer_mla_backend...
from __future__ import annotations """ Support attention backend for TRTLLM MLA kernels from flashinfer. """ import math from dataclasses import dataclass from typing import TYPE_CHECKING, Optional, Union import torch import triton import triton.language as tl from sglang.srt.layers.attention.flashinfer_mla_backend...
--- python/sglang/srt/layers/attention/trtllm_mla_backend.py +++ python/sglang/srt/layers/attention/trtllm_mla_backend.py @@ -423,14 +423,9 @@ PAGED_SIZE=self.page_size, ) - # Record the true maximum sequence length for this capture batch so that - # the kernel launch path (which r...
1
13
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/trtllm_mla_backend.py). Goal: perf: trtllm_mla attention backend spec decoding speedup w/ cuda graph Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations """ Support attentio...
## Motivation The `trtllm_mla` backend was selecting kernels during CUDA graph capture using very small sequence lengths. This often led to inefficient kernel choices in most runtime cases, degrading overall performance. ## Modifications Now the kernel selection uses `max_context_len` instead of the real input seque...
[]
null
null
sglang
13fb8b5489447c7e70a3e9b13793bc5bceda9c49
2025-10-23T12:39:51+08:00
10,652
https://github.com/sgl-project/sglang/pull/10652
[CPU] Optimize FP16 decode_attention_cpu (#10652)
[CPU] Optimize FP16 decode_attention_cpu (#10652)
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 @@ -308,6 +308,93 @@ }; #endif +#if defined(CPU_CAPABILITY_AVX512) +template <typename index_t, int BLOCK_M, int BLOCK_N> +struct tinygemm_kernel_nt<at::Half, index_t, BLOCK_M, BLOCK_N> { + static inline void apply( + const at::Half* __rest...
171
2
3
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/decode.cpp). Goal: [CPU] Optimize FP16 decode_attention_cpu 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 val...
<!-- 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 <!-- Describe the purpose and goals of this p...
[]
null
null
sglang
13fb8b5489447c7e70a3e9b13793bc5bceda9c49
2025-10-23T12:39:51+08:00
10,652
https://github.com/sgl-project/sglang/pull/10652
[CPU] Optimize FP16 decode_attention_cpu (#10652)
[CPU] Optimize FP16 decode_attention_cpu (#10652)
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 @@ -47,7 +47,7 @@ #define CVT_BF16_TO_FP32(a) _mm512_castsi512_ps(_mm512_slli_epi32(_mm512_cvtepu16_epi32(a), 16)) -#define CVT_FP16_TO_FP32(a) _mm512_cvtps_ph(a, (_MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC)) +#define CVT_FP16_TO_FP32(a) _mm512_cvtph_p...
1
1
3
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/vec.h). Goal: [CPU] Optimize FP16 decode_attention_cpu Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #if defined(__AVX512F__) && defined(__AVX512BF16__) && defined(__AMX_BF16__) #define CPU_CAPABILITY_AVX512 #endif #i...
<!-- 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 <!-- Describe the purpose and goals of this p...
[]
null
null
sglang
5a33c3aae72ae0c356bc113b328aa3a904a3365d
2025-10-14T20:08:32+08:00
11,556
https://github.com/sgl-project/sglang/pull/11556
Optimize Triton Draft Backend (#11556)
Optimize Triton Draft Backend (#11556)
python/sglang/srt/layers/attention/triton_backend.py
triton
Apache-2.0
from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, 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.utils import create_flashinfer_kv_...
from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, List, Optional import torch import triton import triton.language as tl from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.utils import create_flashinfer_kv_i...
--- python/sglang/srt/layers/attention/triton_backend.py +++ python/sglang/srt/layers/attention/triton_backend.py @@ -1,7 +1,7 @@ from __future__ import annotations from dataclasses import dataclass -from typing import TYPE_CHECKING, Optional, Union +from typing import TYPE_CHECKING, List, Optional import torch ...
51
28
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_backend.py). Goal: Optimize Triton Draft Backend Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKIN...
This PR: - Reduces the redundant copy when doing the multi-step decode (draft) forward. - Introduce the `num_kv_splits_buf` for Triton backend, and only init once when replaying cuda graph.
[]
null
null
sglang
21337b22b960c8bca5410c73ba4f36bfca72443c
2025-10-11T15:59:03+08:00
10,312
https://github.com/sgl-project/sglang/pull/10312
Reland [1/2] Optimizations and refactors about quant kernel (#10312)
Reland [1/2] Optimizations and refactors about quant kernel (#10312) Co-authored-by: Yineng Zhang <me@zhyncs.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 @@ -43,11 +43,17 @@ _use_aiter = get_bool_env_var("SGLANG_USE_AITER") and _is_hip if _is_cuda: - from sgl_kernel import ( - sgl_per_tensor_quant_fp8, - sgl_per_token_group_quant_fp8, - ...
35
8
7
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: Reland [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, Versio...
## Motivation real change is tiny, most code are from the last pr which has been reviewed before fix: either error or 0% acc Blackwell: ``` (cd /data/numa0/tom/primary_synced/sglang && SGL_JIT_DEEPGEMM_PRECOMPILE=0 SGLANG_IS_IN_CI=1 HF_TOKEN=... HF_HUB_ENABLE_HF_TRANSFER=1 python3 test/srt/ep/test_deepep_small.py...
[]
null
null
sglang
21337b22b960c8bca5410c73ba4f36bfca72443c
2025-10-11T15:59:03+08:00
10,312
https://github.com/sgl-project/sglang/pull/10312
Reland [1/2] Optimizations and refactors about quant kernel (#10312)
Reland [1/2] Optimizations and refactors about quant kernel (#10312) Co-authored-by: Yineng Zhang <me@zhyncs.com>
python/sglang/srt/layers/quantization/int8_kernel.py
triton
Apache-2.0
import functools import json import logging import os from typing import Any, Dict, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.utils import get_device_name, is_cuda _is_cuda = is_cuda() if _is_cuda: from sgl_kernel import sgl_per_token_group_quant_int8 logger =...
import functools import json import logging import os from typing import Any, Dict, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.utils import get_bool_env_var, get_device_name, is_cuda _is_cuda = is_cuda() if _is_cuda: # Temporary try: from sgl_kernel ...
--- python/sglang/srt/layers/quantization/int8_kernel.py +++ python/sglang/srt/layers/quantization/int8_kernel.py @@ -8,11 +8,17 @@ import triton import triton.language as tl -from sglang.srt.utils import get_device_name, is_cuda +from sglang.srt.utils import get_bool_env_var, get_device_name, is_cuda _is_cuda =...
12
3
7
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/int8_kernel.py). Goal: Reland [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```python import functools import json import logging import os from typing impor...
## Motivation real change is tiny, most code are from the last pr which has been reviewed before fix: either error or 0% acc Blackwell: ``` (cd /data/numa0/tom/primary_synced/sglang && SGL_JIT_DEEPGEMM_PRECOMPILE=0 SGLANG_IS_IN_CI=1 HF_TOKEN=... HF_HUB_ENABLE_HF_TRANSFER=1 python3 test/srt/ep/test_deepep_small.py...
[]
null
null
sglang
21337b22b960c8bca5410c73ba4f36bfca72443c
2025-10-11T15:59:03+08:00
10,312
https://github.com/sgl-project/sglang/pull/10312
Reland [1/2] Optimizations and refactors about quant kernel (#10312)
Reland [1/2] Optimizations and refactors about quant kernel (#10312) Co-authored-by: Yineng Zhang <me@zhyncs.com>
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -136,14 +136,14 @@ m.impl("fp8_blockwise_scaled_mm", torch::kCUDA, &fp8_blockwise_scaled_mm); m.def( - "sgl_per_token_group_quant_fp8(Tensor input, Tensor output_q, Tensor output_s, int group_size," + "sgl_per_token_gro...
7
7
7
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: Reland [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Versio...
## Motivation real change is tiny, most code are from the last pr which has been reviewed before fix: either error or 0% acc Blackwell: ``` (cd /data/numa0/tom/primary_synced/sglang && SGL_JIT_DEEPGEMM_PRECOMPILE=0 SGLANG_IS_IN_CI=1 HF_TOKEN=... HF_HUB_ENABLE_HF_TRANSFER=1 python3 test/srt/ep/test_deepep_small.py...
[]
null
null
sglang
21337b22b960c8bca5410c73ba4f36bfca72443c
2025-10-11T15:59:03+08:00
10,312
https://github.com/sgl-project/sglang/pull/10312
Reland [1/2] Optimizations and refactors about quant kernel (#10312)
Reland [1/2] Optimizations and refactors about quant kernel (#10312) Co-authored-by: Yineng Zhang <me@zhyncs.com>
sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <cuda_fp8.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" __device__ __forceinline__ float GroupReduceMax(float val, const int tid) { unsigned mask = threadIdx.x % 32 >= 16 ? 0xffff0000 : 0x0000ffff; val = fmaxf(val, __shfl_xor_sync(mask, v...
#include <ATen/cuda/CUDAContext.h> #include <cuda_fp8.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" __device__ __forceinline__ float GroupReduceMax(float val, const int tid) { unsigned mask = threadIdx.x % 32 >= 16 ? 0xffff0000 : 0x0000ffff; val = fmaxf(val, __shfl_xor_sync(mask, v...
--- sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu +++ sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu @@ -121,7 +121,7 @@ double eps, double min_8bit, double max_8bit, - bool scale_ue8m0 = false) { + bool scale_ue8m0) { CHECK_INPUT(input); CHECK_INPUT(output_q); @@ -215,26 +215,3 @@...
1
24
7
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu). Goal: Reland [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <cuda_fp8.h> #include <cmath> #i...
## Motivation real change is tiny, most code are from the last pr which has been reviewed before fix: either error or 0% acc Blackwell: ``` (cd /data/numa0/tom/primary_synced/sglang && SGL_JIT_DEEPGEMM_PRECOMPILE=0 SGLANG_IS_IN_CI=1 HF_TOKEN=... HF_HUB_ENABLE_HF_TRANSFER=1 python3 test/srt/ep/test_deepep_small.py...
[]
null
null
sglang
21337b22b960c8bca5410c73ba4f36bfca72443c
2025-10-11T15:59:03+08:00
10,312
https://github.com/sgl-project/sglang/pull/10312
Reland [1/2] Optimizations and refactors about quant kernel (#10312)
Reland [1/2] Optimizations and refactors about quant kernel (#10312) Co-authored-by: Yineng Zhang <me@zhyncs.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 @@ -219,7 +219,7 @@ const torch::Dtype& out_dtype); void scaled_fp4_quant( torch::Tensor& output, torch::Tensor const& input, torch::Tensor& output_scale, torch::Tensor const& input_scale); -void sgl_per_token_group_quant_fp8( +v...
7
4
7
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: Reland [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Versio...
## Motivation real change is tiny, most code are from the last pr which has been reviewed before fix: either error or 0% acc Blackwell: ``` (cd /data/numa0/tom/primary_synced/sglang && SGL_JIT_DEEPGEMM_PRECOMPILE=0 SGLANG_IS_IN_CI=1 HF_TOKEN=... HF_HUB_ENABLE_HF_TRANSFER=1 python3 test/srt/ep/test_deepep_small.py...
[]
null
null
sglang
42245551efd8d556692aa518a49e8f15cfa136a5
2025-09-28T23:04:22+08:00
10,543
https://github.com/sgl-project/sglang/pull/10543
[sgl-kernel] Optimize concat_mla_k kernel (#10543)
[sgl-kernel] Optimize concat_mla_k kernel (#10543) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com> Co-authored-by: PGFLMG <1106310035@qq.com>
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" 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_ROPE_HEAD_DIM; constex...
#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 @@ -3,6 +3,7 @@ #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; @@ -12,20 +13,10 @@ constexpr int HEAD_CHUN...
44
46
1
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/elementwise/concat_mla.cu). Goal: [sgl-kernel] Optimize concat_mla_k kernel Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <ATen/cuda/CUDADataType.h> #include <cuda_runtime.h> #inclu...
<!-- 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 <!-- Describe the purpose and goals of this p...
[{"scope": "e2e", "hardware": null, "model": "DeepSeek-R1", "shape": "input=4k, output=1", "batch_size": 16, "metric": "Input token throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 9165.76, "optimized": 9327.91, "stated_speedup": null, "speedup": 1.0177}, {"scope": "e2e", "hardware": null, "model": "...
null
1.0187
sglang
0f04a5f428b27b4f011473787de93f3115e832a6
2025-09-22T08:04:27+08:00
10,714
https://github.com/sgl-project/sglang/pull/10714
Optimize cutlass int8 gemm kernel for large M on SM89 Ada GPU (#10714)
Optimize cutlass int8 gemm kernel for large M on SM89 Ada GPU (#10714)
sgl-kernel/csrc/gemm/int8_gemm_kernel.cu
cuda
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/gemm/int8_gemm_kernel.cu +++ sgl-kernel/csrc/gemm/int8_gemm_kernel.cu @@ -409,8 +409,8 @@ cutlass_int8_scaled_mm< ElementOutput, ArchTag, - cutlass::gemm::GemmShape<32, 64, 128>, - cutlass::gemm::GemmShape<16, 64, 64>, + cutlass::gemm::GemmShape<128, 128, ...
2
2
1
[]
[ "ADA", "SM89" ]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/int8_gemm_kernel.cu). Goal: Optimize cutlass int8 gemm kernel for large M on SM89 Ada GPU Target hardware: ADA, SM89 Target models: unspecified Current file: ```cuda /* 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.ai to discuss further. --> ## Motivation Inspired by [10502](https://github.com/sgl-pro...
[]
null
null
sglang
bd7eb0205add75a33047221e3322e376d314697c
2025-09-20T00:12:43-07:00
10,680
https://github.com/sgl-project/sglang/pull/10680
[Performance] Qwen3-Next: optimize causal_conv1d_fn triton kernel - up to 9% faster (#10680)
[Performance] Qwen3-Next: optimize causal_conv1d_fn triton kernel - up to 9% faster (#10680)
python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py
triton
Apache-2.0
# 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/layers/mamba/ops/causal_conv1d.py from typing import Optional, Union import numpy as np import torch PAD...
# 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/layers/mamba/ops/causal_conv1d.py from typing import List, Optional, Union import numpy as np import torc...
--- python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py +++ python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py @@ -2,7 +2,7 @@ # 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/vl...
15
98
3
[ "qwen", "mamba" ]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/mamba/causal_conv1d_triton.py). Goal: [Performance] Qwen3-Next: optimize causal_conv1d_fn triton kernel - up to 9% faster Target hardware: unspecified Target models: qwen, mamba Current file: ```python # Copyright (c) 2024, Tri Dao. # Ad...
<!-- 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 (This PR fixed the merge conflict in this PR:...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "runtime", "unit": "us", "higher_is_better": false, "baseline": 313, "optimized": 95, "stated_speedup": null, "speedup": 3.2947}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "me...
4.6844
1.0546
sglang
3b25dc127ae7df0680cfe0fd7800ba5aa280c64c
2025-09-16T02:53:21+08:00
10,473
https://github.com/sgl-project/sglang/pull/10473
[1/2] Speed up trtllm_mla attention backend (>10% e2e) (#10473)
[1/2] Speed up trtllm_mla attention backend (>10% e2e) (#10473)
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -103,6 +103,9 @@ m.impl("copy_to_gpu_no_ce", torch::kCUDA, &copy_to_gpu_no_ce); m.def("concat_mla_k(Tensor! k, Tensor k_nope, Tensor k_rope) -> ()"); m.impl("concat_mla_k", torch::kCUDA, &concat_mla_k); + + m.def("concat_mla_ab...
3
0
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: [1/2] Speed up trtllm_mla attention backend (>10% e2e) Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0...
<!-- 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 EDIT: 17.5% e2e speedup for short seq len, th...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": 1, "metric": "latency", "unit": "s", "higher_is_better": false, "baseline": 0.010048, "optimized": 0.006176, "stated_speedup": null, "speedup": 1.6269}, {"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": 16, "met...
null
5.4031
sglang
3b25dc127ae7df0680cfe0fd7800ba5aa280c64c
2025-09-16T02:53:21+08:00
10,473
https://github.com/sgl-project/sglang/pull/10473
[1/2] Speed up trtllm_mla attention backend (>10% e2e) (#10473)
[1/2] Speed up trtllm_mla attention backend (>10% e2e) (#10473)
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" 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_ROPE_HEAD_DIM; constex...
#include <ATen/cuda/CUDAContext.h> #include <ATen/cuda/CUDADataType.h> #include <cuda_runtime.h> #include "pytorch_extension_utils.h" 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_ROPE_HEAD_DIM; constex...
--- sgl-kernel/csrc/elementwise/concat_mla.cu +++ sgl-kernel/csrc/elementwise/concat_mla.cu @@ -115,3 +115,105 @@ cudaError_t err = cudaGetLastError(); TORCH_CHECK(err == cudaSuccess, "CUDA kernel launch failed: ", cudaGetErrorString(err)); } + +// ============================== concat_mla_absorb_q =============...
102
0
5
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/elementwise/concat_mla.cu). Goal: [1/2] Speed up trtllm_mla attention backend (>10% e2e) Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <ATen/cuda/CUDADataType.h> #include <cuda_runti...
<!-- 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 EDIT: 17.5% e2e speedup for short seq len, th...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": 1, "metric": "latency", "unit": "s", "higher_is_better": false, "baseline": 0.010048, "optimized": 0.006176, "stated_speedup": null, "speedup": 1.6269}, {"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": 16, "met...
null
5.4031
sglang
3b25dc127ae7df0680cfe0fd7800ba5aa280c64c
2025-09-16T02:53:21+08:00
10,473
https://github.com/sgl-project/sglang/pull/10473
[1/2] Speed up trtllm_mla attention backend (>10% e2e) (#10473)
[1/2] Speed up trtllm_mla attention backend (>10% e2e) (#10473)
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 @@ -172,6 +172,7 @@ void copy_to_gpu_no_ce(const at::Tensor& input, at::Tensor& output); void concat_mla_k(torch::Tensor k, torch::Tensor k_nope, torch::Tensor k_rope); +void concat_mla_absorb_q(at::Tensor a, at::Tensor b, at::Tensor ou...
1
0
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [1/2] Speed up trtllm_mla attention backend (>10% e2e) Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0...
<!-- 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 EDIT: 17.5% e2e speedup for short seq len, th...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": 1, "metric": "latency", "unit": "s", "higher_is_better": false, "baseline": 0.010048, "optimized": 0.006176, "stated_speedup": null, "speedup": 1.6269}, {"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": 16, "met...
null
5.4031
sglang
a360511d7b9f92fde1f54a45f2a4d85831386d36
2025-09-13T10:57:06-07:00
9,748
https://github.com/sgl-project/sglang/pull/9748
[Generative Score API] Scoring(Prefill-only) optimizations. (#9748)
[Generative Score API] Scoring(Prefill-only) optimizations. (#9748)
python/sglang/srt/layers/logits_processor.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/logits_processor.py +++ python/sglang/srt/layers/logits_processor.py @@ -72,7 +72,10 @@ next_token_top_logprobs_val: Optional[List] = None next_token_top_logprobs_idx: Optional[List] = None # The logprobs and ids of the requested token ids in output positions. shape: [#seq, n...
4
1
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/logits_processor.py). Goal: [Generative Score API] Scoring(Prefill-only) optimizations. Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version ...
## 🚀 Motivation - Follow-up to [PR #8840](https://github.com/sgl-project/sglang/pull/8840) to reduce latency and increase throughput for the generative score API. - Scoring only needs the next-token distribution after the full prompt, not per-token logprobs inside the prompt or any sampling. **Performance Impact:** ...
[{"scope": "e2e", "hardware": "H100", "model": "Qwen3-0.6B", "shape": "prompt=300", "batch_size": 10, "metric": "P99 latency", "unit": "ms", "higher_is_better": false, "baseline": 6220, "optimized": 454, "stated_speedup": 13.7, "speedup": 13.7004}, {"scope": "e2e", "hardware": "H100", "model": "Qwen3-0.6B", "shape": "p...
null
1.8151
sglang
c5d2b01cea6cc9a9ad0450222c7a4f19f5487b3d
2025-09-12T05:56:25+08:00
10,303
https://github.com/sgl-project/sglang/pull/10303
[LongCat] Optimize zero_experts_compute_triton by changing mask (#10303)
[LongCat] Optimize zero_experts_compute_triton by changing mask (#10303)
python/sglang/srt/layers/moe/ep_moe/kernels.py
triton
Apache-2.0
import logging from typing import List, Optional import torch import triton from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import ceil_div, dispose_tensor, is_cuda from sglang.utils import is_in_ci logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _i...
import logging from typing import List, Optional import torch import triton from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import ceil_div, dispose_tensor, is_cuda from sglang.utils import is_in_ci logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _i...
--- python/sglang/srt/layers/moe/ep_moe/kernels.py +++ python/sglang/srt/layers/moe/ep_moe/kernels.py @@ -1416,7 +1416,7 @@ zero_expert_scales[zero_expert_mask] = 0.0 normal_expert_mask = expert_indices >= num_experts - expert_indices[normal_expert_mask] = 0 + expert_indices[normal_expert_mask] = ...
1
1
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: [LongCat] Optimize zero_experts_compute_triton by changing mask Target hardware: unspecified Target models: unspecified Current file: ```python import logging from typing import List, Optional import torch import tri...
update moe expert mask @Orchard-DT . Sincerely invite you to help check. <!-- 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 ...
[{"scope": "e2e", "hardware": null, "model": null, "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
0096798ed60b9eadce468c2d206cd2982e97b978
2025-09-09T00:00:33+08:00
10,156
https://github.com/sgl-project/sglang/pull/10156
[1/2] Speed up prefill mla attention (#10156)
[1/2] Speed up prefill mla attention (#10156)
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -436,6 +436,8 @@ m.def("copy_to_gpu_no_ce(Tensor input, Tensor! output) -> ()"); m.impl("copy_to_gpu_no_ce", torch::kCUDA, &copy_to_gpu_no_ce); + m.def("concat_mla_k(Tensor! k, Tensor k_nope, Tensor k_rope) -> ()"); + m.impl("c...
2
0
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: [1/2] Speed up prefill mla attention Target hardware: unspecified 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.ai to discuss further. --> ## Motivation in nsys I see bandwidth is ~90%, and it is no...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": 2048, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 0.109568, "optimized": 0.028672, "stated_speedup": null, "speedup": 3.8214}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size"...
3.8106
1.0196
sglang
0096798ed60b9eadce468c2d206cd2982e97b978
2025-09-09T00:00:33+08:00
10,156
https://github.com/sgl-project/sglang/pull/10156
[1/2] Speed up prefill mla attention (#10156)
[1/2] Speed up prefill mla attention (#10156)
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 @@ -723,3 +723,4 @@ void store_kv_cache(at::Tensor k_cache, at::Tensor v_cache, at::Tensor out_loc, at::Tensor k, at::Tensor v); void copy_to_gpu_no_ce(const at::Tensor& input, at::Tensor& output); +void concat_mla_k(torch::Tensor k, to...
1
0
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [1/2] Speed up prefill mla attention Target hardware: unspecified 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.ai to discuss further. --> ## Motivation in nsys I see bandwidth is ~90%, and it is no...
[{"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": 2048, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 0.109568, "optimized": 0.028672, "stated_speedup": null, "speedup": 3.8214}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size"...
3.8106
1.0196
sglang
85ed8e0a5ec9ed47a5d1ac93ecc8bee2159468e0
2025-09-07T13:31:00+08:00
10,101
https://github.com/sgl-project/sglang/pull/10101
Optimize nvfp4 block scaled gemm kernel when M is small. (#10101)
Optimize nvfp4 block scaled gemm kernel when M is small. (#10101)
sgl-kernel/csrc/gemm/nvfp4_scaled_mm_kernels.cu
cuda
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/gemm/nvfp4_scaled_mm_kernels.cu +++ sgl-kernel/csrc/gemm/nvfp4_scaled_mm_kernels.cu @@ -38,27 +38,74 @@ using namespace cute; #if defined(CUTLASS_ARCH_MMA_SM100_SUPPORTED) -// Kernel Perf config -template <typename T> -struct KernelTraits { +// Config(half_t/bfloat16_t) for M <= 128 +template <t...
118
34
1
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/nvfp4_scaled_mm_kernels.cu). Goal: Optimize nvfp4 block scaled gemm kernel when M is small. Target hardware: unspecified Target models: unspecified Current file: ```cuda /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Lice...
<!-- 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 Until now, the CUTLASS-based nvfp4 block-scale...
[]
null
null
sglang
cb3918a09127a1da8cc0976f86e7425285a1dca6
2025-09-07T09:16:18+08:00
9,477
https://github.com/sgl-project/sglang/pull/9477
Optimize moe_sum_reduce_kernel (#9477)
Optimize moe_sum_reduce_kernel (#9477) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com> Co-authored-by: Xiaoyu Zhang <35585791+BBuf@users.noreply.github.com>
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 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...
--- 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 @@ -735,29 +735,32 @@ token_block_id = tl.program_id(0) dim_block_id = tl.program_id(1) - token_start = token_block_id * BLOCK_M - token_end = min...
27
24
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py). Goal: Optimize moe_sum_reduce_kernel Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations import os from typing import Any, Dict, Lis...
<!-- 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 During the Prefill stage of TP MoE, the moe_s...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "num_tokens=1.0", "batch_size": 1, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 9.92, "optimized": 9.536, "stated_speedup": null, "speedup": 1.0403}, {"scope": "kernel", "hardware": null, "model": null, "shape": "num_tokens=2.0"...
1.0343
1.1283
sglang
339f8eef09e1cf94044dbe1fdb556dfc01430428
2025-09-05T18:45:08+08:00
9,534
https://github.com/sgl-project/sglang/pull/9534
[1/2] Optimizations and refactors about quant kernel (#9534)
[1/2] Optimizations and refactors about quant kernel (#9534)
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 @@ -43,11 +43,17 @@ _use_aiter = get_bool_env_var("SGLANG_USE_AITER") and _is_hip if _is_cuda: - from sgl_kernel import ( - sgl_per_tensor_quant_fp8, - sgl_per_token_group_quant_fp8, - ...
29
8
7
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (...
<!-- 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 to review this, just look at https://github.c...
[]
null
null
sglang
339f8eef09e1cf94044dbe1fdb556dfc01430428
2025-09-05T18:45:08+08:00
9,534
https://github.com/sgl-project/sglang/pull/9534
[1/2] Optimizations and refactors about quant kernel (#9534)
[1/2] Optimizations and refactors about quant kernel (#9534)
python/sglang/srt/layers/quantization/int8_kernel.py
triton
Apache-2.0
import functools import json import logging import os from typing import Any, Dict, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.utils import get_device_name, is_cuda _is_cuda = is_cuda() if _is_cuda: from sgl_kernel import sgl_per_token_group_quant_int8 logger =...
import functools import json import logging import os from typing import Any, Dict, List, Optional, Tuple import torch import triton import triton.language as tl from sglang.srt.utils import get_device_name, is_cuda _is_cuda = is_cuda() if _is_cuda: # Temporary try: from sgl_kernel import sgl_per_tok...
--- python/sglang/srt/layers/quantization/int8_kernel.py +++ python/sglang/srt/layers/quantization/int8_kernel.py @@ -12,7 +12,13 @@ _is_cuda = is_cuda() if _is_cuda: - from sgl_kernel import sgl_per_token_group_quant_int8 + # Temporary + try: + from sgl_kernel import sgl_per_token_group_quant_8bit ...
8
2
7
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/int8_kernel.py). Goal: [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```python import functools import json import logging import os from typing import Any, ...
<!-- 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 to review this, just look at https://github.c...
[]
null
null
sglang
339f8eef09e1cf94044dbe1fdb556dfc01430428
2025-09-05T18:45:08+08:00
9,534
https://github.com/sgl-project/sglang/pull/9534
[1/2] Optimizations and refactors about quant kernel (#9534)
[1/2] Optimizations and refactors about quant kernel (#9534)
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -121,14 +121,9 @@ m.impl("fp8_blockwise_scaled_mm", torch::kCUDA, &fp8_blockwise_scaled_mm); m.def( - "sgl_per_token_group_quant_fp8(Tensor input, Tensor output_q, Tensor output_s, int group_size," - " float eps, float ...
3
8
7
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (...
<!-- 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 to review this, just look at https://github.c...
[]
null
null
sglang
339f8eef09e1cf94044dbe1fdb556dfc01430428
2025-09-05T18:45:08+08:00
9,534
https://github.com/sgl-project/sglang/pull/9534
[1/2] Optimizations and refactors about quant kernel (#9534)
[1/2] Optimizations and refactors about quant kernel (#9534)
sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <cuda_fp8.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" __device__ __forceinline__ float GroupReduceMax(float val, const int tid) { unsigned mask = 0xffff; val = fmaxf(val, __shfl_xor_sync(mask, val, 8)); val = fmaxf(val, __shfl_xor_syn...
#include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <int THREADS_PER_SUBWARP> __device__ __forceinline__ float GroupReduceMax(float val, const int tid) { unsigned mask = 0xffff; static_assert( (THREADS_PER...
--- sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu +++ sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu @@ -1,119 +1,396 @@ #include <ATen/cuda/CUDAContext.h> -#include <cuda_fp8.h> +#include <c10/util/Float8_e4m3fn.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" +template <i...
453
183
7
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu). Goal: [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <cuda_fp8.h> #include <cmath> #include ...
<!-- 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 to review this, just look at https://github.c...
[]
null
null
sglang
339f8eef09e1cf94044dbe1fdb556dfc01430428
2025-09-05T18:45:08+08:00
9,534
https://github.com/sgl-project/sglang/pull/9534
[1/2] Optimizations and refactors about quant kernel (#9534)
[1/2] Optimizations and refactors about quant kernel (#9534)
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 @@ -207,23 +207,17 @@ const torch::Dtype& out_dtype); void scaled_fp4_quant( torch::Tensor& output, torch::Tensor const& input, torch::Tensor& output_scale, torch::Tensor const& input_scale); -void sgl_per_token_group_quant_fp8( ...
6
12
7
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [1/2] Optimizations and refactors about quant kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (...
<!-- 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 to review this, just look at https://github.c...
[]
null
null
sglang
5c34b4f1c769fc1150a39b96a4673559d6657a8e
2025-08-29T17:17:03-07:00
9,556
https://github.com/sgl-project/sglang/pull/9556
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -159,8 +159,7 @@ m.def( "silu_and_mul_scaled_fp4_experts_quant(Tensor! output, Tensor! output_scale," - "Tensor input, Tensor input_global_scale, Tensor input_offset_by_experts," - "Tensor output_scale_offset_by_exp...
1
2
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: [NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Licens...
This PR further optimizes `silu_and_mul_scaled_fp4_grouped_quant` for DeepEP low-latency scenarios. When the mask contains small values, the kernel achieves up to 82× speedup over the previous version. The change also improves performance for non-masked NVFP4 expert quantization (`scaled_fp4_experts_quant`) and NVFP4 g...
[{"scope": "kernel", "hardware": null, "model": "DeepEP", "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 82, "speedup": 82.0}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": nul...
41.75
null
sglang
5c34b4f1c769fc1150a39b96a4673559d6657a8e
2025-08-29T17:17:03-07:00
9,556
https://github.com/sgl-project/sglang/pull/9556
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cuda_fp8.h> #include <cuda_runtime.h> #include <torch/all.h> template <typename T> struct TypeConverter { using Type = half2; }; // keep for generality template <> struct TypeConverter<half2> { using Type = half; }; template <> struct ...
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cuda_fp8.h> #include <cuda_runtime.h> #include <torch/all.h> template <typename T> struct TypeConverter { using Type = half2; }; // keep for generality template <> struct TypeConverter<half2> { using Type = half; }; template <> struct ...
--- sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu +++ sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu @@ -347,7 +347,7 @@ } } - // Eerly exit when using masks. + // Early exit when using masks. if (use_mask && rowIdx_in_expert >= mask[expert_idx]) { continue; } @@ -374,6 +374,107 @@ in...
134
19
5
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu). Goal: [NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include ...
This PR further optimizes `silu_and_mul_scaled_fp4_grouped_quant` for DeepEP low-latency scenarios. When the mask contains small values, the kernel achieves up to 82× speedup over the previous version. The change also improves performance for non-masked NVFP4 expert quantization (`scaled_fp4_experts_quant`) and NVFP4 g...
[{"scope": "kernel", "hardware": null, "model": "DeepEP", "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 82, "speedup": 82.0}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": nul...
41.75
null
sglang
5c34b4f1c769fc1150a39b96a4673559d6657a8e
2025-08-29T17:17:03-07:00
9,556
https://github.com/sgl-project/sglang/pull/9556
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
sgl-kernel/csrc/gemm/nvfp4_quant_entry.cu
cuda
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/gemm/nvfp4_quant_entry.cu +++ sgl-kernel/csrc/gemm/nvfp4_quant_entry.cu @@ -32,9 +32,8 @@ torch::Tensor& output_scale, torch::Tensor const& input, torch::Tensor const& input_global_scale, - torch::Tensor const& input_offset_by_experts, - torch::Tensor const& output_scale_offset_...
5
7
5
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/nvfp4_quant_entry.cu). Goal: [NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf Target hardware: unspecified Target models: unspecified Current file: ```cuda /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apach...
This PR further optimizes `silu_and_mul_scaled_fp4_grouped_quant` for DeepEP low-latency scenarios. When the mask contains small values, the kernel achieves up to 82× speedup over the previous version. The change also improves performance for non-masked NVFP4 expert quantization (`scaled_fp4_experts_quant`) and NVFP4 g...
[{"scope": "kernel", "hardware": null, "model": "DeepEP", "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 82, "speedup": 82.0}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": nul...
41.75
null
sglang
5c34b4f1c769fc1150a39b96a4673559d6657a8e
2025-08-29T17:17:03-07:00
9,556
https://github.com/sgl-project/sglang/pull/9556
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
[NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf (#9556)
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 @@ -394,9 +394,8 @@ torch::Tensor& output_scale, torch::Tensor const& input, torch::Tensor const& input_global_scale, - torch::Tensor const& input_offset_by_experts, - torch::Tensor const& output_scale_offset_by_experts...
2
3
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [NVIDIA] [2/N] Optimize `silu_and_mul_scaled_fp4_grouped_quant` perf Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Licens...
This PR further optimizes `silu_and_mul_scaled_fp4_grouped_quant` for DeepEP low-latency scenarios. When the mask contains small values, the kernel achieves up to 82× speedup over the previous version. The change also improves performance for non-masked NVFP4 expert quantization (`scaled_fp4_experts_quant`) and NVFP4 g...
[{"scope": "kernel", "hardware": null, "model": "DeepEP", "shape": null, "batch_size": null, "metric": "performance", "unit": null, "higher_is_better": true, "baseline": null, "optimized": null, "stated_speedup": 82, "speedup": 82.0}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": nul...
41.75
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
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 @@ -105,7 +105,19 @@ #define CHECK_EQ(a, b) TORCH_CHECK((a) == (b), "CHECK_EQ(" #a ", " #b ") failed. ", a, " vs ", b) -// parallel routines +// [NB] Parallel Routines +// +// * at::parallel_for - applies for most of generic use cases, this will be...
118
1
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/common.h). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #include <ATen/ATen.h> #include <ATen/Parallel.h> #include <ATen/record_function.h> #if defined(_OPENMP) #incl...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
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 @@ -254,7 +254,7 @@ return; } - // pattern: 1-4-16 + // pattern: 1-4-16, N = 16, 32, 48, 64 constexpr int64_t BLOCK_M = 4; constexpr int64_t BLOCK_N = 64; const int64_t MB = div_up(M, BLOCK_M); @@ -268,35 +268,59 @@ switch (...
30
14
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/gemm.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "gemm.h" #include "common.h" #include "vec.h" namespace { // packed layout: // quants {N, K} int8_t // com...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/gemm.h
cpp
Apache-2.0
#pragma once #include <ATen/native/CPUBlas.h> #include "common.h" // amx-bf16 #define TILE_M 16 #define TILE_N 16 #define TILE_K 32 // block size for AMX gemm constexpr int block_size_m() { return 2 * TILE_M; } constexpr int block_size_n() { return 2 * TILE_N; } // define threshold using brgemm (intel AMX) temp...
#pragma once #include <ATen/native/CPUBlas.h> #include "common.h" // amx-bf16 #define TILE_M 16 #define TILE_N 16 #define TILE_K 32 // block size for AMX gemm constexpr int block_size_m() { return 2 * TILE_M; } constexpr int block_size_n() { return 2 * TILE_N; } // define threshold using brgemm (intel AMX) temp...
--- sgl-kernel/csrc/cpu/gemm.h +++ sgl-kernel/csrc/cpu/gemm.h @@ -27,10 +27,10 @@ inline bool can_use_brgemm<at::Half>(int M) { return true; } -// TODO: add u8s8 brgemm, this requires PyTorch 2.7 +// this requires PyTorch 2.7 or above template <> inline bool can_use_brgemm<int8_t>(int M) { - return false; + re...
4
3
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/gemm.h). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #pragma once #include <ATen/native/CPUBlas.h> #include "common.h" // amx-bf16 #define TILE_M 16 #define TILE_N 16 #define TIL...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/gemm_fp8.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" // we use 4x32 for BLOCK_M #define BLOCK_SIZE_M_SCALE 4 namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const float* __restrict__ input, int64_t size) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::v...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const float* __restrict__ input, int64_t size) { using bVec = at::vec::Vectorized<scalar_t>; using fVec = at::vec::Vectorized<float>; constexpr int kVecSize = bVec::s...
--- sgl-kernel/csrc/cpu/gemm_fp8.cpp +++ sgl-kernel/csrc/cpu/gemm_fp8.cpp @@ -1,9 +1,6 @@ #include "common.h" #include "gemm.h" #include "vec.h" - -// we use 4x32 for BLOCK_M -#define BLOCK_SIZE_M_SCALE 4 namespace { @@ -250,7 +247,8 @@ int K, int lda, int ldb, - int ldc) { + int ...
36
33
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/gemm_fp8.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" // we use 4x32 for BLOCK_M #define BLOCK_SIZE_M_SCALE 4 namespac...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/gemm_int8.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t, bool has_bias, int BLOCK_M, int BLOCK_N> struct tinygemm_kernel_nn { static inline void apply( const uint8_t* __restrict__ A, const int8_t* __restrict__ B, scalar_t* __restrict__ C, const float* _...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t, bool has_bias, int BLOCK_N> struct scale_C { static inline void apply( scalar_t* __restrict__ C, const int32_t* __restrict__ Ctmp, const int32_t* __restrict__ Bcomp, const float* __restrict__ bias...
--- sgl-kernel/csrc/cpu/gemm_int8.cpp +++ sgl-kernel/csrc/cpu/gemm_int8.cpp @@ -3,6 +3,61 @@ #include "vec.h" namespace { + +template <typename scalar_t, bool has_bias, int BLOCK_N> +struct scale_C { + static inline void apply( + scalar_t* __restrict__ C, + const int32_t* __restrict__ Ctmp, + const ...
70
12
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/gemm_int8.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t, bool has_bias, int BLO...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/moe.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE]: Fused MoE kernel with AMX // // This file contains implementations for // * `moe_align_block_size` // * `fused_moe` // // The functionality is identical to triton kernel, excepts: // * fuse silu_and_mul with gemm1, therefore...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE]: Fused MoE kernel with AMX // // This file contains implementations for // * `moe_align_block_size` // * `fused_moe` // // The functionality is identical to triton kernel, excepts: // * fuse silu_and_mul with gemm1, therefore...
--- sgl-kernel/csrc/cpu/moe.cpp +++ sgl-kernel/csrc/cpu/moe.cpp @@ -579,35 +579,30 @@ const int64_t stride_e = 2 * N * K; const int64_t stride_n = K; + int64_t avg_M = std::max(int64_t(1), M * topk / E); + const bool use_brgemm = can_use_brgemm<scalar_t>(avg_M); + // here we only parallel on half of 2N to ...
43
73
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/moe.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE]: Fused MoE kernel with AMX // // This file co...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/moe_fp8.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const scalar_t* __restrict__ input, int64_t size) { using Vec = at::vec::Vectorized<scalar_t>; // no remainder #pragma GCC unroll 4 for (int64_t d = 0; d < size; d += V...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const scalar_t* __restrict__ input, int64_t size) { using Vec = at::vec::Vectorized<scalar_t>; // no remainder #pragma GCC unroll 4 for (int64_t d = 0; d < size; d += V...
--- sgl-kernel/csrc/cpu/moe_fp8.cpp +++ sgl-kernel/csrc/cpu/moe_fp8.cpp @@ -174,18 +174,18 @@ const int64_t stride_e = 2 * N * K; const int64_t stride_n = K; + int64_t avg_M = std::max(int64_t(1), M * topk / E); + const bool use_brgemm = can_use_brgemm<at::Float8_e4m3fn>(avg_M); + + int64_t B_tmp_size_per_th...
54
49
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/moe_fp8.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(sc...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/moe_int8.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const scalar_t* __restrict__ input, int64_t size) { using Vec = at::vec::Vectorized<scalar_t>; // no remainder #pragma GCC unroll 4 for (int64_t d = 0; d < size; d += V...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(scalar_t* __restrict__ out, const scalar_t* __restrict__ input, int64_t size) { using Vec = at::vec::Vectorized<scalar_t>; // no remainder #pragma GCC unroll 4 for (int64_t d = 0; d < size; d += V...
--- sgl-kernel/csrc/cpu/moe_int8.cpp +++ sgl-kernel/csrc/cpu/moe_int8.cpp @@ -107,6 +107,120 @@ for (; d < size; ++d) { out[d] = static_cast<scalar_t>(input[d] + float(input2[d]) * scale); } +} + +template <typename scalar_t, int BLOCK_N> +inline void silu_and_mul( + scalar_t* __restrict__ C, + const i...
336
98
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/moe_int8.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { template <typename scalar_t> inline void copy_stub(s...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
5ad296bda140117e4eb85ce781955d94fb221973
2025-08-29T08:21:55+08:00
8,750
https://github.com/sgl-project/sglang/pull/8750
Optimize prefill performance on cpu backend (#8750)
Optimize prefill performance on cpu backend (#8750)
sgl-kernel/csrc/cpu/qkv_proj.cpp
cpp
Apache-2.0
#include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE]: Fused kernel for QKV projection with weight absorption and RoPE // // 1. `q_a_proj` and `kv_a_proj_with_mqa` fused into one gemm, // otherwise we need to split IC for the 2nd gemm. // 2. `q_a_layernorm` and `kv_a_layernorm` fused i...
#include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE]: Fused kernel for QKV projection with weight absorption and RoPE // // 1. `q_a_proj` and `kv_a_proj_with_mqa` fused into one gemm, // otherwise we need to split IC for the 2nd gemm. // 2. `q_a_layernorm` and `kv_a_layernorm` fused i...
--- sgl-kernel/csrc/cpu/qkv_proj.cpp +++ sgl-kernel/csrc/cpu/qkv_proj.cpp @@ -100,8 +100,7 @@ const int64_t NB1 = div_up(N1, BLOCK_N); const int64_t NB = NB0 + NB1; - // TODO: brgemm u8s8 depends on PyTorch 2.7 release. - const bool use_brgemm = false; + const bool use_brgemm = can_use_brgemm<int8_t>(M); ...
1
2
9
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/qkv_proj.cpp). Goal: Optimize prefill performance on cpu backend Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "gemm.h" #include "vec.h" namespace { // [NOTE]: Fused kernel for QKV projection with weig...
## Motivation This PR aims at improving prefill performance for CPU backend, it will improve `bfloat16`, `int8_w8a8` and `fp8_w8a8` paths. This one has no effective on decoding performance. ## Modifications * **amx-int8**: enable **amx-int8** for GEMM and MoE kernels. As SGLang pops up with PyTorch 2.7, we are free ...
[{"scope": "kernel", "hardware": "Intel 4th gen Xeon (SPR)", "model": null, "shape": "M=1024,K=4096,N=14336", "batch_size": 1024, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 4.375, "optimized": 3.483, "stated_speedup": null, "speedup": 1.2561}, {"scope": "kernel", "hardware": "Intel 4th ge...
1.3585
null
sglang
0fc54b971e14211d54035b72af1a2af0dd93511e
2025-08-18T04:09:49+08:00
9,272
https://github.com/sgl-project/sglang/pull/9272
[fix]: fix cutlass moe ut and and Opt H20 cutlass groupGemm performance (#9272)
[fix]: fix cutlass moe ut and and Opt H20 cutlass groupGemm performance (#9272) Co-authored-by: wanghanpei <wanghanpei@bytedance.com>
sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cutlass/arch/arch.h> #include <torch/all.h> #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/epilogue/collective/collective_builder.hpp" #include "cutlass/epilogue/collective/default_epilogue.hpp" #include "cutlass/ep...
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cutlass/arch/arch.h> #include <torch/all.h> #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/epilogue/collective/collective_builder.hpp" #include "cutlass/epilogue/collective/default_epilogue.hpp" #include "cutlass/ep...
--- sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu +++ sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu @@ -437,6 +437,34 @@ } } +#define JOIN_STRUCT_PP_NAME(m, n, k, a, b, c) sm90_fp8_pp_config##_##m##_##n##_##k##_##a##_##b##_##c + +#define JOIN_STRUCT_CO_NAME(m, n, k, a, b, c) sm90_fp8_co_config##_##m##_##n##_#...
109
35
2
[]
[ "H20" ]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu). Goal: [fix]: fix cutlass moe ut and and Opt H20 cutlass groupGemm performance Target hardware: H20 Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include...
<!-- 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. fix cutlass moe UT 2. add optimized cutlas...
[]
null
null
sglang
0fc54b971e14211d54035b72af1a2af0dd93511e
2025-08-18T04:09:49+08:00
9,272
https://github.com/sgl-project/sglang/pull/9272
[fix]: fix cutlass moe ut and and Opt H20 cutlass groupGemm performance (#9272)
[fix]: fix cutlass moe ut and and Opt H20 cutlass groupGemm performance (#9272) Co-authored-by: wanghanpei <wanghanpei@bytedance.com>
sgl-kernel/include/utils.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/utils.h +++ sgl-kernel/include/utils.h @@ -252,6 +252,25 @@ CHECK_CUDA_SUCCESS(cudaDeviceGetAttribute(&sm_major, cudaDevAttrComputeCapabilityMajor, device)); CHECK_CUDA_SUCCESS(cudaDeviceGetAttribute(&sm_minor, cudaDevAttrComputeCapabilityMinor, device)); return sm_major * 10 + sm_minor;...
19
0
2
[]
[ "H20" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/utils.h). Goal: [fix]: fix cutlass moe ut and and Opt H20 cutlass groupGemm performance Target hardware: H20 Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2....
<!-- 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. fix cutlass moe UT 2. add optimized cutlas...
[]
null
null
sglang
eff4eb3fdd81a82ac76ae16250d06c48fd7ab03e
2025-08-15T22:08:11-07:00
7,667
https://github.com/sgl-project/sglang/pull/7667
Add fp4 quantize before all-gather for Flashinfer cutlass MoE DP (max throughput) (#7667)
Add fp4 quantize before all-gather for Flashinfer cutlass MoE DP (max throughput) (#7667)
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_te...
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_te...
--- python/sglang/srt/layers/dp_attention.py +++ python/sglang/srt/layers/dp_attention.py @@ -72,6 +72,7 @@ _device: torch.device _global_dp_buffer_len: int _local_dp_buffer_len: int + _global_num_tokens: Optional[List[int]] @classmethod def set_metadata(cls, hidden_size: int, dtype: torch...
23
4
8
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/dp_attention.py). Goal: Add fp4 quantize before all-gather for Flashinfer cutlass MoE DP (max throughput) Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations import functools import l...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation The goal of this PR is to optimize communications f...
[{"scope": "e2e", "hardware": null, "model": "nvidia/DeepSeek-R1-0528-FP4", "shape": null, "batch_size": 1024, "metric": "benchmark duration", "unit": "s", "higher_is_better": false, "baseline": 75.54, "optimized": 69.06, "stated_speedup": null, "speedup": 1.0938}, {"scope": "e2e", "hardware": null, "model": "nvidia/De...
null
1.0938
sglang
eff4eb3fdd81a82ac76ae16250d06c48fd7ab03e
2025-08-15T22:08:11-07:00
7,667
https://github.com/sgl-project/sglang/pull/7667
Add fp4 quantize before all-gather for Flashinfer cutlass MoE DP (max throughput) (#7667)
Add fp4 quantize before all-gather for Flashinfer cutlass MoE DP (max throughput) (#7667)
python/sglang/srt/layers/logits_processor.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/logits_processor.py +++ python/sglang/srt/layers/logits_processor.py @@ -191,7 +191,11 @@ else: self.global_dp_buffer_len = self.global_dp_buffer_len - set_dp_buffer_len(self.global_dp_buffer_len, self.dp_local_num_tokens) + set_dp_buffer_len( + ...
5
1
8
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/logits_processor.py). Goal: Add fp4 quantize before all-gather for Flashinfer cutlass MoE DP (max throughput) Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Ap...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation The goal of this PR is to optimize communications f...
[{"scope": "e2e", "hardware": null, "model": "nvidia/DeepSeek-R1-0528-FP4", "shape": null, "batch_size": 1024, "metric": "benchmark duration", "unit": "s", "higher_is_better": false, "baseline": 75.54, "optimized": 69.06, "stated_speedup": null, "speedup": 1.0938}, {"scope": "e2e", "hardware": null, "model": "nvidia/De...
null
1.0938
sglang
4fc09e0df0f018d74bbc99e16e11e9530d198b1e
2025-08-15T01:46:16-07:00
8,777
https://github.com/sgl-project/sglang/pull/8777
Fp4 MOE quant kernel optimization (#8777)
Fp4 MOE quant kernel optimization (#8777) Co-authored-by: Rain Jiang <96632942+rainj-me@users.noreply.github.com>
sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cuda_fp8.h> #include <cuda_runtime.h> #include <torch/all.h> template <typename T> struct TypeConverter { using Type = half2; }; // keep for generality template <> struct TypeConverter<half2> { using Type = half; }; template <> struct ...
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cuda_fp8.h> #include <cuda_runtime.h> #include <torch/all.h> template <typename T> struct TypeConverter { using Type = half2; }; // keep for generality template <> struct TypeConverter<half2> { using Type = half; }; template <> struct ...
--- sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu +++ sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu @@ -240,10 +240,111 @@ } // Use UE4M3 by default. -template <class Type, bool UE8M0_SF = false> +template <class Type, bool UE8M0_SF = false, bool SMALL_NUM_EXPERTS = false> __global__ void #if defined(__CUDA_ARCH__) && ...
232
51
1
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/nvfp4_expert_quant.cu). Goal: Fp4 MOE quant kernel optimization Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cuda_fp8.h> #include <cuda_runtime...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Port vLLM's [FP4 MoE kernel optimization (PR #19500)]...
[{"scope": "kernel", "hardware": "NVIDIA B200", "model": null, "shape": null, "batch\u6e38\u620f\u526f\u672c_size": null, "metric": "Avg Time", "unit": "sec", "higher_is_better": false, "baseline": 68.22, "optimized": 59.17, "stated_speedup": 1.13, "speedup": 1.1529}]
1.1529
null
sglang
841810f227d5c8c9385749df811272eebc8e5845
2025-08-13T21:59:22-07:00
8,818
https://github.com/sgl-project/sglang/pull/8818
[Perf] Tunings for SM100 FP8 CUTLASS kernel (#8818)
[Perf] Tunings for SM100 FP8 CUTLASS kernel (#8818)
sgl-kernel/csrc/gemm/fp8_gemm_kernel.cu
cuda
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/gemm/fp8_gemm_kernel.cu +++ sgl-kernel/csrc/gemm/fp8_gemm_kernel.cu @@ -48,6 +48,7 @@ #include <cutlass/gemm/kernel/gemm_universal.hpp> #include <cutlass/util/packed_stride.hpp> +#include "math.hpp" #include "utils.h" using namespace cute; @@ -1019,8 +1020,18 @@ const torch::Tensor& sca...
126
24
1
[]
[ "SM100" ]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/fp8_gemm_kernel.cu). Goal: [Perf] Tunings for SM100 FP8 CUTLASS kernel Target hardware: SM100 Target models: unspecified Current file: ```cuda /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "Lice...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Port vLLM's https://github.com/vllm-project/vllm/p...
[]
null
null
sglang
5c31b35db28e740c5cf4152e09e8d641057d8c03
2025-08-09T17:16:07-07:00
8,245
https://github.com/sgl-project/sglang/pull/8245
[hicache] Optimization for DMA copy (#8245)
[hicache] Optimization for DMA copy (#8245)
sgl-kernel/csrc/kvcacheio/transfer.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAException.h> #include <c10/util/irange.h> #include <cstdint> #include "pytorch_extension_utils.h" __device__ __forceinline__ void transfer_item_warp(int32_t lane_id, const void* src_addr, void* dst_addr, int64_t item_size_bytes) { // todo, different chunk s...
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAException.h> #include <c10/util/irange.h> #include <cstdint> #include "pytorch_extension_utils.h" __device__ __forceinline__ void transfer_item_warp(int32_t lane_id, const void* src_addr, void* dst_addr, int64_t item_size_bytes) { // todo, different chunk s...
--- sgl-kernel/csrc/kvcacheio/transfer.cu +++ sgl-kernel/csrc/kvcacheio/transfer.cu @@ -451,15 +451,33 @@ auto src_indices_cpu = src_indices.cpu(); auto dst_indices_cpu = dst_indices.cpu(); - const int64_t num_pages = src_indices_cpu.size(0) / page_size; + const auto num_indices = src_indices_cpu.numel(); ...
24
6
1
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/kvcacheio/transfer.cu). Goal: [hicache] Optimization for DMA copy Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAException.h> #include <c10/util/irange.h> #include <cst...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Using `cudaMemcpy` for KV cache offloading is ineff...
[]
null
null
sglang
3f2e315f6e5beb210b981ba07c4da88f703ccc50
2025-08-09T15:29:12+08:00
8,962
https://github.com/sgl-project/sglang/pull/8962
optimize: reduce shulffle and quantization overhead in cutlass_moe sm90 (#8962)
optimize: reduce shulffle and quantization overhead in cutlass_moe sm90 (#8962) Co-authored-by: 戚余航 <qiyuhang@bytedance.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 @@ -1356,3 +1356,62 @@ expert_tokens_alignment, ) return a_q, sfa + + +@triton.jit +def _per_group_transpose( + data_ptr: torch.Tensor, + trans_data_ptr: torch.Tensor, + expert_off...
59
0
2
[]
[ "SM90" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: optimize: reduce shulffle and quantization overhead in cutlass_moe sm90 Target hardware: SM90 Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, V...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation <!-- Explain the purpose of this PR and the goals i...
[]
null
null
sglang
0475448ee303a361d00783274d544ae10977a3ff
2025-08-06T21:37:50+08:00
8,860
https://github.com/sgl-project/sglang/pull/8860
Optimize triton swa kernel by skipping computation (#8860)
Optimize triton swa kernel by skipping computation (#8860)
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 @@ -134,38 +134,6 @@ start_n = tl.multiple_of(start_n, BLOCK_N) mask_n = (start_n + offs_n) < cur_seq_len_prefix - offs_kv_loc = tl.load( - kv...
122
105
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_ops/extend_attention.py). Goal: Optimize triton swa kernel by skipping computation Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Apache Licen...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation For triton sliding window attention, when mask for ...
[]
null
null
sglang
d9def43dcdfd961c4fb2d8eee72f30681268abe3
2025-08-03T12:13:47+08:00
8,722
https://github.com/sgl-project/sglang/pull/8722
[Perf]Use Cooperative Schedule for H100 & H200 & H800 in fp8_blockwise_scaled_grouped_mm (#8722)
[Perf]Use Cooperative Schedule for H100 & H200 & H800 in fp8_blockwise_scaled_grouped_mm (#8722)
sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cutlass/arch/arch.h> #include <torch/all.h> #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/epilogue/collective/collective_builder.hpp" #include "cutlass/epilogue/collective/default_epilogue.hpp" #include "cutlass/ep...
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cutlass/arch/arch.h> #include <torch/all.h> #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/epilogue/collective/collective_builder.hpp" #include "cutlass/epilogue/collective/default_epilogue.hpp" #include "cutlass/ep...
--- sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu +++ sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu @@ -485,7 +485,8 @@ torch::TensorOptions options_int = torch::TensorOptions().dtype(torch::kInt64).device(a.device()); torch::Tensor problem_sizes_transpose = torch::empty(num_experts * 3, options_int); - if...
3
2
1
[]
[ "H100", "H200", "H800" ]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu). Goal: [Perf]Use Cooperative Schedule for H100 & H200 & H800 in fp8_blockwise_scaled_grouped_mm Target hardware: H100, H200, H800 Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Fix https://github.com/sgl-project/sglang/pull/7278#...
[]
null
null
sglang
7a4309cc8a56e7a2cffba82a5189b51fd5776259
2025-07-29T23:31:54+08:00
8,499
https://github.com/sgl-project/sglang/pull/8499
[sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% (#8499)
[sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% (#8499) Co-authored-by: Ke Bao <ispobaoke@gmail.com>
sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cmath> #include <cub/block/block_reduce.cuh> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <typename T> __global__ void per_tensor_absmax_kernel(const T* __restrict__ input, float* __restrict__ output_s, const int64_t...
#include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cmath> #include <cub/block/block_reduce.cuh> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <typename T> __global__ void per_tensor_absmax_kernel(const T* __restrict__ input, float* __restrict__ output_s, const int64_t...
--- sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu +++ sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu @@ -44,10 +44,10 @@ } } -template <typename T> +template <typename T, typename DST_DTYPE> __global__ void per_tensor_quant_fp8_kernel( const T* __restrict__ input, - FP8_TYPE* __restrict__ output, + DST_D...
7
7
3
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu). Goal: [sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #inc...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow: https://github.com/sgl-project/sglang/pull/...
[{"scope": "kernel", "hardware": "B200", "model": null, "shape": "seq_len=64", "batch_size": 16, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 25.792001, "optimized": 23.968, "stated_speedup": null, "speedup": 1.0761}, {"scope": "kernel", "hardware": "B200", "model": null, "shape": "seq_len=...
1.2544
1.4431
sglang
7a4309cc8a56e7a2cffba82a5189b51fd5776259
2025-07-29T23:31:54+08:00
8,499
https://github.com/sgl-project/sglang/pull/8499
[sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% (#8499)
[sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% (#8499) Co-authored-by: Ke Bao <ispobaoke@gmail.com>
sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cuda_fp8.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" __device__ __forceinline__ float GroupReduceMax(float val, const int tid) { unsigned mask = 0xffff; val = fmaxf(val, __shfl_xor_sync(mask, val, 8)...
#include <ATen/cuda/CUDAContext.h> #include <cuda_fp8.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" __device__ __forceinline__ float GroupReduceMax(float val, const int tid) { unsigned mask = 0xffff; val = fmaxf(val, __shfl_xor_sync(mask, val, 8)); val = fmaxf(val, __shfl_xor_syn...
--- sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu +++ sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu @@ -1,5 +1,4 @@ #include <ATen/cuda/CUDAContext.h> -#include <c10/util/Float8_e4m3fn.h> #include <cuda_fp8.h> #include <cmath>
0
1
3
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_token_group_quant_8bit.cu). Goal: [sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow: https://github.com/sgl-project/sglang/pull/...
[{"scope": "kernel", "hardware": "B200", "model": null, "shape": "seq_len=64", "batch_size": 16, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 25.792001, "optimized": 23.968, "stated_speedup": null, "speedup": 1.0761}, {"scope": "kernel", "hardware": "B200", "model": null, "shape": "seq_len=...
1.2544
1.4431
sglang
7a4309cc8a56e7a2cffba82a5189b51fd5776259
2025-07-29T23:31:54+08:00
8,499
https://github.com/sgl-project/sglang/pull/8499
[sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% (#8499)
[sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% (#8499) Co-authored-by: Ke Bao <ispobaoke@gmail.com>
sgl-kernel/csrc/gemm/per_token_quant_fp8.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" static constexpr int kWarpSize = 32; // --------------------------------------------------------------------------- // 1. Warp‑local, no shared memory // • One warp handles one token. // • Eight tokens ...
#include <ATen/cuda/CUDAContext.h> #include <cmath> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" static constexpr int kWarpSize = 32; // --------------------------------------------------------------------------- // 1. Warp‑local, no shared memory // • One warp handles one token. // • Eight tokens ...
--- sgl-kernel/csrc/gemm/per_token_quant_fp8.cu +++ sgl-kernel/csrc/gemm/per_token_quant_fp8.cu @@ -12,10 +12,10 @@ // • One warp handles one token. // • Eight tokens per 256‑thread CTA. // --------------------------------------------------------------------------- -template <typename T, int kTokensPerCTA = 8,...
14
15
3
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_token_quant_fp8.cu). Goal: [sgl-kernel performace] fix fp8 quant kernels dispatch __nv_fp8_e4m3 bug to improve performance 10%-20% Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #inc...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow: https://github.com/sgl-project/sglang/pull/...
[{"scope": "kernel", "hardware": "B200", "model": null, "shape": "seq_len=64", "batch_size": 16, "metric": "latency", "unit": "us", "higher_is_better": false, "baseline": 25.792001, "optimized": 23.968, "stated_speedup": null, "speedup": 1.0761}, {"scope": "kernel", "hardware": "B200", "model": null, "shape": "seq_len=...
1.2544
1.4431
sglang
a3398d8478e981659c4d045635e62c8066ca6bae
2025-07-07T09:20:30+08:00
7,794
https://github.com/sgl-project/sglang/pull/7794
Optimize moe align block size kernel (#7794)
Optimize moe align block size kernel (#7794)
sgl-kernel/csrc/moe/moe_align_kernel.cu
cuda
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/moe/moe_align_kernel.cu +++ sgl-kernel/csrc/moe/moe_align_kernel.cu @@ -21,16 +21,10 @@ #include "utils.h" -template <typename T, int N, int Alignment = sizeof(T) * N> -class alignas(Alignment) AlignedArray { - public: - T data[N]; -}; - #define WARP_SIZE 32 #define VEC_SIZE 4 -using Vec =...
108
77
2
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/moe_align_kernel.cu). Goal: Optimize moe align block size kernel Target hardware: unspecified Target models: unspecified Current file: ```cuda /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "Licen...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation - Optimize prefix sum with Blelloch scan (O(logN)) ...
[]
null
null
sglang
a3398d8478e981659c4d045635e62c8066ca6bae
2025-07-07T09:20:30+08:00
7,794
https://github.com/sgl-project/sglang/pull/7794
Optimize moe align block size kernel (#7794)
Optimize moe align block size kernel (#7794)
sgl-kernel/include/utils.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/utils.h +++ sgl-kernel/include/utils.h @@ -363,3 +363,9 @@ } return tensor_padded; } + +// Get the next power of 2 of a number +inline uint32_t next_pow2(uint32_t x) noexcept { + if (x <= 1) return 1; + return 1u << (32 - __builtin_clz(x - 1)); +}
6
0
2
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/utils.h). Goal: Optimize moe align block size kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may n...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation - Optimize prefix sum with Blelloch scan (O(logN)) ...
[]
null
null
sglang
8e9fb43d825508dfacd6b970f19337eb2f755a7a
2025-07-05T13:25:49+08:00
7,782
https://github.com/sgl-project/sglang/pull/7782
Optimize Hopper CUTLASS FP8 Blockwise Grouped GEMM Kernel in Small K Scenario (#7782)
Optimize Hopper CUTLASS FP8 Blockwise Grouped GEMM Kernel in Small K Scenario (#7782)
sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cutlass/arch/arch.h> #include <torch/all.h> #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/epilogue/collective/collective_builder.hpp" #include "cutlass/epilogue/collective/default_epilogue.hpp" #include "cutlass/ep...
#include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> #include <cutlass/arch/arch.h> #include <torch/all.h> #include "cute/tensor.hpp" #include "cutlass/cutlass.h" #include "cutlass/epilogue/collective/collective_builder.hpp" #include "cutlass/epilogue/collective/default_epilogue.hpp" #include "cutlass/ep...
--- sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu +++ sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu @@ -61,7 +61,12 @@ using ArchTag = cutlass::arch::Sm90; using OperatorClass = cutlass::arch::OpClassTensorOp; - using FusionOperation = cutlass::epilogue::fusion::LinearCombination<ElementD, ElementAccumulat...
86
38
1
[]
[ "HOPPER" ]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/fp8_blockwise_moe_kernel.cu). Goal: Optimize Hopper CUTLASS FP8 Blockwise Grouped GEMM Kernel in Small K Scenario Target hardware: HOPPER Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c10/cuda/CUDAGuard.h> ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow https://github.com/sgl-project/sglang/pull/72...
[]
null
null
sglang
2998c4bdf4fea00081978b320b60f4b0ce905297
2025-07-04T03:42:44+08:00
7,744
https://github.com/sgl-project/sglang/pull/7744
[optimize] fuse renormalize into moe_topk_softmax (#7744)
[optimize] fuse renormalize into moe_topk_softmax (#7744) Co-authored-by: ispobock <ispobaoke@gmail.com>
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -169,9 +169,7 @@ "pad_sorted_token_ids) -> ()"); m.impl("moe_align_block_size", torch::kCUDA, &moe_align_block_size); - m.def( - "topk_softmax(Tensor! topk_weights, Tensor! topk_indices, Tensor! " - "token_expert_i...
1
3
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: [optimize] fuse renormalize into moe_topk_softmax Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation fuse normalize into moe took softmax kernel. This P...
[]
null
null
sglang
2998c4bdf4fea00081978b320b60f4b0ce905297
2025-07-04T03:42:44+08:00
7,744
https://github.com/sgl-project/sglang/pull/7744
[optimize] fuse renormalize into moe_topk_softmax (#7744)
[optimize] fuse renormalize into moe_topk_softmax (#7744) Co-authored-by: ispobock <ispobaoke@gmail.com>
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 @@ -41,15 +41,29 @@ /// Alignment requirement in bytes int Alignment = sizeof(T) * N> class alignas(Alignment) AlignedArray { - float data[N]; + T data[N]; }; + +// ========================== Util funct...
161
85
5
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/moe/moe_topk_softmax_kernels.cu). Goal: [optimize] fuse renormalize into moe_topk_softmax Target hardware: unspecified Target models: unspecified Current file: ```cuda // Adapt from https://github.com/vllm-project/vllm/blob/v0.7.3/csrc/moe/topk_softmax_kerne...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation fuse normalize into moe took softmax kernel. This P...
[]
null
null
sglang
2998c4bdf4fea00081978b320b60f4b0ce905297
2025-07-04T03:42:44+08:00
7,744
https://github.com/sgl-project/sglang/pull/7744
[optimize] fuse renormalize into moe_topk_softmax (#7744)
[optimize] fuse renormalize into moe_topk_softmax (#7744) Co-authored-by: ispobock <ispobaoke@gmail.com>
sgl-kernel/csrc/torch_extension_rocm.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/torch_extension_rocm.cc +++ sgl-kernel/csrc/torch_extension_rocm.cc @@ -63,9 +63,7 @@ "pad_sorted_token_ids) -> ()"); m.impl("moe_align_block_size", torch::kCUDA, &moe_align_block_size); - m.def( - "topk_softmax(Tensor! topk_weights, Tensor! topk_indices, Tensor! " - "token_ex...
1
3
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/torch_extension_rocm.cc). Goal: [optimize] fuse renormalize into moe_topk_softmax Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation fuse normalize into moe took softmax kernel. This P...
[]
null
null
sglang
2998c4bdf4fea00081978b320b60f4b0ce905297
2025-07-04T03:42:44+08:00
7,744
https://github.com/sgl-project/sglang/pull/7744
[optimize] fuse renormalize into moe_topk_softmax (#7744)
[optimize] fuse renormalize into moe_topk_softmax (#7744) Co-authored-by: ispobock <ispobaoke@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 @@ -222,10 +222,7 @@ bool pad_sorted_token_ids); void topk_softmax( - torch::Tensor& topk_weights, - torch::Tensor& topk_indices, - torch::Tensor& token_expert_indices, - torch::Tensor& gating_output); + torch::Tensor...
1
4
5
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [optimize] fuse renormalize into moe_topk_softmax Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation fuse normalize into moe took softmax kernel. This P...
[]
null
null
sglang
18efb5e8e0ed467f6dc42680d88787f5ed6c074e
2025-06-09T10:37:34+08:00
6,929
https://github.com/sgl-project/sglang/pull/6929
[perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 (#6929)
[perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 (#6929)
sgl-kernel/csrc/attention/cutlass_mla_kernel.cu
cuda
Apache-2.0
/* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. 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/...
/* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. 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/...
--- sgl-kernel/csrc/attention/cutlass_mla_kernel.cu +++ sgl-kernel/csrc/attention/cutlass_mla_kernel.cu @@ -22,8 +22,9 @@ #include <torch/all.h> #include <cute/tensor.hpp> -#include <device/sm100_mla.hpp> -#include <kernel/sm100_mla_tile_scheduler.hpp> + +#include "cutlass_sm100_mla/device/sm100_mla.hpp" +#include ...
54
24
4
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/attention/cutlass_mla_kernel.cu). Goal: [perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 Target hardware: unspecified Target models: unspecified Current file: ```cuda /* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. Copy...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation An inelegant workaround, thus the kernel have to be...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "heads=128", "batch_size": 1, "metric": "bandwidth", "unit": "GB/s", "higher_is_better": true, "baseline": null, "optimized": 18.775741, "stated_speedup": 1.8, "speedup": 1.8}, {"scope": "kernel", "hardware": null, "model": null, "shape": "heads=64", "batch...
1.8
null
sglang
18efb5e8e0ed467f6dc42680d88787f5ed6c074e
2025-06-09T10:37:34+08:00
6,929
https://github.com/sgl-project/sglang/pull/6929
[perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 (#6929)
[perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 (#6929)
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -60,7 +60,7 @@ m.impl("merge_state_v2", torch::kCUDA, &merge_state_v2); m.def( "cutlass_mla_decode(Tensor! out, Tensor q_nope_and_q_pe, Tensor kv_c_and_k_pe_cache, Tensor seq_lens, Tensor " - "page_table, Tensor workspa...
1
1
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: [perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Lice...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation An inelegant workaround, thus the kernel have to be...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "heads=128", "batch_size": 1, "metric": "bandwidth", "unit": "GB/s", "higher_is_better": true, "baseline": null, "optimized": 18.775741, "stated_speedup": 1.8, "speedup": 1.8}, {"scope": "kernel", "hardware": null, "model": null, "shape": "heads=64", "batch...
1.8
null
sglang
18efb5e8e0ed467f6dc42680d88787f5ed6c074e
2025-06-09T10:37:34+08:00
6,929
https://github.com/sgl-project/sglang/pull/6929
[perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 (#6929)
[perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 (#6929)
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 @@ -109,8 +109,10 @@ torch::Tensor const& kv_c_and_k_pe_cache, torch::Tensor const& seq_lens, torch::Tensor const& page_table, - torch::Tensor const& workspace); -int64_t cutlass_mla_get_workspace_size(int64_t max_seq_len,...
4
2
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [perf][sgl-kernel] extend cutlass_mla_decode to support num_head < 128 Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache Lice...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation An inelegant workaround, thus the kernel have to be...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "heads=128", "batch_size": 1, "metric": "bandwidth", "unit": "GB/s", "higher_is_better": true, "baseline": null, "optimized": 18.775741, "stated_speedup": 1.8, "speedup": 1.8}, {"scope": "kernel", "hardware": null, "model": null, "shape": "heads=64", "batch...
1.8
null
sglang
2a413829f42b8e8433a3e7cfd91cc9cb241cfbc0
2025-06-07T17:43:50+08:00
5,955
https://github.com/sgl-project/sglang/pull/5955
Add triton version as a fused_moe_triton config search key to avoid performace decrease in different Triton version (#5955)
Add triton version as a fused_moe_triton config search key to avoid performace decrease in different Triton version (#5955)
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
triton
Apache-2.0
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py @@ -936,8 +936,15 @@ # directory json_file_name = get_config_file_name(E, N, dtype, [block_n, block_k]) + # We found that using the fused_moe_kernel config from Triton 3.1.0 with ...
8
1
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py). Goal: Add triton version as a fused_moe_triton config search key to avoid performace decrease in different Triton version Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Follow https://github.com/sgl-project/sglang/pull/5...
[]
null
null
sglang
b819381feca4467f803dce1cb01533987c270003
2025-06-05T23:00:18-07:00
6,838
https://github.com/sgl-project/sglang/pull/6838
AITER backend extension and workload optimizations (#6838)
AITER backend extension and workload optimizations (#6838) Co-authored-by: wunhuang <wunhuang@amd.com> Co-authored-by: Hubert Lu <Hubert.Lu@amd.com>
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
triton
Apache-2.0
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py @@ -1332,7 +1332,7 @@ if ( not (use_fp8_w8a8 or use_int8_w8a8) or block_shape is not None - or (_is_hip and get_bool_env_var("SGLANG_AITER_MOE")) + or (_is_h...
1
1
6
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py). Goal: AITER backend extension and workload optimizations Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1...
`Co-author: @kkHuang-amd ` <!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation - DeepSeek optimization ...
[]
null
null
sglang
ff00895c46a4549f6c4279b1f8de24c05f1fa7ef
2025-06-03T08:37:34+08:00
6,456
https://github.com/sgl-project/sglang/pull/6456
Add CPU optimized kernels for topk and rope fusions (#6456)
Add CPU optimized kernels for topk and rope fusions (#6456)
sgl-kernel/csrc/cpu/norm.cpp
cpp
Apache-2.0
#include "common.h" #include "vec.h" namespace { // NB: avoid using `at::vec::map<>` on bfloat16 or half template <typename scalar_t> void rmsnorm_kernel_impl( scalar_t* __restrict__ output, const scalar_t* __restrict__ input, const scalar_t* __restrict__ weight, int64_t batch_size, int64_t hidden...
#include "common.h" #include "vec.h" namespace { // NB: avoid using `at::vec::map<>` on bfloat16 or half // Llama4TextL2Norm template <typename scalar_t> void l2norm_kernel_impl( scalar_t* __restrict__ output, const scalar_t* __restrict__ input, int64_t batch_size, int64_t hidden_size, float eps =...
--- sgl-kernel/csrc/cpu/norm.cpp +++ sgl-kernel/csrc/cpu/norm.cpp @@ -4,6 +4,67 @@ namespace { // NB: avoid using `at::vec::map<>` on bfloat16 or half +// Llama4TextL2Norm +template <typename scalar_t> +void l2norm_kernel_impl( + scalar_t* __restrict__ output, + const scalar_t* __restrict__ input, + int64_...
77
0
4
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/norm.cpp). Goal: Add CPU optimized kernels for topk and rope fusions Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "vec.h" namespace { // NB: avoid using `at::vec::map<>` on bfloat16 or half template <...
## Overview: This PR is adding the following CPU optimized sgl-kernels that are at least used in Qwen3/LLama1-4 models: ``` - TopK fusions: TopK+sigmoid softmax+TopK - Norm fusion: L2norm - RoPE fusions: origin rope fusion (gpt_neox style and gptj style) ```
[]
null
null
sglang
ff00895c46a4549f6c4279b1f8de24c05f1fa7ef
2025-06-03T08:37:34+08:00
6,456
https://github.com/sgl-project/sglang/pull/6456
Add CPU optimized kernels for topk and rope fusions (#6456)
Add CPU optimized kernels for topk and rope fusions (#6456)
sgl-kernel/csrc/cpu/rope.cpp
cpp
Apache-2.0
#include "common.h" #include "vec.h" namespace { template <typename scalar_t> void rope_kernel_impl( scalar_t* __restrict__ q_pe_out, scalar_t* __restrict__ k_pe_out, int64_t* __restrict__ t_pos, scalar_t* __restrict__ q_pe, scalar_t* __restrict__ k_pe, scalar_t* __restrict__ t_emb_pos, in...
#include "common.h" #include "vec.h" namespace { template <typename scalar_t> void rotary_embedding_3D_kernel_impl( scalar_t* __restrict__ query_out, scalar_t* __restrict__ key_out, int64_t* __restrict__ positions, scalar_t* __restrict__ query, scalar_t* __restrict__ key, scalar_t* __restrict_...
--- sgl-kernel/csrc/cpu/rope.cpp +++ sgl-kernel/csrc/cpu/rope.cpp @@ -4,126 +4,343 @@ namespace { template <typename scalar_t> -void rope_kernel_impl( - scalar_t* __restrict__ q_pe_out, - scalar_t* __restrict__ k_pe_out, - int64_t* __restrict__ t_pos, - scalar_t* __restrict__ q_pe, - scalar_t* __rest...
310
93
4
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/rope.cpp). Goal: Add CPU optimized kernels for topk and rope fusions Target hardware: CPU Target models: unspecified Current file: ```cpp #include "common.h" #include "vec.h" namespace { template <typename scalar_t> void rope_kernel_impl( scalar_t* ...
## Overview: This PR is adding the following CPU optimized sgl-kernels that are at least used in Qwen3/LLama1-4 models: ``` - TopK fusions: TopK+sigmoid softmax+TopK - Norm fusion: L2norm - RoPE fusions: origin rope fusion (gpt_neox style and gptj style) ```
[]
null
null
sglang
ff00895c46a4549f6c4279b1f8de24c05f1fa7ef
2025-06-03T08:37:34+08:00
6,456
https://github.com/sgl-project/sglang/pull/6456
Add CPU optimized kernels for topk and rope fusions (#6456)
Add CPU optimized kernels for topk and rope fusions (#6456)
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 @@ -157,6 +157,101 @@ } } +template <typename scalar_t, int NUM_EXPERTS> +void topk_sigmoid_kernel_impl( + float* __restrict__ topk_weights, + int32_t* __restrict__ topk_ids, + const scalar_t* __restrict__ gating_output, + int64_t num_t...
221
0
4
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/topk.cpp). Goal: Add CPU optimized kernels for topk and rope fusions 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* ...
## Overview: This PR is adding the following CPU optimized sgl-kernels that are at least used in Qwen3/LLama1-4 models: ``` - TopK fusions: TopK+sigmoid softmax+TopK - Norm fusion: L2norm - RoPE fusions: origin rope fusion (gpt_neox style and gptj style) ```
[]
null
null
sglang
ff00895c46a4549f6c4279b1f8de24c05f1fa7ef
2025-06-03T08:37:34+08:00
6,456
https://github.com/sgl-project/sglang/pull/6456
Add CPU optimized kernels for topk and rope fusions (#6456)
Add CPU optimized kernels for topk and rope fusions (#6456)
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 @@ -23,6 +23,9 @@ // silu_and_mul at::Tensor silu_and_mul_cpu(at::Tensor& input); +// l2norm +at::Tensor l2norm_cpu(at::Tensor& input, double eps); + // rmsnorm at::Tensor rmsnorm_cpu(at::Tensor& input, at::Tensor& wei...
25
4
4
[]
[ "CPU" ]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/cpu/torch_extension_cpu.cpp). Goal: Add CPU optimized kernels for topk and rope fusions Target hardware: CPU Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version 2.0 (t...
## Overview: This PR is adding the following CPU optimized sgl-kernels that are at least used in Qwen3/LLama1-4 models: ``` - TopK fusions: TopK+sigmoid softmax+TopK - Norm fusion: L2norm - RoPE fusions: origin rope fusion (gpt_neox style and gptj style) ```
[]
null
null
sglang
c087ddd6865a52634326a05af66429cb5531cd16
2025-05-28T15:15:23+08:00
6,627
https://github.com/sgl-project/sglang/pull/6627
Refine pre_reorder_triton_kernel slightly to improve performance (#6627)
Refine pre_reorder_triton_kernel slightly to improve performance (#6627) Co-authored-by: luoyuan.luo <luoyuan.luo@antgroup.com>
python/sglang/srt/layers/moe/ep_moe/kernels.py
triton
Apache-2.0
import logging from typing import List, Optional import torch import triton from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import dispose_tensor, is_cuda logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _is_cuda: from sglang.srt.layers.quantizat...
import logging from typing import List, Optional import torch import triton from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import dispose_tensor, is_cuda logger = logging.getLogger(__name__) _is_cuda = is_cuda() if _is_cuda: from sglang.srt.layers.quantizat...
--- python/sglang/srt/layers/moe/ep_moe/kernels.py +++ python/sglang/srt/layers/moe/ep_moe/kernels.py @@ -184,8 +184,10 @@ src_idx = tl.program_id(0) src2dst_ptr = src2dst_ptr + src_idx * topk topk_ids_ptr = topk_ids_ptr + src_idx * topk - src_ptr = input_ptr + src_idx * hidden_size + + vec = tl....
9
4
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: Refine pre_reorder_triton_kernel slightly to improve performance Target hardware: unspecified Target models: unspecified Current file: ```python import logging from typing import List, Optional import torch import tr...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation In ep_moe kernel _pre_reorder_triton_kernel_ and _p...
[{"scope": "kernel", "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}, {"scope": "kernel", "hardware": null, "model": null, "shape": null, "batch_size": null, "...
1.125
null
sglang
25c83fff6a80d9e3d2749f2ead122f96fdc127e9
2025-05-12T02:36:29-04:00
5,558
https://github.com/sgl-project/sglang/pull/5558
Performing Vocabulary Parallelism for LM Head across Attention TP Groups (#5558)
Performing Vocabulary Parallelism for LM Head across Attention TP Groups (#5558) Co-authored-by: liusy58 <liusy58@linux.alibaba.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 typing import TYPE_CHECKING, List import torch import triton import triton.language as tl from sglang.srt.distributed import ( GroupCoordinator, get_tensor_model_parallel_world_size, get_tp_group...
from __future__ import annotations import functools import logging from contextlib import contextmanager from typing import TYPE_CHECKING, List import torch import triton import triton.language as tl from sglang.srt.distributed import ( GroupCoordinator, get_tensor_model_parallel_world_size, get_tp_group...
--- python/sglang/srt/layers/dp_attention.py +++ python/sglang/srt/layers/dp_attention.py @@ -252,12 +252,12 @@ ) -def tp_reduce_scatter( +def attn_tp_reduce_scatter( output: torch.Tensor, input_list: List[torch.Tensor], ): return get_attention_tp_group().reduce_scatter(output, input_list) ...
2
2
3
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/dp_attention.py). Goal: Performing Vocabulary Parallelism for LM Head across Attention TP Groups Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations import functools import logging fr...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation <!-- Explain the purpose of this PR and the goals i...
[]
null
null
sglang
25c83fff6a80d9e3d2749f2ead122f96fdc127e9
2025-05-12T02:36:29-04:00
5,558
https://github.com/sgl-project/sglang/pull/5558
Performing Vocabulary Parallelism for LM Head across Attention TP Groups (#5558)
Performing Vocabulary Parallelism for LM Head across Attention TP Groups (#5558) Co-authored-by: liusy58 <liusy58@linux.alibaba.com>
python/sglang/srt/layers/logits_processor.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/logits_processor.py +++ python/sglang/srt/layers/logits_processor.py @@ -23,15 +23,16 @@ from torch import nn from sglang.srt.distributed import ( - get_tensor_model_parallel_rank, get_tensor_model_parallel_world_size, tensor_model_parallel_all_gather, ) from sglang.srt.l...
29
8
3
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/logits_processor.py). Goal: Performing Vocabulary Parallelism for LM Head across Attention TP Groups Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Apache Lice...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation <!-- Explain the purpose of this PR and the goals i...
[]
null
null
sglang
18ce468d56aa33a8bebcef0bc3f4777b0d70cdce
2025-04-26T07:24:59+08:00
5,740
https://github.com/sgl-project/sglang/pull/5740
update triton 3.2.0 h200 fused moe triton config and add warning about triton fused_moe_kernel performance degradation due to different Triton versions. (#5740)
update triton 3.2.0 h200 fused moe triton config and add warning about triton fused_moe_kernel performance degradation due to different Triton versions. (#5740)
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
triton
Apache-2.0
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py @@ -940,7 +940,10 @@ ) if os.path.exists(config_file_path): with open(config_file_path) as f: - logger.info("Using configuration from %s for MoE layer.", config_fil...
4
1
1
[]
[ "H200" ]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py). Goal: update triton 3.2.0 h200 fused moe triton config and add warning about triton fused_moe_kernel performance degradation due to different Triton versions. Target hardware: H200 Target models: unspecified Cur...
## Motivation <img width="839" alt="图片" src="https://github.com/user-attachments/assets/06f8db13-b826-4bc1-8523-ff2894478cb4" /> Reproduction commands : ```shell SGL_ENABLE_JIT_DEEPGEMM=0 python3 -m sglang.launch_server --model /DeepSeek-V3 --tp 8 --trust-remote-code --enable-dp-attention --dp-size 8 # Random 1k, 2...
[]
null
null
sglang
99456bcacb81a1e39c710f44d5921c1e60814cda
2025-04-20T15:38:27+08:00
5,432
https://github.com/sgl-project/sglang/pull/5432
[perf] introduce deep gemm group_gemm_masked as bmm (#5432)
[perf] introduce deep gemm group_gemm_masked as bmm (#5432)
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 @@ -44,6 +44,7 @@ fp8_min = -fp8_max _enable_jit_deepgemm = False +_enable_jit_deepgemm_bmm = False if _is_cuda: import deep_gemm from sgl_kernel import ( @@ -53,10 +54,11 @@ ) sm_v...
108
4
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: [perf] introduce deep gemm group_gemm_masked as bmm Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (t...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation per-token-group quant+deep_gemm's grouped_gemm_mask...
[{"scope": "e2e", "hardware": "H200", "model": "DeepSeek-V3", "shape": "input-len=1000, output-len=100", "batch_size": 1, "metric": "Decode median latency", "unit": "s", "higher_is_better": false, "baseline": 0.0172, "optimized": 0.0166, "stated_speedup": null, "speedup": 1.0361}, {"scope": "e2e", "hardware": "H200", "...
null
1.0361
sglang
388e15c0db6b0381a1a7e08dd5b7a028130578fc
2025-04-15T12:28:23+08:00
5,381
https://github.com/sgl-project/sglang/pull/5381
kernel: support slightly faster merge_state_v2 cuda kernel (#5381)
kernel: support slightly faster merge_state_v2 cuda kernel (#5381)
sgl-kernel/csrc/common_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/common_extension.cc +++ sgl-kernel/csrc/common_extension.cc @@ -47,6 +47,8 @@ m.impl("lightning_attention_decode", torch::kCUDA, &lightning_attention_decode); m.def("merge_state(Tensor v_a, Tensor s_a, Tensor v_b, Tensor s_b, Tensor! v_merged, Tensor! s_merged) -> ()"); m.impl("merge_state"...
2
0
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/common_extension.cc). Goal: kernel: support slightly faster merge_state_v2 cuda kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version...
support slightly faster merge_state_v2 cuda kernel - [x] float32 - [x] float16 - [x] bfloat16 - [x] dispatch by scalar_t - [x] unit tests (performance & correctness) - [x] support any headsize which is multiples of 4(float) or 8(half/bfloat16), merge_state v1 seems only support 64,128,256 - [x] slightly faster than m...
[{"scope": "kernel", "hardware": "L20", "model": null, "shape": "tokens=256,heads=8,headsize=32", "batch_size": 256, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 0.0391, "optimized": 0.0204, "stated_speedup": 1.9198, "speedup": 1.9167}, {"scope": "kernel", "hardware": "L20", "model": null, ...
1.0427
null
sglang
388e15c0db6b0381a1a7e08dd5b7a028130578fc
2025-04-15T12:28:23+08:00
5,381
https://github.com/sgl-project/sglang/pull/5381
kernel: support slightly faster merge_state_v2 cuda kernel (#5381)
kernel: support slightly faster merge_state_v2 cuda kernel (#5381)
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 @@ -88,6 +88,8 @@ torch::Tensor output, torch::Tensor new_kv); void merge_state( + at::Tensor v_a, at::Tensor s_a, at::Tensor v_b, at::Tensor s_b, at::Tensor v_merged, at::Tensor s_merged); +void merge_state_v2( at::Tenso...
2
0
4
[]
[]
[]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: kernel: support slightly faster merge_state_v2 cuda kernel Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version...
support slightly faster merge_state_v2 cuda kernel - [x] float32 - [x] float16 - [x] bfloat16 - [x] dispatch by scalar_t - [x] unit tests (performance & correctness) - [x] support any headsize which is multiples of 4(float) or 8(half/bfloat16), merge_state v1 seems only support 64,128,256 - [x] slightly faster than m...
[{"scope": "kernel", "hardware": "L20", "model": null, "shape": "tokens=256,heads=8,headsize=32", "batch_size": 256, "metric": "latency", "unit": "ms", "higher_is_better": false, "baseline": 0.0391, "optimized": 0.0204, "stated_speedup": 1.9198, "speedup": 1.9167}, {"scope": "kernel", "hardware": "L20", "model": null, ...
1.0427
null
sglang
bdde237562ebd70944aef94873a96f765578b048
2025-04-15T03:35:43+08:00
5,370
https://github.com/sgl-project/sglang/pull/5370
[perf] experimental enhance fp8 per-tensor quant (#5370)
[perf] experimental enhance fp8 per-tensor quant (#5370)
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 @@ -839,3 +839,103 @@ ) return C + + +@triton.jit +def _per_tensor_quant_mla_fp8_stage1( + x_ptr, + x_s_ptr, + head_size, + x_stride_h, + x_stride_s, + eps, + fp8_max, + ...
100
0
2
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/quantization/fp8_kernel.py). Goal: [perf] experimental enhance fp8 per-tensor quant Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation 1. fix `input_to_float8` precision 2. impl mla absr...
[{"scope": "e2e", "hardware": null, "model": "RedHatAI/DeepSeek-Coder-V2-Lite-Instruct-FP8", "shape": "input-len=128,output-len=128", "batch_size": 1, "metric": "Decode. median latency", "unit": "s", "higher_is_better": false, "baseline": 0.00732, "optimized": 0.00628, "stated_speedup": null, "speedup": 1.1656}, {"scop...
null
1.1658
sglang
3e4794aad8a2349c1ac3d98d2c6369c637fade18
2025-04-13T01:01:13+08:00
5,294
https://github.com/sgl-project/sglang/pull/5294
refine fused_moe tuning docs (#5294)
refine fused_moe tuning docs (#5294)
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py
triton
Apache-2.0
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
# Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e81738/vllm/model_executor/layers/fused_moe/fused_moe.py """Fused MoE kernel.""" import functools import json import logging import os from typing import Any, Callable, Dict, List, Optional, Tuple import torch import triton im...
--- python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py +++ python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py @@ -956,7 +956,7 @@ logger.warning( ( "Using default MoE config. Performance might be sub-optimal! " - "Config file not found at %s" + "Config fi...
1
1
1
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/fused_moe_triton/fused_moe.py). Goal: refine fused_moe tuning docs Target hardware: unspecified Target models: unspecified Current file: ```python # Adapted from https://github.com/vllm-project/vllm/blob/a6221a144af772fd1a68fe7e627935dc53e8173...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation <!-- Explain the purpose of this PR and the goals i...
[]
null
null
sglang
23c764b18aeb37c42ddedd7468f1a5753df1f232
2025-04-02T00:23:25+08:00
4,767
https://github.com/sgl-project/sglang/pull/4767
[Feature] Support DeepEP Low Latency (#4767)
[Feature] Support DeepEP Low Latency (#4767) Co-authored-by: sleepcoo <sleepcoo@gmail.com> Co-authored-by: laixinn <xielx@shanghaitech.edu.cn> Co-authored-by: ch-wan <cwan39@gatech.edu>
python/sglang/srt/layers/moe/ep_moe/kernels.py
triton
Apache-2.0
import logging from typing import List, Optional import torch import triton import triton.language as tl from sglang.srt.distributed import get_tensor_model_parallel_rank from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import is_cuda _is_cuda = is_cuda() if _is_c...
import logging from typing import List, Optional import torch import triton import triton.language as tl from sglang.srt.distributed import get_tensor_model_parallel_rank from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import is_cuda _is_cuda = is_cuda() if _is_c...
--- python/sglang/srt/layers/moe/ep_moe/kernels.py +++ python/sglang/srt/layers/moe/ep_moe/kernels.py @@ -242,6 +242,148 @@ silu_mul_output = gate_output * up_output * scale silu_mul_output = silu_mul_output.to(OutDtype) tl.store(down_input_ptr + offset, silu_mul_output, mask=mask...
142
0
3
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: [Feature] Support DeepEP Low Latency Target hardware: unspecified Target models: unspecified Current file: ```python import logging from typing import List, Optional import torch import triton import triton.language ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation <!-- Explain the purpose of this PR and the goals i...
[]
null
null
sglang
65c24c28f97bbcabf69008d14c47a72149398385
2025-03-23T23:44:17-07:00
4,396
https://github.com/sgl-project/sglang/pull/4396
[Quant Kernel] refactored per token group quant fp8 to support int8 up-to 2x faster (#4396)
[Quant Kernel] refactored per token group quant fp8 to support int8 up-to 2x faster (#4396)
sgl-kernel/csrc/torch_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/torch_extension.cc +++ sgl-kernel/csrc/torch_extension.cc @@ -98,6 +98,11 @@ " float eps, float fp8_min, float fp8_max) -> ()"); m.impl("sgl_per_token_group_quant_fp8", torch::kCUDA, &sgl_per_token_group_quant_fp8); + m.def( + "sgl_per_token_group_quant_int8(Tensor input, Tensor ou...
5
0
5
[]
[]
[ "2x" ]
Optimize this cpp kernel file from sglang (sgl-kernel/csrc/torch_extension.cc). Goal: [Quant Kernel] refactored per token group quant fp8 to support int8 up-to 2x faster Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation #2965 The new cuda kernel accelerates 1x-2x compar...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "seq_len=64,group_size=128,dst_dtype=torch.int8", "batch_size": 1, "metric": "latency", "unit": null, "higher_is_better": false, "baseline": 10.848, "optimized": 9.152, "stated_speedup": null, "speedup": 1.1853}, {"scope": "kernel", "hardware": null, "model...
1.87
null
sglang
65c24c28f97bbcabf69008d14c47a72149398385
2025-03-23T23:44:17-07:00
4,396
https://github.com/sgl-project/sglang/pull/4396
[Quant Kernel] refactored per token group quant fp8 to support int8 up-to 2x faster (#4396)
[Quant Kernel] refactored per token group quant fp8 to support int8 up-to 2x faster (#4396)
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 @@ -141,6 +141,14 @@ double eps, double fp8_min, double fp8_max); +void sgl_per_token_group_quant_int8( + at::Tensor input, + at::Tensor output_q, + at::Tensor output_s, + int64_t group_size, + double eps, + ...
8
0
5
[]
[]
[ "2x" ]
Optimize this cpp kernel file from sglang (sgl-kernel/include/sgl_kernel_ops.h). Goal: [Quant Kernel] refactored per token group quant fp8 to support int8 up-to 2x faster Target hardware: unspecified Target models: unspecified Current file: ```cpp /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under th...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation #2965 The new cuda kernel accelerates 1x-2x compar...
[{"scope": "kernel", "hardware": null, "model": null, "shape": "seq_len=64,group_size=128,dst_dtype=torch.int8", "batch_size": 1, "metric": "latency", "unit": null, "higher_is_better": false, "baseline": 10.848, "optimized": 9.152, "stated_speedup": null, "speedup": 1.1853}, {"scope": "kernel", "hardware": null, "model...
1.87
null
sglang
c2bd094d6eb621a51a19d6595ddb3ddcc9030970
2025-03-23T05:30:34+08:00
4,643
https://github.com/sgl-project/sglang/pull/4643
Optimize Permute Kernel in DeepEP (#4643)
Optimize Permute Kernel in DeepEP (#4643) Co-authored-by: Cheng Wan <54331508+ch-wan@users.noreply.github.com>
python/sglang/srt/layers/moe/ep_moe/kernels.py
triton
Apache-2.0
import logging from typing import List, Optional import torch import triton import triton.language as tl from sglang.srt.distributed import get_tensor_model_parallel_rank from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import is_cuda _is_cuda = is_cuda() if _is_c...
import logging from typing import List, Optional import torch import triton import triton.language as tl from sglang.srt.distributed import get_tensor_model_parallel_rank from sglang.srt.layers.quantization.fp8_kernel import per_token_group_quant_fp8 from sglang.srt.utils import is_cuda _is_cuda = is_cuda() if _is_c...
--- python/sglang/srt/layers/moe/ep_moe/kernels.py +++ python/sglang/srt/layers/moe/ep_moe/kernels.py @@ -15,52 +15,6 @@ sglang_per_token_group_quant_fp8, ) logger = logging.getLogger(__name__) - - -@triton.jit -def compute_src2dst_triton_kernel( - reorder_ids, src2dst, num_toks, BLOCK_SIZE: tl.conste...
47
49
3
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/moe/ep_moe/kernels.py). Goal: Optimize Permute Kernel in DeepEP Target hardware: unspecified Target models: unspecified Current file: ```python import logging from typing import List, Optional import torch import triton import triton.language as ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation <!-- Explain the purpose of this PR and the goals i...
[]
null
null
sglang
6a384d5c012e424e5baf9891efa5465088e807dc
2025-03-22T00:37:57-07:00
4,639
https://github.com/sgl-project/sglang/pull/4639
Speed up per token and per tensor quant by 15% (#4639)
Speed up per token and per tensor quant by 15% (#4639)
sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cmath> #include <cub/block/block_reduce.cuh> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <typename T> __global__ void per_tensor_absmax_kernel(const T* __restrict__ input, float* __restrict__ output_s, const int64_t...
#include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cmath> #include <cub/block/block_reduce.cuh> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <typename T> __global__ void per_tensor_absmax_kernel(const T* __restrict__ input, float* __restrict__ output_s, const int64_t...
--- sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu +++ sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu @@ -54,42 +54,40 @@ const int grid_size = blockDim.x * gridDim.x; const float scale_val = 1.0f / (*scale); - constexpr uint32_t vec_size = 16 / sizeof(T); - using vec_t = flashinfer::vec_t<T, vec_size>; + // We ...
12
14
2
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_tensor_quant_fp8.cu). Goal: Speed up per token and per tensor quant by 15% Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <c10/util/Float8_e4m3fn.h> #include <cmath> #includ...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation #2965 Improvements 1. Store using `uint4` cast to ...
[]
null
null
sglang
6a384d5c012e424e5baf9891efa5465088e807dc
2025-03-22T00:37:57-07:00
4,639
https://github.com/sgl-project/sglang/pull/4639
Speed up per token and per tensor quant by 15% (#4639)
Speed up per token and per tensor quant by 15% (#4639)
sgl-kernel/csrc/gemm/per_token_quant_fp8.cu
cuda
Apache-2.0
#include <ATen/cuda/CUDAContext.h> #include <cmath> #include <cub/block/block_reduce.cuh> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <typename T> __global__ void per_token_quant_fp8_kernel( const T* __restrict__ input, FP8_TYPE* __restrict__ output_q, float* __restrict__ output_s, ...
#include <ATen/cuda/CUDAContext.h> #include <cmath> #include <cub/block/block_reduce.cuh> #include <flashinfer/vec_dtypes.cuh> #include "utils.h" template <typename T> __global__ void per_token_quant_fp8_kernel( const T* __restrict__ input, FP8_TYPE* __restrict__ output_q, float* __restrict__ output_s, ...
--- sgl-kernel/csrc/gemm/per_token_quant_fp8.cu +++ sgl-kernel/csrc/gemm/per_token_quant_fp8.cu @@ -24,17 +24,19 @@ float max_value = 0.0f; - constexpr uint32_t vec_size = 16 / sizeof(T); - using vec_t = flashinfer::vec_t<T, vec_size>; - const int32_t num_vec_elems = hidden_dim / vec_size; + // We want to st...
17
18
2
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/gemm/per_token_quant_fp8.cu). Goal: Speed up per token and per tensor quant by 15% Target hardware: unspecified Target models: unspecified Current file: ```cuda #include <ATen/cuda/CUDAContext.h> #include <cmath> #include <cub/block/block_reduce.cuh> #inclu...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation #2965 Improvements 1. Store using `uint4` cast to ...
[]
null
null
sglang
c0e9a36c5f5e8e018663a3b84c401780c5999381
2025-03-19T12:25:38+08:00
4,553
https://github.com/sgl-project/sglang/pull/4553
Optimize Triton decoding kernel for dynamic workload (#4553)
Optimize Triton decoding kernel for dynamic workload (#4553)
python/sglang/srt/layers/attention/triton_backend.py
triton
Apache-2.0
from __future__ import annotations from typing import TYPE_CHECKING, Optional, Union import torch import triton from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.utils import create_flashinfer_kv_indices_triton from sglang.srt.layers.dp_attention import get_a...
from __future__ import annotations from typing import TYPE_CHECKING, 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.utils import create_flashinfer_kv_indices_triton from sglang.srt.lay...
--- python/sglang/srt/layers/attention/triton_backend.py +++ python/sglang/srt/layers/attention/triton_backend.py @@ -4,16 +4,63 @@ import torch import triton +import triton.language as tl from sglang.srt.layers.attention.base_attn_backend import AttentionBackend from sglang.srt.layers.attention.utils import cr...
142
15
5
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_backend.py). Goal: Optimize Triton decoding kernel for dynamic workload Target hardware: unspecified Target models: unspecified Current file: ```python from __future__ import annotations from typing import TYPE_CHECKING, Optional...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation The current implementation of triton decode attenti...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "total token throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 10566.4, "optimized": 10893.63, "stated_speedup": null, "speedup": 1.031}, {"scope": "e2e", "hardware": null, "model": null, "shape": null, "ba...
1.0506
1.0309
sglang
c0e9a36c5f5e8e018663a3b84c401780c5999381
2025-03-19T12:25:38+08:00
4,553
https://github.com/sgl-project/sglang/pull/4553
Optimize Triton decoding kernel for dynamic workload (#4553)
Optimize Triton decoding kernel for dynamic workload (#4553)
python/sglang/srt/layers/attention/triton_ops/decode_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/decode_attention.py +++ python/sglang/srt/layers/attention/triton_ops/decode_attention.py @@ -37,6 +37,9 @@ ) +_MIN_BLOCK_KV = 32 + + @triton.jit def tanh(x): # Tanh is just a scaled sigmoid @@ -52,6 +55,8 @@ kv_indptr, kv_indices, Att_Out, + ...
95
37
5
[]
[]
[]
Optimize this triton kernel file from sglang (python/sglang/srt/layers/attention/triton_ops/decode_attention.py). Goal: Optimize Triton decoding kernel for dynamic workload Target hardware: unspecified Target models: unspecified Current file: ```python # Copyright 2023-2024 SGLang Team # Licensed under the Apache Lic...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation The current implementation of triton decode attenti...
[{"scope": "e2e", "hardware": null, "model": null, "shape": null, "batch_size": null, "metric": "total token throughput", "unit": "tok/s", "higher_is_better": true, "baseline": 10566.4, "optimized": 10893.63, "stated_speedup": null, "speedup": 1.031}, {"scope": "e2e", "hardware": null, "model": null, "shape": null, "ba...
1.0506
1.0309
sglang
25e1816eff104da56f97ce494e255306603fe2f6
2025-03-17T03:16:30+08:00
4,477
https://github.com/sgl-project/sglang/pull/4477
fix custom allreduce performance/accuracy problem (#4477)
fix custom allreduce performance/accuracy problem (#4477)
sgl-kernel/csrc/allreduce/trt_reduce_internal.cu
cuda
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/allreduce/trt_reduce_internal.cu +++ sgl-kernel/csrc/allreduce/trt_reduce_internal.cu @@ -182,8 +182,9 @@ } } } - - __syncthreads(); + if constexpr (start || need_fence) { + __syncthreads(); + } } template <typename T, int RANKS_PER_NODE, bool COPY_INPUT = true> @@ -262,6 +2...
6
19
2
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/csrc/allreduce/trt_reduce_internal.cu). Goal: fix custom allreduce performance/accuracy problem Target hardware: unspecified Target models: unspecified Current file: ```cuda /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, V...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Fix accuracy/performance problem for custom allreduc...
[]
null
null
sglang
25e1816eff104da56f97ce494e255306603fe2f6
2025-03-17T03:16:30+08:00
4,477
https://github.com/sgl-project/sglang/pull/4477
fix custom allreduce performance/accuracy problem (#4477)
fix custom allreduce performance/accuracy problem (#4477)
sgl-kernel/include/trt_reduce_internal.cuh
cuda
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/trt_reduce_internal.cuh +++ sgl-kernel/include/trt_reduce_internal.cuh @@ -39,7 +39,7 @@ namespace trt_llm { constexpr size_t WARP_SIZE = 32; -constexpr size_t MAX_ALL_REDUCE_BLOCKS = 36; +constexpr size_t MAX_ALL_REDUCE_BLOCKS = 32; constexpr size_t MAX_RANKS_PER_NODE = 8; constexpr size_t...
1
1
2
[]
[]
[]
Optimize this cuda kernel file from sglang (sgl-kernel/include/trt_reduce_internal.cuh). Goal: fix custom allreduce performance/accuracy problem Target hardware: unspecified Target models: unspecified Current file: ```cuda /* Copyright 2025 SGLang Team. All Rights Reserved. Licensed under the Apache License, Version...
<!-- Thank you for your contribution! We appreciate it. The following guidelines will help improve your pull request and facilitate feedback. If anything is unclear, don't hesitate to submit your pull request and ask the maintainers for assistance. --> ## Motivation Fix accuracy/performance problem for custom allreduc...
[]
null
null