repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
sglang
test/registered/kernels/ops/diffusion/test_glm_image_ln_modulate.py
.py
"""GLM-Image fused LN+modulate / qk-LN fast paths must stay bit-exact vs eager.""" import pytest import torch import sglang.multimodal_gen.runtime.models.dits.glm_image as glm_image from sglang.multimodal_gen.runtime.models.dits.glm_image import ( _eager_ln_modulate, _glm_ln_modulate, _glm_qk_layernorm, )...
56
2,474
sglang
test/registered/kernels/ops/diffusion/test_qwen_image_modulation.py
.py
import sys import pytest import torch import triton from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.diffusion.triton.norm import norm_infer from sglang.kernels.ops.diffusion.triton.scale_shift import ( fuse_layernorm_scale_shift_gate_select01_kernel, fuse_residual_layernorm_scal...
229
7,294
sglang
test/registered/kernels/ops/diffusion/test_ltx2_ada_values.py
.py
import sys import pytest import torch from sglang.kernels.ops.diffusion.triton.ltx2_ada_values import ltx2_ada_values9 from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci register_cuda_ci(est_time=8, stage="base-b-kernel-unit", runner_config="1-gpu-large") register_amd_ci(est_time=8, suite="nigh...
93
2,893
sglang
test/registered/kernels/ops/diffusion/test_bitexact_gate.py
.py
import sys from types import ModuleType from unittest.mock import MagicMock, patch import pytest import torch from sglang.kernels.ops.diffusion.bitexact_gate import ( BitExactFusionGate, flashinfer_rmsnorm_diagnostic_hint, tensors_equal, ) from sglang.test.ci.ci_register import register_cpu_ci from sglang...
160
5,610
sglang
test/registered/kernels/ops/diffusion/test_ltx2_rms_norm_modulate.py
.py
"""LTX-2 quality=high RMSNorm+modulate fusion: gated, close to eager.""" import sys import pytest import torch from torch import nn from sglang.kernels.ops.diffusion.ltx2_rmsnorm_modulate import ( fused_ltx2_rms_norm_modulate, mark_ltx2_rms_norm_modulate_site, mount_ltx2_rms_norm_modulate, unmount_lt...
72
2,639
sglang
test/registered/kernels/ops/diffusion/test_causal_conv3d_cat_pad.py
.py
import sys import pytest import torch from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.diffusion.causal_conv3d_cat_pad import ( fused_causal_conv3d_cat_pad_cuda, ) from sglang.kernels.ops.diffusion.triton.causal_conv3d_pad import ( fused_causal_conv3d_cat_pad as fused_causal_conv...
90
2,732
sglang
test/registered/kernels/ops/diffusion/test_flux2_vae_fastpath.py
.py
"""Focused correctness checks for the FLUX.2 VAE CUDA fast path.""" import sys import pytest import torch import torch.nn as nn import torch.nn.functional as F from diffusers.models.upsampling import Upsample2D from sglang.kernels.ops.diffusion.triton import group_norm_silu_twopass as gn_kernel from sglang.multimoda...
65
2,337
sglang
test/registered/kernels/ops/diffusion/test_qknorm_rope.py
.py
import itertools import sys import pytest import torch import triton from sglang.kernels.jit.utils import get_ci_test_range from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=44, stage="base-b-kernel-unit", runner_config="1-gpu-large") # Nightly is not redundant here: it sets SGLANG_JI...
441
13,922
sglang
test/registered/kernels/ops/diffusion/test_fused_ln_modulate.py
.py
import pytest import torch import torch.nn as nn from sglang.kernels.ops.diffusion.fused_ln_modulate import ( can_fuse_ln_modulate, fused_ln_modulate, fused_ln_modulate_active, mark_fused_ln_modulate_site, mount_fused_ln_modulate, unmount_fused_ln_modulate, ) from sglang.test.ci.ci_register imp...
83
3,008
sglang
test/registered/kernels/ops/diffusion/test_fused_norm_scale_shift.py
.py
import sys from typing import Optional, Tuple import pytest import torch from einops import rearrange from torch import Tensor from sglang.kernels.ops.diffusion.cutedsl.scale_residual_norm_scale_shift import ( fused_norm_scale_shift, fused_scale_residual_norm_scale_shift, validate_scale_shift, ) from sgla...
252
8,725
sglang
test/registered/kernels/ops/diffusion/test_fused_gate_rmsnorm.py
.py
"""Core checks for the quality-gated fused gate-RMSNorm path.""" import sys import pytest import torch import torch.nn as nn import torch.nn.functional as F from sglang.kernels.ops.diffusion import fused_gate_rmsnorm as fgn from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=4, stage="...
55
2,123
sglang
test/registered/kernels/ops/diffusion/test_flydsl_fused_norm.py
.py
import sys import pytest import torch import torch.nn.functional as F from sglang.test.ci.ci_register import register_amd_ci register_amd_ci(est_time=30, stage="jit-kernel-unit", runner_config="amd") DEVICE = "cuda" D = 5120 EPS = 1e-6 def _ref_rms_norm(x_f32, weight, eps): var = x_f32.pow(2).mean(-1, keepdim...
134
3,934
sglang
test/registered/kernels/ops/diffusion/test_sana_ln_modulate.py
.py
"""Sana fused LN+modulate fast path must stay bit-exact vs eager.""" import pytest import torch import sglang.multimodal_gen.runtime.models.dits.sana as sana from sglang.multimodal_gen.runtime.models.dits.sana import ( _eager_ln_modulate, _sana_ln_modulate, ) from sglang.test.ci.ci_register import register_cu...
56
2,261
sglang
test/registered/kernels/ops/diffusion/test_ernie_norm_scale_shift.py
.py
"""ERNIE fused norm/scale/shift fast paths must stay bit-exact vs eager.""" import sys from unittest.mock import patch import pytest import torch import sglang.multimodal_gen.runtime.models.dits.ernie_image as ernie_image from sglang.multimodal_gen.runtime.layers.layernorm import RMSNorm from sglang.multimodal_gen.r...
136
5,044
sglang
test/registered/kernels/ops/diffusion/test_stage_profiler_sync.py
.py
"""SGLANG_DIFFUSION_SYNC_STAGE_PROFILING must drain the GPU queue at the timing start of *stage* records too — otherwise a stage that only launches kernels (DenoisingStage's tail) leaks its queued work into whichever later stage blocks first, inflating e.g. DecodingStage readings 2-3x.""" import sys import time impor...
51
1,958
sglang
test/registered/kernels/ops/diffusion/test_varlen_uspattn_equivalence.py
.py
"""End-to-end equivalence between USPAttention varlen path and SDPA reference. Compares the production varlen path (``build_varlen_mask_meta`` + ``fused_pack_qkv`` + ``flash_attn_varlen_func`` + ``fused_scatter_to_padded``) against ``torch.nn.functional.scaled_dot_product_attention`` with a broadcast key mask, for inp...
158
5,710
sglang
test/registered/kernels/ops/diffusion/test_native_bf16_rmsnorm.py
.py
import pytest import torch from sglang.kernels.ops.diffusion.triton.native_bf16_rmsnorm import ( rmsnorm_scale, rmsnorm_tanh_residual, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=8, stage="base-b-kernel-unit", runner_config="1-gpu-large") EPS = 1e-5 def _native_bf16_...
88
3,487
sglang
test/registered/kernels/ops/diffusion/test_timestep_embedding.py
.py
import os import sys import numpy as np import pytest import torch try: import tabulate except Exception: tabulate = None from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.diffusion.timestep_embedding import ( timestep_embedding as timestep_embedding_cuda, ) from sglang.test....
185
6,031
sglang
test/registered/kernels/ops/diffusion/test_scale_shift.py
.py
import sys import pytest import torch from sglang.kernels.ops.diffusion.triton.scale_shift import ( try_fused_scaled_residual_add_exact, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=5, stage="base-b-kernel-unit", runner_config="1-gpu-large") pytestmark = pytest.mark.skipif(...
41
1,400
sglang
test/registered/kernels/ops/diffusion/test_flux_ln_modulate.py
.py
"""FLUX.1 fused LN+modulate fast path must stay bit-exact vs eager.""" import pytest import torch import sglang.multimodal_gen.runtime.models.dits.flux as flux from sglang.kernels.ops.diffusion.fused_ln_modulate import ( mark_fused_ln_modulate_site, mount_fused_ln_modulate, ) from sglang.multimodal_gen.runtim...
76
2,825
sglang
test/registered/kernels/ops/diffusion/test_autoencoder_kl_fastpath.py
.py
"""Install-path checks for the generic AutoencoderKL CUDA fast path.""" import sys import pytest import torch from sglang.multimodal_gen.configs.models.vaes.stablediffusion3 import ( StableDiffusion3VAEConfig, ) from sglang.multimodal_gen.runtime.models.vaes import flux2_vae_cuda_opt as vae_opt from sglang.multi...
63
2,456
sglang
test/registered/kernels/ops/diffusion/test_hunyuanvideo_eager_fusions.py
.py
"""HunyuanVideo eager QKV/RoPE and quality-gated QKNorm tests.""" import sys from unittest.mock import patch import pytest import torch import sglang.kernels.ops.diffusion.hunyuan_qknorm as hunyuan_qknorm from sglang.kernels.ops.diffusion.hunyuan_qknorm import ( mark_hunyuan_qknorm_site, mount_hunyuan_qknorm...
95
3,380
sglang
test/registered/kernels/ops/diffusion/test_ltx2_qknorm_split_rope.py
.py
import sys import pytest import torch import torch.nn.functional as F from sglang.kernels.ops.diffusion.ltx2_qknorm_split_rope import ( can_use_ltx2_qknorm_split_rope_cuda, ltx2_qknorm_split_rope_cuda, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=45, stage="base-b-kerne...
222
6,679
sglang
test/registered/kernels/ops/diffusion/test_quality_gate.py
.py
import sys import pytest import torch.nn as nn from sglang.kernels.ops.diffusion.quality_gate import QualityGatedFusion from sglang.test.ci.ci_register import register_cpu_ci register_cpu_ci(est_time=2, suite="base-a-test-cpu") def test_quality_gate_mounts_and_unmounts_all_sites(): fusion = QualityGatedFusion(...
48
1,435
sglang
test/registered/kernels/ops/diffusion/test_residual_gate_add.py
.py
import sys import pytest import torch from sglang.kernels.ops.diffusion.residual_gate_add import ( can_use_residual_gate_add_cuda, residual_gate_add, residual_gate_add_cuda, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=30, stage="base-b-kernel-unit", runner_config="...
124
4,707
sglang
test/registered/kernels/ops/layernorm/test_qknorm.py
.py
import itertools import sys import pytest import torch import triton from sglang.kernels.jit.utils import get_ci_test_range from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=37, stage="base-b-kernel-unit", runner_config="1-gpu-large") # Nightly is not redundant here: it sets SGLANG_JI...
103
3,280
sglang
test/registered/kernels/ops/layernorm/test_minimax_m3_rmsnorm.py
.py
# SPDX-License-Identifier: Apache-2.0 """Reference tests for MiniMax-M3 ROCm Gemma RMSNorm Triton kernels.""" import pytest import torch from sglang.srt.utils import is_hip if not is_hip(): pytest.skip( "MiniMax-M3 Gemma RMSNorm Triton kernels are ROCm-only.", allow_module_level=True, ) if no...
88
2,852
sglang
test/registered/kernels/ops/layernorm/test_gemma4_fused_routing.py
.py
"""Correctness tests for ``gemma4_fused_routing``. Compares the Triton-fused routing kernel against the original SGLang ``Gemma4MoE.routing_function`` reference (softmax-of-topk * per_expert_scale). Run with:: pytest test/registered/kernels/test_gemma4_fused_routing.py -v Requires a CUDA-capable GPU; skips other...
107
3,698
sglang
test/registered/kernels/ops/layernorm/test_rmsnorm_hf.py
.py
"""Tests for the JIT rmsnorm_hf kernel (HF LlamaRMSNorm semantics).""" import itertools import sys import pytest import torch from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.layernorm.rmsnorm_hf import ( is_supported_rmsnorm_hf_hidden_size, rmsnorm_hf, ) from sglang.test.ci.ci_...
139
5,039
sglang
test/registered/kernels/ops/layernorm/test_fused_add_rmsnorm.py
.py
import itertools import sys import pytest import torch from sglang.kernels.jit.utils import get_ci_test_range from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=10, stage="base-b-kernel-unit", runner_config="1-gpu-large") # Nightly is not redundant here: it sets SGLANG_JIT_KERNEL_RUN_F...
115
3,970
sglang
test/registered/kernels/ops/layernorm/test_fused_op_gpu_parity.py
.py
"""Every-backend-vs-native parity for BaseFusedOp ops on real GPU (RFC #29630). For each reworked fused op, run every backend eligible on this platform and assert it matches the pure-torch ``forward_native`` reference within dtype tolerance. New backends are picked up automatically. """ import pytest import torch fr...
124
4,451
sglang
test/registered/kernels/ops/layernorm/test_kernels_namespace.py
.py
"""GPU-free import / registry / selector tests for ``sglang.kernels`` (RFC #29630).""" import importlib import importlib.util import subprocess import sys import pytest import sglang.kernels as K import sglang.kernels.fused_op as fo import sglang.kernels.ops # noqa: F401 -- populate the registry import sglang.kern...
237
8,630
sglang
test/registered/kernels/ops/layernorm/test_mhc_kernels.py
.py
from contextlib import nullcontext import pytest import torch import sglang.kernels.ops.layernorm.mhc as mhc from sglang.kernels.ops.layernorm.mhc import mhc_fused_post_pre, mhc_post, mhc_pre from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=30, stage="base-b", runner_config="1-gpu-la...
131
4,586
sglang
test/registered/kernels/ops/layernorm/test_fused_eh_norm.py
.py
import sys import pytest import torch from sglang.kernels.ops.layernorm.fused_eh_norm import fused_eh_norm from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=45, stage="base-b-kernel-unit", runner_config="1-gpu-large") pytestmark = pytest.mark.skipif( not torch.cuda.is_available()...
122
4,510
sglang
test/registered/kernels/ops/layernorm/test_fused_op.py
.py
"""GPU-free BaseFusedOp + registry / spec unit tests (RFC #29630). Every-backend-vs-native parity on real hardware lives in ``test_fused_op_gpu_parity.py``. """ import math import pytest import torch import sglang.kernels as K from sglang.kernels.fused_op import BaseFusedOp from sglang.kernels.registry import Kerne...
241
6,903
sglang
test/registered/kernels/ops/layernorm/test_qknorm_across_heads.py
.py
import itertools import sys import pytest import torch import triton from sglang.kernels.jit.utils import get_ci_test_range from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=15, stage="base-b-kernel-unit", runner_config="1-gpu-large") # Nightly is not redundant here: it sets SGLANG_JI...
85
2,680
sglang
test/registered/kernels/ops/layernorm/test_fused_qk_gemma_rmsnorm_gate.py
.py
import itertools import sys import pytest import torch from sglang.srt.models.utils import fused_qk_gemma_rmsnorm_with_gate from sglang.test.ci.ci_register import register_amd_ci register_amd_ci(est_time=20, stage="jit-kernel-unit", runner_config="amd") def reference_qk_gemma_rmsnorm_with_gate( q_gate: torch.T...
152
4,981
sglang
test/registered/kernels/ops/layernorm/test_rmsnorm.py
.py
import itertools import sys import pytest import torch from sglang.kernels.jit.utils import get_ci_test_range from sglang.srt.utils import is_hip from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci register_cuda_ci(est_time=45, stage="base-b-kernel-unit", runner_config="1-gpu-large") # Nightly i...
158
4,316
sglang
test/registered/kernels/ops/quantization/test_per_token_group_quant_8bit_v2.py
.py
import itertools import pytest import torch from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.quantization.per_token_group_quant_8bit_v2 import ( per_token_group_quant_8bit_v2, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=90, stage="base-b-kerne...
192
6,067
sglang
test/registered/kernels/ops/quantization/test_awq_marlin_repack.py
.py
import sys import numpy as np import pytest import torch from sgl_kernel.scalar_type import scalar_types from sglang.kernels.ops.quantization.awq_marlin_repack import ( awq_marlin_repack as jit_awq_marlin_repack, ) from sglang.srt.layers.quantization.utils import pack_cols, quantize_weights from sglang.test.ci.ci...
111
3,395
sglang
test/registered/kernels/ops/quantization/test_awq_marlin_moe_repack.py
.py
import sys import numpy as np import pytest import torch from sgl_kernel.scalar_type import scalar_types from sglang.kernels.ops.quantization.awq_marlin_repack import ( awq_marlin_moe_repack as jit_awq_marlin_moe_repack, ) from sglang.srt.layers.quantization.utils import pack_cols, quantize_weights from sglang.te...
125
4,006
sglang
test/registered/kernels/ops/quantization/test_per_tensor_quant_fp8.py
.py
import itertools import sys from typing import Optional, Tuple import pytest import torch from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.quantization.per_tensor_quant_fp8 import ( per_tensor_quant_fp8, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_...
104
3,266
sglang
test/registered/kernels/ops/quantization/test_per_token_quant_fp8.py
.py
import sys import pytest import torch from sgl_kernel import sgl_per_token_quant_fp8 as aot_per_token_quant_fp8 from sglang.kernels.ops.quantization.fp8_kernel import scaled_fp8_quant from sglang.kernels.ops.quantization.per_token_quant_fp8 import per_token_quant_fp8 from sglang.test.ci.ci_register import register_cu...
121
4,960
sglang
test/registered/kernels/ops/quantization/test_per_token_group_quant.py
.py
"""Correctness tests for the trait-driven per_token_group_quant JIT kernel. The reference is computed in pure PyTorch (the quantization math itself), NOT by calling the v2 / minimax kernels -- those are being deprecated, so the tests must outlive them. Two guard strengths, chosen by what the kernel's numerics can act...
552
23,271
sglang
test/registered/kernels/ops/quantization/test_awq_dequantize.py
.py
import itertools import sys import pytest import torch from sglang.kernels.ops.quantization.awq_dequantize import ( awq_dequantize as jit_awq_dequantize, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=9, stage="base-b-kernel-unit", runner_config="1-gpu-large") try: from ...
171
4,758
sglang
test/registered/kernels/ops/quantization/test_gptq_marlin.py
.py
import sys from types import SimpleNamespace import pytest import torch from sgl_kernel.scalar_type import scalar_types from sglang.kernels.ops.quantization.gptq_marlin import gptq_marlin_gemm from sglang.srt.layers.quantization.marlin_utils import ( check_marlin_supported, marlin_make_workspace, ) from sglan...
192
5,620
sglang
test/registered/kernels/ops/quantization/test_hadamard_jit.py
.py
import math import sys import numpy as np import pytest import torch import torch.nn.functional as F from scipy.linalg import hadamard from sglang.kernels.ops.quantization.hadamard import ( hadamard_transform, hadamard_transform_12n, hadamard_transform_20n, hadamard_transform_28n, hadamard_transfo...
428
13,467
sglang
test/registered/kernels/ops/quantization/test_gptq_marlin_repack.py
.py
import sys import pytest import torch from sgl_kernel.scalar_type import scalar_types from sglang.kernels.ops.quantization.gptq_marlin_repack import gptq_marlin_repack from sglang.srt.layers.quantization.utils import ( gptq_quantize_weights, pack_rows, sort_weights, ) from sglang.test.ci.ci_register impor...
96
2,752
sglang
test/registered/kernels/ops/moe/test_moe_preprocess.py
.py
"""fused_moe_preprocess must be bit-identical to the torch.sort-based path, and the grouped GEMM must produce identical results under both block_size_m configs (the block schedule and kernel config are chosen together). """ import pytest import torch from sglang.kernels.ops.moe.inkling_moe import ( SMALL_M_BLOCK_...
97
3,251
sglang
test/registered/kernels/ops/moe/test_moe_lora_align_block_size.py
.py
# Temporarily adapted from https://github.com/vllm-project/vllm/blob/main/tests/lora/test_moe_lora_align_sum.py, will optimize in future refactor import random import sys import pytest import torch # --------------------------------------------------------- # IMPORT PREBUILT KERNEL # ---------------------------------...
168
6,376
sglang
test/registered/kernels/ops/moe/test_inkling_silu_and_mul.py
.py
"""Numerics tests for the plain-Triton silu_and_mul (former helion kernels). The kernels compute silu(gate) * up (* weight) in fp32 with one rounding cast at the store, in the exact operation order of the helion kernels they replaced, so bf16 outputs sit within 1 bf16 ulp of a same-order torch fp32 reference (tl.sigmo...
160
5,975
sglang
test/registered/kernels/ops/moe/test_fused_topk_deepseek.py
.py
import sys import pytest import torch from sglang.srt.layers.moe.topk import biased_grouped_topk_gpu, biased_grouped_topk_impl from sglang.srt.utils import get_device from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=40, stage="nightly", runner_config="1-gpu-large") @pytest.mark.par...
102
3,610
sglang
test/registered/kernels/ops/moe/test_marlin_packed_topk_unpack.py
.py
"""Precision test for the fused packed-topk unpack triton kernel used by the Marlin MoE runner (fused-gate-topk support). The FlashInfer / Inkling fused gate emits PackedTopKOutput -- int32 ``(expert_id << 16) | bf16-weight-bits``. The Marlin runner reads topk_ids / topk_weights separately, so it unpacks with a single...
91
3,144
sglang
test/registered/kernels/ops/moe/test_moe_align_block_size.py
.py
import itertools import sys import pytest import torch import triton import triton.language as tl from sglang.kernels.jit.utils import get_ci_test_range from sglang.kernels.ops.moe.moe_align import moe_align_block_size from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=28, stage="base-...
364
11,329
sglang
test/registered/kernels/ops/moe/test_post_reorder_deepgemm.py
.py
import pytest import torch from sglang.kernels.ops.moe.ep_moe_kernels import ( post_reorder_deepgemm, post_reorder_triton_kernel, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=30, stage="base-b-kernel-unit", runner_config="1-gpu-large") register_cuda_ci(est_time=30, stage...
91
3,128
sglang
test/registered/kernels/ops/moe/test_minimax_m3_mxfp8.py
.py
# SPDX-License-Identifier: Apache-2.0 """Reference-vs-fused unit tests for the MiniMax-M3 ROCm native MXFP8 ops. Each fused kernel has a slow PyTorch / dequant-to-bf16 reference; these assert the two agree within tolerance: * Fused MXFP8 activation quant (Triton) -> torch reference * Native MXFP8 linear (t...
269
9,811
sglang
test/registered/kernels/ops/moe/test_moe_wna16_marlin.py
.py
import itertools import sys from types import SimpleNamespace import pytest import torch from sgl_kernel.scalar_type import scalar_types from sglang.kernels.ops.moe.moe_wna16_marlin import moe_wna16_marlin_gemm from sglang.srt.layers.moe.fused_moe_triton import moe_align_block_size from sglang.srt.layers.moe.fused_mo...
689
20,639
sglang
test/registered/kernels/ops/moe/test_moe_align_small_numel.py
.py
"""Correctness of the single-launch tiny-numel moe_align triton kernel. The oracle is a plain-torch implementation of the documented contract, so it does not depend on any other kernel's shape support; the AOT `sgl_kernel` path is cross-checked on top of it to back the drop-in-replacement claim. """ import itertools ...
215
8,461
sglang
test/registered/kernels/ops/moe/test_renorm.py
.py
# Adapted from https://github.com/flashinfer-ai/flashinfer/blob/main/tests/test_sampling.py # and /sgl-workspace/sglang/python/sglang/kernels/aot/tests/test_sampling.py import sys import pytest import torch from sglang.srt.utils import is_hip from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci ...
97
3,616
sglang
test/registered/kernels/ops/moe/test_minimax_quant_scatter.py
.py
import random import sys from contextlib import nullcontext import pytest import torch import sglang.srt.layers.moe.moe_runner.deep_gemm as deep_gemm_runner from sglang.kernels.ops.moe.ep_moe_kernels import ( fill_gateup_input_triton_kernel, moe_ep_deepgemm_preprocess, ) from sglang.kernels.ops.quantization.m...
357
11,501
sglang
test/registered/kernels/ops/moe/test_sigmoid_gate_mul.py
.py
import sys import pytest import torch from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci register_cuda_ci(est_time=4, stage="base-b-kernel-unit", runner_config="1-gpu-large") register_amd_ci(est_time=4, stage="jit-kernel-unit", runner_config="amd") DEVICE = "cuda" def reference_sigmoid_gate_...
82
2,541
sglang
test/registered/kernels/ops/moe/test_sigmoid_gate_mul_broadcast.py
.py
import sys import pytest import torch from sglang.test.ci.ci_register import register_amd_ci register_amd_ci(est_time=4, suite="jit-kernel-unit-test-amd") DEVICE = "cuda" def reference_sigmoid_gate_mul(x, gate): return x * torch.sigmoid(gate) # ── element-wise variant ── @pytest.mark.parametrize("dtype", ...
124
3,522
sglang
test/registered/kernels/ops/moe/test_fused_swiglu_epilogue.py
.py
"""Correctness of the SwiGLU-in-the-up-GEMM-epilogue MoE fast path. Two claims are invisible at the call site and would break silently under an innocuous-looking rewrite: 1. Interleaving W13 rows leaves every up-GEMM output column unchanged -- the permute only decides which column a gate/up pair lands in. 2. The e...
208
7,951
sglang
test/registered/kernels/ops/moe/test_moe_topk_sigmoid.py
.py
""" Correctness tests for the moe_topk_sigmoid JIT kernel. Validates against a pure-PyTorch reference and, when sgl_kernel is available, cross-checks against the AOT implementation. """ import itertools import os import sys from typing import Optional import pytest import torch from sglang.kernels.ops.moe.moe_topk_...
497
18,028
sglang
test/registered/kernels/ops/moe/test_fp4_moe.py
.py
# SPDX-License-Identifier: Apache-2.0 from typing import Callable import pytest import torch from flashinfer import fp4_quantize, scaled_fp4_grouped_quantize from flashinfer.fused_moe import cutlass_fused_moe as flashinfer_cutlass_fused_moe from sgl_kernel import silu_and_mul from torch.nn import functional as F from...
345
10,769
sglang
test/registered/kernels/ops/moe/test_moe_fused_gate.py
.py
"""Correctness tests for the Triton :func:`moe_fused_gate` router. The Triton kernel is a drop-in reimplementation of the CUDA fused gate for the ungrouped case (``num_expert_group == 1``). We validate it three ways: * against an explicit, definition-based torch reference (documents the math), * against the CUDA JIT ...
526
18,739
sglang
test/registered/kernels/ops/kimi_k3/test_collectives.py
.py
from __future__ import annotations import atexit import os import pytest import torch import torch.distributed as dist import sglang.srt.distributed.parallel_state as ps from sglang.kernels.jit.utils import cache_once from sglang.kernels.ops.communication.mp import register_comm_cleanup from sglang.kernels.ops.kimi_...
360
10,371
sglang
test/registered/kernels/ops/kimi_k3/test_compute.py
.py
import unittest import torch from sglang.kernels.ops.attention.fla.kda_replayssm_spec_decode import ( commit_kda_replayssm_spec, ) from sglang.kernels.ops.kimi_k3 import ( situ_and_mul, situ_and_mul_masked_post_quant, ) from sglang.kernels.ops.kimi_k3.attn_res import attn_res_fused_tma from sglang.kernels...
454
14,598
sglang
test/registered/kernels/ops/kimi_k3/test_ar_fusion.py
.py
"""Correctness test for the K3 MNNVL fused all-reduce (ar_fusion) kernels. Compares the 1shot multicast-push and the in-place low-SM NVLS 2shot pull (with and without the fused residual) against NCCL, bit-exact on small-int bf16 inputs; the fused-RMSNorm pull against a torch reference; the pull tuning knobs (num_block...
452
17,299
sglang
test/registered/kernels/ops/communication/test_tp_qknorm.py
.py
from __future__ import annotations import atexit import itertools import logging import multiprocessing import os from multiprocessing.context import SpawnProcess from typing import List import pytest import torch import torch.distributed as dist import triton import sglang.srt.distributed.parallel_state as ps from ...
201
6,916
sglang
test/registered/kernels/ops/communication/test_amd_deterministic_custom_allreduce.py
.py
""" Test deterministic custom all-reduce kernel behavior with batch size invariance. This test uses the 1-stage all-reduce kernel which is inherently deterministic due to fixed accumulation ordering (each GPU reads all data from all GPUs and reduces locally in a fixed order - no atomics, no race conditions). Note: Th...
255
8,335
sglang
test/registered/kernels/ops/communication/test_symm_mem_all_gather.py
.py
"""Correctness test for the symmetric-memory multimem all-gather kernel. Compares ``all_gather_inner`` (concat-along-hidden multimem.st gather) against NCCL all-gather for a sweep of token counts, hidden widths, and the ``safe`` / ``skip_entry_sync`` knobs, in both eager and CUDA-graph modes. Usage:: # Run on th...
168
5,996
sglang
test/registered/kernels/ops/communication/test_custom_all_reduce.py
.py
"""Correctness test for the JIT custom all-reduce (v2) kernel. Compares the JIT custom all-reduce output against NCCL all-reduce for a sweep of tensor sizes, dtypes, and algorithms, in both eager and CUDA-graph modes. Usage:: # Run the test on the default world sizes (2, 4, 8 GPUs): python tests/test_custom_...
244
8,527
sglang
test/registered/kernels/ops/communication/test_amd_nccl_allreduce_determinism.py
.py
""" Test to confirm non-determinism of default NCCL all-reduce with batch size invariance. This test uses the default torch.distributed.all_reduce (NCCL) which can be NON-DETERMINISTIC due to tree-based reduction algorithms that don't guarantee fixed accumulation order for bfloat16/float16. This test compares: 1. Def...
213
6,861
sglang
test/registered/kernels/ops/gemm/test_dsv3_router_gemm.py
.py
"""Tests for JIT dsv3_router_gemm kernel.""" import itertools import sys import pytest import torch from sglang.kernels.jit.utils import ( get_ci_test_range, get_jit_cuda_arch, is_hip_runtime, ) from sglang.kernels.ops.gemm.dsv3_router_gemm import dsv3_router_gemm from sglang.test.ci.ci_register import r...
69
2,143
sglang
test/registered/kernels/ops/gemm/test_minimax_fused_qkv_index_gemm.py
.py
import pytest import torch from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=30, stage="base-b-kernel-unit", runner_config="4-gpu-b200") dev = "cuda" def _pack_weight_scale(scale_u8: torch.Tensor) -> torch.Tensor: from sglang.srt.layers.deep_gemm_wrapper.configurer import DEEPGE...
70
2,065
sglang
test/registered/kernels/ops/gemm/test_fp8_blockwise_gemm.py
.py
import sys from typing import Optional, Type import pytest import torch from sglang.kernels.ops.gemm.fp8_blockwise_gemm import fp8_blockwise_scaled_mm from sglang.srt.utils import is_sm120_supported from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci( est_time=30, stage="base-b", run...
91
3,190
sglang
test/registered/kernels/ops/gemm/test_cutedsl_bf16_gemm.py
.py
"""Tests for the CuTe DSL TGV BF16 GEMM kernel.""" import sys import pytest import torch from sglang.kernels.jit.utils import ( get_ci_test_range, get_jit_cuda_arch, is_hip_runtime, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=30, stage="base-b-kernel-unit", runner...
84
2,968
sglang
test/registered/kernels/ops/gemm/test_chunked_sgmv_cuda_graph.py
.py
# Copyright 2023-2026 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...
295
9,680
sglang
test/registered/kernels/ops/gemm/test_cutedsl_dsv3_fused_a_gemm.py
.py
"""Tests for the CuTe DSL DeepSeek-V3 fused-A GEMM kernel.""" import sys import pytest import torch from sglang.kernels.jit.utils import ( get_ci_test_range, get_jit_cuda_arch, is_hip_runtime, ) from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=30, stage="base-b-kernel-un...
54
1,719
sglang
test/registered/kernels/ops/gemm/test_dsv3_fused_a_gemm.py
.py
"""Tests for JIT dsv3_fused_a_gemm kernel.""" import sys import pytest import torch import torch.nn.functional as F from sglang.kernels.jit.utils import ( get_ci_test_range, get_jit_cuda_arch, is_hip_runtime, ) from sglang.kernels.ops.gemm.dsv3_fused_a_gemm import dsv3_fused_a_gemm from sglang.test.ci.ci...
51
1,691
sglang
test/registered/kernels/ops/attention/test_c128_v2.py
.py
from __future__ import annotations import sys from typing import Tuple, Union import pytest import torch import triton from sglang.kernels.ops.attention.dsv4 import compress_forward from sglang.srt.utils import get_device from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci from sglang.test.kerne...
280
9,212
sglang
test/registered/kernels/ops/attention/test_deepseek_v4_compress_plan_draft_pad.py
.py
"""Kernel-level tests for the DSV4 compress write-plan (`plan_prefill`). `plan_w` decides which tokens' raw KV get persisted into the compress-state ring for a *future* compression window to read. A speculative verify batch plans from the optimistic `seq_len = prefix + num_draft_tokens` but rolls back to `prefix + acc...
218
10,013
sglang
test/registered/kernels/ops/attention/test_cp_prefix_len_fa3_parity.py
.py
""" FA3 parity test for `prepare_context_parallel_metadata`. Drives the real function and feeds its `kv_len_prev/next_tensor` into FA3 via `flash_attn_with_kvcache`. Compares per-rank CP output against a full-sequence FA3 reference computed over the unpadded `(prefix + extend)` KV. Any discrepancy indicates the metada...
144
5,445
sglang
test/registered/kernels/ops/attention/test_mla_cp_fa3_parity.py
.py
"""FA3 numerical parity for MLA prefill CP. Verifies the rank-local zigzag-split FA3 path (``_mla_cp_attn`` + ``cp_attn_forward_extend`` in ``flashattention_backend.py``) matches a single non-CP ``flash_attn_with_kvcache`` over the full sequence. Single-process, single-layer, pre-populated paged KV cache. Requires FA...
211
6,690
sglang
test/registered/kernels/ops/attention/test_fused_verify_triton_gdn.py
.py
"""Tests for fused sigmoid gating delta rule MTP kernel (GDN target_verify). Compares the fused kernel `fused_sigmoid_gating_delta_rule_update` against the reference two-step implementation: 1. g, beta = fused_gdn_gating(A_log, a, b, dt_bias) 2. o = fused_recurrent_gated_delta_rule_update(q, k, v, g, beta, ......
239
6,995
sglang
test/registered/kernels/ops/attention/test_dsa_metadata.py
.py
import unittest import torch from sglang.kernels.ops.attention.dsa_metadata import ( fused_dsa_decode_metadata, fused_dsa_draft_extend_metadata, fused_dsa_target_verify_metadata, ) from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci from sglang.test.test_utils import CustomTestCase r...
528
20,176
sglang
test/registered/kernels/ops/attention/test_flash_attention_3_only_qv.py
.py
# Adapted from sgl-flash-attn hopper/test_attn_kvcache.py::test_flash_attn_kvcache_only_qv # Covers the only_qv (NoPE) decode path that FA3 adds for sparse MLA on SM90: # the QK^T matmul is skipped and attention is computed as softmax(qv * V) over # a paged V cache (no K cache, no rope). import math import sys import ...
101
3,346
sglang
test/registered/kernels/ops/attention/test_minimax_decode_topk.py
.py
"""Correctness tests for the MiniMax-M3 single-stage radix-select decode topk. The kernel selects, per (head, batch) row, the indices of the ``topk`` largest block scores among the row's first ``num_blocks = ceil(seq_len / block_size)`` entries, front-packing valid block ids and ``-1``-padding the tail. This mirrors t...
146
5,875
sglang
test/registered/kernels/ops/attention/test_kda_helion.py
.py
from __future__ import annotations import inspect import sys import pytest import torch from sglang.kernels.ops.attention.fla.fused_recurrent import ( fused_recurrent_kda_packed_decode, ) from sglang.kernels.ops.attention.fla.fused_recurrent_linear_replayssm import ( fused_recurrent_linear_replayssm_decode, ...
1,027
33,854
sglang
test/registered/kernels/ops/attention/test_topk_v2.py
.py
"""Correctness tests for the DeepSeek-V4 (DSA indexer) JIT top-k transform v2. The v2 kernel selects the per-row top-k of ``scores`` (ragged ``seq_lens``) and writes the page-table transform of the selected raw indices into the output. We validate against ``torch.topk`` with a small tolerance for boundary ties (the fp...
300
12,345
sglang
test/registered/kernels/ops/attention/test_paged_mqa_metadata.py
.py
"""Unit tests for paged_mqa_metadata JIT kernel. Verifies byte-equal correctness against a pure-PyTorch reference oracle across the shape envelope. Output is int32 ``[num_sm + 1, 2]`` — a deterministic partition table — so equality is strict (``torch.equal``, no atol/rtol). Test groups: 1. ``test_matches_pytorch_ref...
278
10,823
sglang
test/registered/kernels/ops/attention/test_concat_mla.py
.py
import itertools import sys import pytest import torch import triton from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=17, stage="base-b-kernel-unit", runner_config="1-gpu-large") def torch_concat_mla_k( k: torch.Tensor, k_nope: torch.Tensor, k_rope: torch.Tensor ) -> None: ...
175
5,642
sglang
test/registered/kernels/ops/attention/test_cute_dsl_fp8_paged_mqa_logits.py
.py
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 import sys import pytest import torch from sglang.kernels.ops.attention.dsa import cutedsl_paged_mqa_logits, pick_dsl_expand from sglang.srt.layers.attention.dsa.utils import ( ...
235
7,607
sglang
test/registered/kernels/ops/attention/test_dsv4_indexer_quant.py
.py
"""Correctness tests for the DeepSeek-V4 DSA indexer fp8-quant Q kernel and its V3.2/GLM rope-first variant, after the grid-stride + occupancy scheduling optimization of ``fused_q_indexer_rope_hadamard_quant``. Covers both template configs that share the kernel: - fused_q_indexer_rope_hadamard_quant (V4: rope on tr...
190
7,740
sglang
test/registered/kernels/ops/attention/test_minimax_qknorm_rope.py
.py
"""Correctness for the fused MiniMax-M3 Gemma-RMSNorm + partial NeoX RoPE kernel. Verifies the in-place fused kernel reproduces GemmaRMSNorm((1+w)) + partial NeoX RoPE to the bf16 round-off floor, leaves V untouched, and matches sglang's RoPE convention (cos|sin cache, neox pairs (i, i+rotary_dim/2)). """ import pyte...
179
7,031
sglang
test/registered/kernels/ops/attention/test_sparse_mla_q8kv8_prefill_sm90.py
.py
from __future__ import annotations import math import sys import pytest import torch from sglang.srt.utils import is_sm90_supported from sglang.test.ci.ci_register import register_cuda_ci register_cuda_ci(est_time=240, stage="base-b-kernel-unit", runner_config="1-gpu-large") DTYPE_FP8 = torch.float8_e4m3fn D_V = ...
725
26,953
sglang
test/registered/kernels/ops/attention/test_cutedsl_gdn.py
.py
"""Tests for CuTe DSL fused sigmoid gating delta rule kernel (GDN).""" import sys import numpy as np import pytest import torch from sglang.test.ci.ci_register import register_cuda_ci try: import cuda.bindings.driver as cuda_driver import cutlass # noqa: F401 from cutlass.cute.runtime import from_dlpac...
312
10,680
sglang
test/registered/kernels/ops/attention/test_kda_fused_decode.py
.py
"""Kimi-K3 fused KDA decode must match the existing unfused decode chain. The fused kernel replaces: causal_conv1d_update -> kda_packed_decode -> sigmoid-gated RMSNorm This file covers the local head layouts used by Kimi-K3 TP8/TP16/TP32: H = 12/6/3. The H=6 and H=3 cases are the branches added by the fixed-head...
216
5,662
sglang
test/registered/kernels/ops/attention/test_dsa_transform_index.py
.py
import unittest from unittest.mock import patch import torch import sglang.kernels.ops.attention.dsa.transform_index as transform_index_module from sglang.kernels.ops.attention.dsa.transform_index import ( transform_index_page_table_decode_fast, transform_index_page_table_prefill_fast, ) from sglang.test.ci.c...
241
8,069