docs: improve CI and testing documentation (#21202)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lianmin Zheng
2026-03-23 10:48:50 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent b4d3fb001d
commit 27ac831a84
119 changed files with 519 additions and 809 deletions
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -22,4 +24,4 @@ def test_green_ctx():
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -84,4 +86,4 @@ def test_verify_tree_greedy():
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -73,4 +75,4 @@ def test_reconstruct_indices_from_tree_mask():
if __name__ == "__main__":
test_reconstruct_indices_from_tree_mask()
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -126,4 +128,4 @@ def test_tree_speculative_sampling_target_only(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,5 +1,7 @@
# Adapted from https://github.com/flashinfer-ai/flashinfer/blob/4e8eb1879f9c3ba6d75511e5893183bf8f289a62/tests/test_activation.py
import sys
import pytest
import sgl_kernel
import torch
@@ -36,4 +38,4 @@ def test_fused_gelu_mul(dim, batch_size, seq_len):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import apply_token_bitmask_inplace_cuda
@@ -20,4 +22,4 @@ def test_apply_token_bitmask_inplace_kernel():
if __name__ == "__main__":
test_apply_token_bitmask_inplace_kernel()
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import itertools
import sys
from typing import Optional, Tuple
import pytest
@@ -112,4 +113,4 @@ def test_awq_dequant_compare_implementations(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,5 +1,7 @@
# Adapted from https://github.com/flashinfer-ai/flashinfer/blob/4e8eb1879f9c3ba6d75511e5893183bf8f289a62/tests/test_bmm_fp8.py
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -40,4 +42,4 @@ def test_bmm_fp8(input_dtype, mat2_dtype, res_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
# Adapted from https://github.com/vllm-project/vllm/blob/main/tests/kernels/mamba/test_causal_conv1d.py
import sys
from typing import Optional
import torch
@@ -486,4 +487,4 @@ def test_causal_conv1d_varlen(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import sgl_kernel
import torch
@@ -13,4 +15,4 @@ def test_copy_to_gpu_no_ce(size):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -101,4 +103,4 @@ def test_cutlass_mla_decode(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import cutlass_w4a8_moe_mm
@@ -282,4 +284,4 @@ def ref_grouped_gemm(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -29,4 +31,4 @@ def test_dsv3_fused_a_gemm(num_tokens):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
import torch.nn.functional as F
@@ -32,4 +34,4 @@ def test_dsv3_router_gemm(num_tokens, num_experts):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,4 +1,5 @@
import random
import sys
from typing import Tuple
import pytest
@@ -202,4 +203,4 @@ def test_fp8_blockwise_scaled_grouped_mm(num_experts, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,4 +1,5 @@
import random
import sys
import pytest
import torch
@@ -152,4 +153,4 @@ def test_es_sm100_mxfp8_blockscaled_grouped_mm(num_experts, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,6 +1,7 @@
# Adapted from https://github.com/Dao-AILab/flash-attention/blob/main/hopper/test_flash_attn.py
import itertools
import math
import sys
from typing import Optional
import pytest
@@ -1365,4 +1366,4 @@ def test_flash_attn_varlen_output(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import math
import sys
from typing import List, Optional, Tuple
import pytest
@@ -489,4 +490,4 @@ def test_convert_vertical_slash_indexes_mergehead(causal):
# f"{torch.max(torch.abs(lse - ref_lse))}"
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,5 +1,6 @@
import math
import random
import sys
from typing import Optional, Tuple
import pytest
@@ -659,4 +660,4 @@ def test_flash_mla_fp8(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,5 +1,6 @@
import os
import random
import sys
from typing import Optional, Type
import pytest
@@ -90,4 +91,4 @@ def test_accuracy(M, N, K, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import random
import sys
from typing import Tuple
import pytest
@@ -218,4 +219,4 @@ def test_fp8_blockwise_scaled_grouped_mm(num_experts, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import fp8_scaled_mm
@@ -46,4 +48,4 @@ def test_accuracy(M, N, K, with_bias, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
import random
import sys
from pathlib import Path
import numpy as np
@@ -163,4 +164,4 @@ def test_mmq(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import gptq_gemm
@@ -128,4 +130,4 @@ def test_gptq_gemm(M, N, K, bit, group_size, use_shuffle, dtype):
if __name__ == "__main__":
pytest.main([__file__, "-v"])
sys.exit(pytest.main([__file__, "-v"]))
+2 -1
View File
@@ -1,4 +1,5 @@
import math
import sys
import pytest
import torch
@@ -82,4 +83,4 @@ def test_fast_hadamard_transform(dim, dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import int8_scaled_mm
@@ -45,4 +47,4 @@ def test_accuracy(M, N, K, with_bias, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import kimi_k2_moe_fused_gate
@@ -121,4 +123,4 @@ def test_kimi_k2_specific_case(seq_length, num_experts, topk):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel.kvcacheio import (
@@ -703,4 +705,4 @@ def test_transfer_kv_page_head(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,5 +1,6 @@
# Adapted from https://github.com/flashinfer-ai/flashinfer/blob/55576c626421b5ee7e7ebe74afd26465c8ae863f/flashinfer/triton/kernels/cascade.py
import sys
from typing import List
import pytest
@@ -139,4 +140,4 @@ def test_merge_state(seq_len, num_heads, head_dim):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,3 +1,4 @@
import sys
from typing import Optional
import pytest
@@ -397,4 +398,4 @@ def test_merge_attn_states(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import itertools
import sys
import pytest
import torch
@@ -271,4 +272,4 @@ def test_moe_sum(m: int, topk: int, k: int, dtype: torch.dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,3 +1,4 @@
import sys
from typing import Optional
import pytest
@@ -215,4 +216,4 @@ def test_moe_fused_gate_combined(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import itertools
import sys
import pytest
import torch
@@ -180,4 +181,4 @@ def test_topk_sigmoid_renormalize_correction_bias(num_tokens, num_experts, topk)
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import itertools
import sys
import pytest
import torch
@@ -180,4 +181,4 @@ def test_topk_softmax_renormalize(num_tokens, num_experts, topk):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,5 +1,7 @@
# Adapted from https://github.com/flashinfer-ai/flashinfer/blob/4e8eb1879f9c3ba6d75511e5893183bf8f289a62/tests/test_norm.py
import sys
import pytest
import sgl_kernel
import torch
@@ -139,4 +141,4 @@ def test_gemma_fused_add_rmsnorm(batch_size, hidden_size, dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,5 +1,6 @@
import itertools
import os
import sys
import time
from pathlib import Path
@@ -182,4 +183,4 @@ def test_per_token_group_quant_with_column_major(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,4 +1,5 @@
import itertools
import sys
from typing import Optional, Tuple
import pytest
@@ -54,4 +55,4 @@ def test_per_token_quant_compare_implementations(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import qserve_w4a8_per_chn_gemm
@@ -115,4 +117,4 @@ def test_accuracy(M, N, K, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
from sgl_kernel import qserve_w4a8_per_group_gemm
@@ -180,4 +182,4 @@ def test_accuracy(M, N, K, group_size, out_dtype):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+3 -1
View File
@@ -1,5 +1,7 @@
# Adapted from https://github.com/flashinfer-ai/flashinfer/blob/93e1a2634e22355b0856246b032b285ad1d1da6b/tests/test_sampling.py
import sys
import flashinfer.sampling
import pytest
import sgl_kernel
@@ -183,4 +185,4 @@ def test_min_p_sampling(batch_size, vocab_size, p):
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
+2 -1
View File
@@ -1,3 +1,4 @@
import sys
from typing import Any, Optional
import pytest
@@ -249,4 +250,4 @@ def test_topk_transform_ragged_kernel(
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))
@@ -1,3 +1,5 @@
import sys
import pytest
import torch
@@ -13,4 +15,4 @@ def test_check_torch_defaults():
if __name__ == "__main__":
pytest.main([__file__])
sys.exit(pytest.main([__file__]))