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/attention/test_aiter_fp8_q_unified_attention.py | .py | """Coverage for the AITER FP8-Q unified-attention decode path."""
import math
import unittest
from types import SimpleNamespace
from unittest import mock
import torch
from sglang.srt.utils import is_hip
from sglang.test.ci.ci_register import register_amd_ci
from sglang.test.test_utils import CustomTestCase
register... | 305 | 11,220 |
sglang | test/registered/attention/test_verify_splitkv.py | .py | """Correctness tests for the split-KV EAGLE-verify attention kernel.
``verify_splitkv_fwd`` is a drop-in for ``extend_attention_fwd`` on the topk=1
causal (target-verify) path. These tests check:
(a) numerical parity with ``extend_attention_fwd`` on the pure-causal path
(the operative case at topk=1), across h... | 254 | 8,984 |
sglang | test/registered/attention/test_wave_attention_kernels.py | .py | import random
import unittest
import torch
from sglang.kernels.ops.attention.decode_attention import (
decode_attention_fwd_grouped as triton_decode_attention_fwd_grouped,
)
from sglang.kernels.ops.attention.extend_attention import (
extend_attention_fwd,
redundant_attention,
)
from sglang.kernels.ops.att... | 355 | 11,886 |
sglang | test/registered/attention/test_flash_attention_4.py | .py | import unittest
from types import SimpleNamespace
import requests
from sglang.srt.utils import get_device_sm, kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
DEFAULT_URL_... | 119 | 3,537 |
sglang | test/registered/attention/test_qwen3_next_deterministic.py | .py | """
Usage:
cd test/srt
python3 -m unittest test_qwen3_next_deterministic.TestFlashInferDeterministic
"""
import unittest
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.test_deterministic_utils import (
COMMON_SERVER_ARGS,
TestDeterministicBase,
)
register_cuda_ci(est_time=200, stage... | 48 | 1,138 |
sglang | test/registered/attention/unittests/conftest.py | .py | import sys
from pathlib import Path
# Put this directory on sys.path so pytest can import the subpackages
# (dense/, mla/, ...) without confusing this directory with the stdlib
# `unittest` module.
_here = str(Path(__file__).resolve().parent)
if _here not in sys.path:
sys.path.insert(0, _here)
| 10 | 300 |
sglang | test/registered/attention/unittests/hybrid_linear/test_flashinfer_mla_chunk_metadata.py | .py | """Regression test: HybridLinearAttnBackend delegates init_mha_chunk_metadata.
Hybrid MLA models (Ring/Ling, Kimi-Linear) run DeepSeek-style MLA on their
full-attention layers. Prefill plans the flashinfer ragged wrapper via
``hasattr(get_attn_backend(), "init_mha_chunk_metadata")`` (forward_mha.py).
For a hybrid mode... | 146 | 5,177 |
sglang | test/registered/attention/unittests/hybrid_linear/test_verify_buffer_fixup_hook.py | .py | """The mamba plan-stream verify fixup hook must refresh draft-produced tree links.
Under ``SGLANG_ENABLE_OVERLAP_PLAN_STREAM``, ``_replay_metadata`` copies
``spec_info.retrieve_next_token`` / ``retrieve_next_sibling`` into the captured
per-bs buffers on the plan stream, racing the draft's ``build_tree`` on the
compute... | 132 | 5,408 |
sglang | test/registered/attention/unittests/kda/test_triton.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_hip
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.kda_attention import (
KDAAttentionCase,
mak... | 259 | 8,953 |
sglang | test/registered/attention/unittests/dense/test_extend_init_contract.py | .py | """Unit tests for the init contract that piecewise + breakable cuda graph
capture rely on with ``forward_mode=EXTEND``.
The piecewise + breakable runners (unlike the full ``cuda_graph_runner``)
capture prefill chunks, which means their capture path passes
``forward_mode=ForwardMode.EXTEND`` to ``attn_backend.init_forw... | 143 | 5,830 |
sglang | test/registered/attention/unittests/dense/test_fa4.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
make_dense_cases,
run_dense_attention_case,
)
fr... | 429 | 15,184 |
sglang | test/registered/attention/unittests/dense/test_triton.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_hip
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
... | 463 | 16,039 |
sglang | test/registered/attention/unittests/dense/test_flex_attention.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
make_dense_cases,
run_dense_attention_case,
)
fr... | 114 | 3,944 |
sglang | test/registered/attention/unittests/dense/test_flashinfer.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_flashinfer_available
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
... | 425 | 14,005 |
sglang | test/registered/attention/unittests/dense/test_hybrid_attn.py | .py | import unittest
import torch
from sglang.srt.layers.attention.attention_registry import ATTENTION_BACKENDS
from sglang.srt.layers.attention.hybrid_attn_backend import HybridAttnBackend
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_flashinfer_available
from sglang... | 91 | 3,257 |
sglang | test/registered/attention/unittests/dense/test_tbo.py | .py | import unittest
import torch
from sglang.srt.layers.attention.attention_registry import ATTENTION_BACKENDS
from sglang.srt.layers.attention.tbo_backend import TboAttnBackend
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import get_device_sm
from sglang.test.ci.ci_register ... | 222 | 9,099 |
sglang | test/registered/attention/unittests/dense/test_fa3.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import get_device_sm
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
make_dens... | 439 | 15,649 |
sglang | test/registered/attention/unittests/dense/test_trtllm_mha.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_flashinfer_available
from sglang.srt.utils.common import (
is_sm90_supported,
is_sm100_supported,
is_sm120_supported,
)
from sglang.test.ci.ci_register import register_cuda_ci
... | 382 | 13,313 |
sglang | test/registered/attention/unittests/dense/test_torch_native.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
make_dense_cases,
run_dense_att... | 112 | 3,858 |
sglang | test/registered/attention/unittests/mamba/test_mamba2.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import MagicMock
import torch
from sglang.srt.layers.attention.hybrid_linear_attn_backend import (
HybridLinearAttnBackend,
MambaAttnBackendBase,
)
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_r... | 331 | 13,528 |
sglang | test/registered/attention/unittests/dsv4/test_deepseek_v4.py | .py | """DSV4 attention correctness — SWA + C4/C128 coverage.
Covers eager EXTEND/DECODE plus CUDA-graph-style capture/replay for the
SWA-only (compress_ratio=0) path of `DeepseekV4AttnBackend` through flash_mla
with the production packed FP8-nope/BF16-rope SWA cache, plus math-faithful
EAGER coverage for the C4 (compress_r... | 624 | 24,916 |
sglang | test/registered/attention/unittests/dual_chunk/test_dual_chunk_flash_attn.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.kits.attention_unittest.attention_methods.dual_chunk_attention import (
DualChunkAttentionCase,
make_dual_chunk_cases,
make_dual_chunk_sparse_cases,
make_dual_chunk_sparse_sub_window_case... | 178 | 7,739 |
sglang | test/registered/attention/unittests/swa/test_triton.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_hip
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
... | 346 | 11,729 |
sglang | test/registered/attention/unittests/swa/test_flashinfer.py | .py | import unittest
import torch
from sglang.srt.environ import envs
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_flashinfer_available
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention ... | 271 | 9,834 |
sglang | test/registered/attention/unittests/swa/test_swa_out_cache_loc.py | .py | """Unit coverage for SWAKVPool.set_kv_buffer with a pre-translated swa_loc.
The attention backend translates out_cache_loc once per forward and passes it
in via a ``KVWriteLoc`` (loc + swa_loc) on the loc_info argument; set_kv_buffer
uses swa_loc directly for SWA layers and asserts it is provided. The per-backend
cuda... | 84 | 2,977 |
sglang | test/registered/attention/unittests/swa/test_torch_native.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dense_attention import (
DenseAttentionCase,
make_swa_no_prefix_input_config_cas... | 136 | 4,884 |
sglang | test/registered/attention/unittests/gdn/test_linear_replayssm_decode.py | .py | """Correctness test for the buffered output-only linear-attention decode kernel
(ReplaySSM Part A), implemented in
``python/sglang/srt/layers/attention/fla/fused_recurrent_linear_replayssm.py``.
One kernel, two gate granularities (selected by ``is_kda``):
* GDN (``is_kda=False``): per-head SCALAR gate. Ground truth ... | 341 | 15,617 |
sglang | test/registered/attention/unittests/gdn/test_triton.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import MagicMock
import torch
from sglang.srt.layers.attention.hybrid_linear_attn_backend import (
HybridLinearAttnBackend,
MambaAttnBackendBase,
)
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils im... | 407 | 14,550 |
sglang | test/registered/attention/unittests/gdn/test_flashinfer.py | .py | import unittest
import torch
from sglang.srt.layers.attention.linear.kernels.gdn_triton import TritonGDNKernel
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_flashinfer_available
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attenti... | 397 | 13,343 |
sglang | test/registered/attention/unittests/gdn/test_gdn_cutedsl_ring_verify.py | .py | """Vendored CuTe DSL GDN MTP verify with the fused ReplaySSM ring-write.
The ring-write must be a pure side channel and the ring must feed the fold a
faithful raw window, so the anchor is:
* the verify OUTPUT is bitwise unchanged by cache_ring (both the ilp4 and
the wide_vec kernels);
* rawv/rawk are bitwise ... | 151 | 5,344 |
sglang | test/registered/attention/unittests/gdn/test_gdn_replayssm_spec_fold.py | .py | """GDN ReplaySSM fold-every-commit: fused ring-write + commit fold.
The production kernel targets bitwise parity with the recurrent verify and
per-draft snapshot baseline. These tests allow an absolute error up to FP32_ATOL
for committed/tracked state and downstream outputs, and verify that bound
through 256 chained c... | 247 | 9,076 |
sglang | test/registered/attention/unittests/gdn/test_torch_native.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.utils import is_hip
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.gdn_attention import (
GDNAttentionCase,
mak... | 102 | 3,566 |
sglang | test/registered/attention/unittests/mla/test_cutlass_mla.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.kits.attention_unittest.attention_methods.mla_attention import (
MLAAttentionCase,
run_mla_attention_case,
)
from sglang.test.test_utils import CustomTestCase
# Cutlass MLA requires exactly Blac... | 99 | 3,191 |
sglang | test/registered/attention/unittests/mla/test_tokenspeed_mla.py | .py | import importlib.util
import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.kits.attention_unittest.attention_methods.mla_attention import (
MLAAttentionCase,
run_mla_attention_case,
)
from sglang.test.test_utils import CustomTestCase
# tokenspeed_... | 186 | 6,254 |
sglang | test/registered/attention/unittests/mla/test_flashmla.py | .py | import unittest
import torch
import triton
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.srt.model_executor.forward_context import ForwardContext, forward_context
from sglang.test.kits.attention_unittest.attention_methods.mla_attention import (
MLAAttentionCase,
build_mla_at... | 441 | 16,821 |
sglang | test/registered/attention/unittests/mla/test_triton.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.mla_attention import (
MLAAttentionCase,
make_mla_cases,
run_mla_attention_case,
)
from sglan... | 371 | 12,777 |
sglang | test/registered/attention/unittests/mla/test_flashinfer.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.kits.attention_unittest.attention_methods.mla_attention import (
MLAAttentionCase,
make_mla_cases,
run_mla_attention_case,
)
from sglang.test.kits.attention_unittest.runner_modes.cuda_graph_d... | 251 | 9,649 |
sglang | test/registered/attention/unittests/mla/test_trtllm_mla.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.kits.attention_unittest.attention_methods.mla_attention import (
MLAAttentionCase,
run_mla_attention_case,
)
from sglang.test.test_utils import CustomTestCase
# trtllm_mla goes through FlashInfe... | 162 | 5,171 |
sglang | test/registered/attention/unittests/dsa/test_dsa.py | .py | import unittest
import torch
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.dsa_attention import (
DSA_DECODE_IMPL_VARIANTS,
DSA_PAGE_SIZE,
DSA_PREFILL_IMPL_VARIANTS,
... | 401 | 16,507 |
sglang | test/registered/attention/unittests/lightning/test_triton.py | .py | import unittest
import torch
from sglang.kernels.ops.attention.linear.seg_la import SegLaMeta, seg_la_fwd
from sglang.srt.model_executor.forward_batch_info import ForwardMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.attention_unittest.attention_methods.lightning_a... | 275 | 10,268 |
sglang | test/registered/profiling/test_start_profile.py | .py | """
Usage:
# From the test/srt directory:
cd test/srt
python3 -m unittest test_start_profile.TestStartProfile
python3 -m unittest test_start_profile.TestStartProfileWithNsys
# Run specific tests:
python3 -m unittest test_start_profile.TestStartProfile.test_start_profile_1
python3 -m unittest test_start_profile.TestSta... | 347 | 11,405 |
sglang | test/registered/profiling/test_profile_v2.py | .py | import os
import shutil
import tempfile
import unittest
from pathlib import Path
import requests
from sglang.srt.environ import envs
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DE... | 111 | 3,147 |
sglang | test/registered/ep/test_tbo_shared_experts_fusion.py | .py | import os
import unittest
from types import SimpleNamespace
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
DEFAULT_URL_FOR_TEST,
CustomTe... | 74 | 1,999 |
sglang | test/registered/ep/test_flashinfer_a2a.py | .py | import unittest
from types import SimpleNamespace
import requests
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_PORT_FOR_SRT_TEST_RUNNER,
DEFAULT_URL_FOR_TEST,
Cu... | 201 | 6,079 |
sglang | test/registered/ep/test_mooncake_ep_small.py | .py | import subprocess
import unittest
from types import SimpleNamespace
import requests
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.server_fixtures.disaggregation_fixture import get_rdma_devices_args
from... | 149 | 4,291 |
sglang | test/registered/ep/test_deepep_small.py | .py | import os
import unittest
from types import SimpleNamespace
import requests
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_MODEL_NAME_FOR_TEST_MLA,
DEFAULT_MODEL_NAME_... | 579 | 16,765 |
sglang | test/registered/ep/test_eplb_no_a2a.py | .py | """EPLB with redundant experts on the no-a2a MoE path (--moe-a2a-backend none).
There, all EP ranks run the MoE over the same tokens and sum their partial
outputs, so the logical->physical pick has to be identical on every rank -- a
rank-dependent one counts a replicated logical expert several times and silently
degra... | 111 | 3,679 |
sglang | test/registered/ep/test_deepep_large.py | .py | import unittest
from types import SimpleNamespace
import requests
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.send_one import BenchArgs, send_one_prompt
from sglang.test.test_utils import (
DEFAUL... | 220 | 6,709 |
sglang | test/registered/cuda_graph/test_cuda_piecewise_backend.py | .py | from unittest.mock import MagicMock
import pytest
import torch
from sglang.test.ci.ci_register import register_cuda_ci
register_cuda_ci(est_time=5, stage="base-b", runner_config="1-gpu-small")
if not torch.cuda.is_available():
pytest.skip("CUDA piecewise backend requires CUDA", allow_module_level=True)
import ... | 57 | 1,839 |
sglang | test/registered/cuda_graph/piecewise/test_pcg_with_speculative_decoding_dflash.py | .py | """Test piecewise CUDA graph coexisting with speculative decoding (DFLASH).
PCG handles prefill/extend path while DFlash needs target aux hidden states
from prefill to materialize draft KV cache. This verifies PCG captures that
path with the DFlash hidden-state variant enabled.
"""
import unittest
from sglang.test.c... | 53 | 1,573 |
sglang | test/registered/cuda_graph/piecewise/test_pcg_with_speculative_decoding_extra.py | .py | """Extra: PCG coexistence with non-EAGLE3 speculative decoding variants.
EAGLE3 lives in the sibling file test_pcg_with_speculative_decoding.py.
"""
import unittest
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.server_fixtures.pcg_spec_fixture import PCGSpecBase
register_cuda_ci(est_time=... | 80 | 2,101 |
sglang | test/registered/cuda_graph/piecewise/test_pcg_with_speculative_decoding.py | .py | """Test piecewise CUDA graph coexisting with speculative decoding (EAGLE3).
PCG handles prefill/extend path while speculative decoding (EAGLE3) uses
decode CUDA graphs. This test verifies they don't interfere with each
other. MTP / STANDALONE / NGRAM variants moved to the sibling file
test_pcg_with_speculative_decodin... | 46 | 1,393 |
sglang | test/registered/cuda_graph/piecewise/test_piecewise_cuda_graph_support_1_gpu.py | .py | import unittest
import torch
from transformers import AutoProcessor
from sglang import Engine
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_IMAGE_URL,
... | 132 | 4,162 |
sglang | test/registered/cuda_graph/breakable/test_bcg_with_lora.py | .py | """LoRA under the breakable (BCG) prefill CUDA graph.
For csgmv and triton, launches the same LoRA-enabled server with the prefill
graph breakable vs disabled and compares per-token prompt logprobs for LoRA,
base, and mixed batches. Guards against vacuous passes by scraping the logs
for graph-served prefill batches (i... | 306 | 10,951 |
sglang | test/registered/cuda_graph/breakable/test_breakable_cuda_graph.py | .py | """Tests for the breakable CUDA graph (BCG) runner.
Two test classes:
- TestBreakableCUDAGraphBasic / TestCopyOutput / TestBreakGraphHelper:
unit tests for the core capture / replay mechanism (simple tensor ops).
- TestBreakableCudaGraph: integration test — spin up Qwen3-8B with
--enable-breakable-cuda-graph and c... | 404 | 14,394 |
sglang | test/registered/cuda_graph/breakable/test_bcg_with_speculative_decoding.py | .py | """Test breakable CUDA graph (BCG) coexisting with EAGLE3 speculative
decoding. Sibling of test_pcg_with_speculative_decoding.py — same
target/draft pair, only flips the prefill backend from tc_piecewise to
breakable. Verifies the draft-side BCG plumbing in PrefillCudaGraphRunner
stays wired (capture_hidden_mode for EA... | 47 | 1,509 |
sglang | test/registered/cuda_graph/full_prefill/test_full_cuda_graph_prefill.py | .py | """Integration tests for the full prefill CUDA graph backend.
The Qwen3-8B test checks end-to-end accuracy with FlashInfer. The smaller
DeepSeek-Coder-V2-Lite test checks that an MLA radix-prefix hit selects the
OSS FA4 cached-prefix graph variant and matches an eager cold request.
The attention backend is pinned to ... | 165 | 5,924 |
sglang | test/registered/4-gpu-models/test_nvidia_nemotron_3_super_nvfp4.py | .py | import unittest
from types import SimpleNamespace
from sglang.srt.environ import envs
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
DEFAULT_... | 166 | 4,421 |
sglang | test/registered/4-gpu-models/test_deepseek_v3_cutedsl_4gpu.py | .py | import os
import unittest
from types import SimpleNamespace
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.run_eval import run_eval
from sglang.test.test_utils import (
DEFAULT_DEEPSEEK_NVFP4_MODEL_FOR_TEST,
DEFAULT_PORT_FOR_SRT_TEST_RUNN... | 187 | 5,805 |
sglang | test/registered/kv_canary/test_self_e2e_pp_perturb.py | .py | from __future__ import annotations
import unittest
from typing import ClassVar
from sglang.srt.kv_canary.config import CanaryMode
from sglang.srt.kv_canary.perturb.config import TargetGroupKind
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.pp_fixture import Canary... | 42 | 1,444 |
sglang | test/registered/kv_canary/test_self_e2e_pd_baseline.py | .py | from __future__ import annotations
import unittest
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.pd_fixture import CanaryPDFixture
register_cuda_ci(est_time=180, stage="extra-a", runner_config="2-gpu-large")
register_amd_ci(est_time=106, stage="extra-a", runner_c... | 32 | 988 |
sglang | test/registered/kv_canary/test_self_e2e_baseline.py | .py | from __future__ import annotations
import unittest
from sglang.srt.kv_canary.config import CanaryMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.consts import SWA_POOL_SERVER_ARGS
from sglang.test.kv_canary.e2e_base import CanaryE2EBase
register_cuda_ci(est_ti... | 46 | 1,420 |
sglang | test/registered/kv_canary/test_self_unit_runner_health.py | .py | from __future__ import annotations
import logging
import unittest
from unittest.mock import Mock
import torch
from sglang.kernels.ops.kv_canary.verify import CanaryLaunchTag
from sglang.srt.kv_canary.config import CanaryConfig
from sglang.srt.kv_canary.runner import stats_logger as stats_logger_module
from sglang.sr... | 130 | 5,309 |
sglang | test/registered/kv_canary/test_self_unit_violation.py | .py | from __future__ import annotations
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.kernels.ops.kv_canary import consts
from sglang.kernels.ops.kv_canary.consts import FailReason
from sglang.kernels.ops.kv_canary.verify import CanaryLaunchTag
from sglang.srt.... | 367 | 17,927 |
sglang | test/registered/kv_canary/test_self_e2e_pp_baseline.py | .py | from __future__ import annotations
import unittest
from sglang.srt.kv_canary.config import CanaryMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.pp_fixture import CanaryPPFixture
register_cuda_ci(est_time=220, stage="extra-a", runner_config="2-gpu-large")
regi... | 26 | 762 |
sglang | test/registered/kv_canary/test_self_e2e_perturb_raise.py | .py | from __future__ import annotations
import unittest
from sglang.srt.kv_canary.config import CanaryMode
from sglang.srt.kv_canary.perturb.config import TargetGroupKind
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.e2e_base import CanaryE2EBase
register_cuda_ci(est_... | 43 | 1,446 |
sglang | test/registered/kv_canary/test_self_e2e_pd_perturb.py | .py | from __future__ import annotations
import unittest
from typing import ClassVar
from sglang.srt.kv_canary.perturb.config import TargetGroupKind
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.pd_fixture import CanaryPDFixture
register_cuda_ci(est_time=180, stage="ex... | 83 | 3,340 |
sglang | test/registered/kv_canary/test_self_e2e_pr_26329.py | .py | """Regression for PR #26329 EAGLE chunked-prefill rotation."""
from __future__ import annotations
import random
import string
import unittest
from typing import ClassVar
from sglang.srt.kv_canary.config import CanaryMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_can... | 86 | 2,651 |
sglang | test/registered/kv_canary/test_self_unit_pool_patcher.py | .py | from __future__ import annotations
import unittest
import torch
from sglang.kernels.ops.kv_canary.consts import MAX_REAL_KV_SOURCES, RealKvHashMode
from sglang.kernels.ops.kv_canary.verify import (
CANARY_SLOT_BYTES,
CanaryLaunchTag,
RealKvSource,
VerifyOrWriteContext,
VerifyPlan,
launch_cana... | 204 | 8,630 |
sglang | test/registered/kv_canary/test_self_unit_capacities.py | .py | from __future__ import annotations
import unittest
from types import SimpleNamespace
from sglang.srt.kv_canary.capacities import CanaryLaunchCapacities
from sglang.srt.model_executor.cuda_graph_config import (
Backend,
CudaGraphConfig,
PhaseConfig,
)
from sglang.test.ci.ci_register import register_cpu_ci
... | 97 | 3,486 |
sglang | test/registered/kv_canary/test_self_unit_radix_walker.py | .py | from __future__ import annotations
import unittest
from array import array
from unittest import mock
import torch
from sglang.srt.kv_canary.radix_cache_walker import walk_radix_cache_for_canary
from sglang.srt.mem_cache.cache_init_params import CacheInitParams
from sglang.srt.mem_cache.radix_cache import RadixKey
fr... | 249 | 11,262 |
sglang | test/registered/kv_canary/test_self_unit_runner_sweep.py | .py | from __future__ import annotations
import unittest
from unittest.mock import patch
from sglang.srt.kv_canary import endpoint as endpoint_module
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.fixtures import (
make_forward_batch,
make_radix_cache,
make_r... | 101 | 3,930 |
sglang | test/registered/kv_canary/test_self_e2e_pr_25015.py | .py | """Regression for PR #25015 EAGLE positions misalign: revert the fix and expect canary fire."""
from __future__ import annotations
import unittest
from typing import ClassVar
from sglang.srt.kv_canary.config import CanaryMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.k... | 89 | 2,769 |
sglang | test/registered/kv_canary/test_self_e2e_bench_speed.py | .py | from __future__ import annotations
import argparse
import dataclasses
import os
import unittest
from pathlib import Path
from typing import ClassVar, Optional
from sglang.bench_one_batch_server import (
BenchArgs,
BenchOneCaseResult,
run_benchmark_internal,
)
from sglang.srt.entrypoints.http_server import... | 260 | 8,998 |
sglang | test/registered/kv_canary/test_self_unit_plan_input.py | .py | from __future__ import annotations
import unittest
from types import SimpleNamespace
import torch
from sglang.srt.kv_canary.plan_input import PlanInput
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.fixtures import (
DEFAULT_DEVICE,
make_forward_batch,
)
f... | 152 | 6,916 |
sglang | test/registered/kv_canary/test_self_unit_sweep_plan_builder.py | .py | from __future__ import annotations
import unittest
import torch
from sglang.srt.kv_canary.sweep_plan_builder import build_verify_plan_radix_sweep
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.fixtures import (
DEFAULT_DEVICE,
make_radix_cache,
make_re... | 102 | 4,195 |
sglang | test/registered/kv_canary/test_self_unit_token_oracle.py | .py | from __future__ import annotations
import unittest
from types import SimpleNamespace
import torch
from sglang.srt.kv_canary.expected_inputs import ExpectedInputs
from sglang.srt.kv_canary.token_oracle.oracle import HashOracle
from sglang.srt.kv_canary.token_oracle.oracle_manager import TokenOracleManager
from sglang... | 69 | 2,805 |
sglang | test/registered/kv_canary/test_self_unit_buffer_alloc.py | .py | from __future__ import annotations
import sys
import unittest
import torch
from sglang.kernels.ops.kv_canary.consts import RealKvHashMode
from sglang.srt.kv_canary.config import CanaryConfig, CanaryMode
from sglang.srt.kv_canary.pool_patcher.buffer_alloc import (
make_packed_source,
make_row_source,
reso... | 145 | 5,932 |
sglang | test/registered/kv_canary/test_self_unit_runner_swa_divergence.py | .py | from __future__ import annotations
import logging
import unittest
from types import SimpleNamespace
import torch
from sglang.kernels.ops.kv_canary.verify import VerifyPlan
from sglang.srt.environ import envs
from sglang.srt.kv_canary.buffer_group import PoolKind
from sglang.srt.kv_canary.runner import swa_divergence... | 467 | 17,742 |
sglang | test/registered/kv_canary/test_self_e2e_perturb_real_kv_used.py | .py | from __future__ import annotations
import unittest
from typing import ClassVar
from sglang.srt.kv_canary.config import CanaryMode
from sglang.srt.kv_canary.perturb.config import TargetGroupKind
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.consts import SWA_POOL_S... | 71 | 2,340 |
sglang | test/registered/kv_canary/test_e2e_base.py | .py | import unittest
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.kv_canary.e2e_base import (
_LONG_PROMPT_BODY,
_UNIQUE_PROMPT_FIRST_CHARS,
_make_unique_prompts,
)
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=1, suite="base-c-test-cpu")
class TestCana... | 32 | 1,139 |
sglang | test/registered/kv_canary/test_self_e2e_perturb_req_to_token.py | .py | from __future__ import annotations
import unittest
from sglang.srt.kv_canary.config import CanaryMode
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.consts import SWA_POOL_SERVER_ARGS
from sglang.test.kv_canary.e2e_base import CanaryE2EBase
register_cuda_ci(est_ti... | 52 | 1,954 |
sglang | test/registered/kv_canary/test_self_unit_pool_patcher_utils.py | .py | from __future__ import annotations
import unittest
from sglang.srt.kv_canary.pool_patcher.utils import wrap_method
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import CustomTestCase
register_cuda_ci(est_time=10, stage="extra-a", runner_config="1-gpu-small")
reg... | 54 | 2,079 |
sglang | test/registered/kv_canary/test_self_unit_perturb.py | .py | from __future__ import annotations
import os
import unittest
from typing import TYPE_CHECKING, cast
from unittest.mock import patch
import torch
from sglang.kernels.ops.kv_canary.verify import RealKvSource
from sglang.srt.kv_canary.buffer_group import PoolKind
from sglang.srt.kv_canary.perturb import (
real_kv_p... | 543 | 21,433 |
sglang | test/registered/kv_canary/test_self_e2e_perturb_real_kv_unused_cache.py | .py | from __future__ import annotations
import unittest
from typing import ClassVar
from sglang.srt.kv_canary.config import CanaryMode
from sglang.srt.kv_canary.perturb.config import TargetGroupKind
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kv_canary.consts import SWA_POOL_S... | 83 | 2,800 |
sglang | test/registered/kv_canary/test_self_unit_runner_per_forward.py | .py | from __future__ import annotations
import unittest
from unittest.mock import patch
import torch
from sglang.kernels.ops.kv_canary.consts import RealKvHashMode
from sglang.kernels.ops.kv_canary.verify import CanaryLaunchTag, VerifyPlan
from sglang.kernels.ops.kv_canary.write import WritePlan
from sglang.srt.kv_canary... | 301 | 13,084 |
sglang | test/registered/kv_canary/test_self_unit_req_to_expected_token_ids_manager.py | .py | from __future__ import annotations
import unittest
from array import array
from types import SimpleNamespace
import torch
from sglang.srt.kv_canary.req_to_expected_token_ids_manager import (
compute_req_all_ids_info,
populate_req_to_expected_token_ids,
)
from sglang.test.ci.ci_register import register_amd_ci... | 172 | 7,064 |
sglang | test/registered/kv_canary/test_self_unit_endpoint.py | .py | from __future__ import annotations
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.kernels.ops.kv_canary.consts import RealKvHashMode
from sglang.kernels.ops.kv_canary.verify import (
CANARY_SLOT_BYTES,
CanaryLaunchTag,
VerifyPlan,
)
from sglang.... | 261 | 10,909 |
sglang | test/registered/kv_canary/test_self_unit_future_tensor.py | .py | from __future__ import annotations
import unittest
from typing import cast
import torch
from sglang.srt.kv_canary.runner.future_tensor import FutureTensors
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import CustomTestCase
register_cuda_ci(est_time=20, stage="... | 182 | 7,936 |
sglang | test/registered/kv_canary/test_self_unit_e2e_base.py | .py | from __future__ import annotations
import unittest
from unittest.mock import patch
from sglang.srt.kv_canary.runner.swa_divergence import SwaDivergenceLog
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.kv_canary.e2e_base import CanaryE2EBase
from sglang.test.test_utils import CustomTestCase
... | 205 | 7,263 |
sglang | examples/usage/modelopt_quantize_and_export.py | .py | #!/usr/bin/env python3
"""
Example: ModelOpt Quantization and Export with SGLang
This example demonstrates the streamlined workflow for quantizing a model with
ModelOpt and automatically exporting it for deployment with SGLang.
"""
import argparse
import os
from typing import Optional
import torch
import sglang as ... | 304 | 9,836 |
sglang | examples/usage/reasoning_aware_compression/rac_collect_traces.py | .py | #!/usr/bin/env python3
"""
Phase I of Reasoning-Aware Compression (RAC): collect on-policy chain-of-thought
traces with SGLang and write them out as a pruning calibration set.
RAC ("Reasoning Models Can be Accurately Pruned Via Chain-of-Thought
Reconstruction", ICLR 2026, https://arxiv.org/abs/2509.12464) starts from ... | 433 | 14,731 |
sglang | examples/usage/reasoning_aware_compression/rac_prune.py | .py | #!/usr/bin/env python3
"""
Phase II of Reasoning-Aware Compression (RAC): one-shot prune a reasoning model
against the on-policy chain-of-thought calibration set built by
`rac_collect_traces.py`.
RAC (https://arxiv.org/abs/2509.12464, ICLR 2026) does not change the pruning
solver. Its whole contribution is which activ... | 233 | 7,590 |
sglang | examples/usage/reasoning_aware_compression/rac_serve_and_eval.py | .py | #!/usr/bin/env python3
"""
Phase III of the Reasoning-Aware Compression (RAC) recipe: serve one or more
checkpoints with SGLang and score them on MATH-500.
The point of this script is the *pair* of numbers it reports. The RAC paper
(https://arxiv.org/abs/2509.12464, ICLR 2026) shows that a badly calibrated
pruned reas... | 260 | 8,398 |
sglang | examples/checkpoint_engine/update.py | .py | """
Usage:
1) Launch the server with wait-for-initial-weights option in one terminal:
python -m sglang.launch_server --model-path /workspace/Qwen/Qwen3-4B/ --tensor-parallel-size 2 --port 19730 --load-format dummy --checkpoint-engine-wait-weights-before-ready --mem-fraction-static 0.7
2) Torchrun this script in ano... | 242 | 8,472 |
sglang | examples/sagemaker/deploy_and_serve_endpoint.py | .py | import json
import boto3
from sagemaker import serializers
from sagemaker.model import Model
from sagemaker.predictor import Predictor
boto_session = boto3.session.Session()
sm_client = boto_session.client("sagemaker")
sm_role = boto_session.resource("iam").Role("SageMakerRole").arn
endpoint_name = "<YOUR_ENDPOINT_N... | 70 | 1,894 |
sglang | examples/profiler/nsys_profile_tools/gputrc2graph.py | .py | """
This generates gpu kernel analysis output from nsys rep. Will call nsys
stats -r cuda_gpu_kern_trace, get non-overlapped gpu cycles, then generate
csv and html output for analysis
"""
import argparse
import logging
import os
import shlex
import regex as re
logger = logging.getLogger(__name__)
# helper data cl... | 347 | 12,809 |
sglang | examples/frontend_language/usage/json_logprobs.py | .py | # NOTE: Currently this can only be run through HTTP requests.
from concurrent.futures import ThreadPoolExecutor
from json_decode import character_regex
from sglang.utils import http_request
character_names = ["Hermione Granger", "Ron Weasley", "Harry Potter"]
base_url = "http://localhost:30000"
prompt = "is a char... | 104 | 3,258 |
sglang | examples/frontend_language/usage/parallel_sample.py | .py | """
Usage:
python3 parallel_sample.py
"""
import sglang as sgl
@sgl.function
def parallel_sample(s, question, n):
s += (
"Question: Compute 1 + 2 + 3\n"
"Reasoning: I need to use a calculator.\n"
"Tool: calculator\n"
"Answer: 6\n"
"Question: Compute 3 + 2 + 2\n"
"R... | 41 | 1,103 |
sglang | examples/frontend_language/usage/sgl_gen_min_tokens.py | .py | """
This example demonstrates how to use `min_tokens` to enforce sgl.gen to generate a longer sequence
Usage:
python3 sgl_gen_min_tokens.py
"""
import sglang as sgl
@sgl.function
def long_answer(s):
s += sgl.user("What is the capital of the United States?")
s += sgl.assistant(sgl.gen("answer", min_tokens=64... | 36 | 839 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.