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/unit/managers/test_schedule_batch_prepare_for_decode.py | .py | import types
import unittest
from unittest.mock import patch
import torch
from sglang.srt.runtime_context import get_context
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.managers.schedule_batch import Schedule... | 86 | 3,244 |
sglang | test/registered/unit/managers/test_scheduler_chunked_req_gate.py | .py | """Regression tests for the SWA chunked-req stash gate (#24252)."""
import unittest
from array import array
from types import SimpleNamespace
from unittest.mock import MagicMock
import torch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase, maybe_stub_sgl_kerne... | 183 | 6,775 |
sglang | test/registered/unit/managers/test_vocab_boundary_finish.py | .py | """Regression tests for Req._check_vocab_boundary_finish NaN guard boundary."""
import unittest
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase, maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.managers.schedule_batch import FINISH_MATCHED_STR, R... | 75 | 2,837 |
sglang | test/registered/unit/managers/test_retraction_order.py | .py | import unittest
from types import SimpleNamespace
from sglang.srt.managers.schedule_batch import ScheduleBatch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=2, suite="base-a-test-cpu")
def _req(output_len: int, input_len: int = 8, p... | 60 | 2,145 |
sglang | test/registered/unit/managers/test_flat_raw_top_logprobs.py | .py | """Unit tests for the flat raw prompt top logprob response format
(`return_flat_raw_top_logprobs` / `return_flat_raw_top_logprobs_b64`).
"""
import asyncio
import base64
import json
import os
import pickle
import time
import unittest
from array import array
from types import SimpleNamespace
import numpy as np
from s... | 762 | 29,984 |
sglang | test/registered/unit/managers/test_fanout_communicator.py | .py | """Unit tests for FanOutCommunicator -- no server, no model loading."""
import asyncio
import unittest
from sglang.srt.managers.communicator import FanOutCommunicator
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=5, suite="base-a-tes... | 52 | 1,889 |
sglang | test/registered/unit/managers/test_io_struct.py | .py | import copy
import unittest
from sglang.srt.managers.io_struct import EmbeddingReqInput, GenerateReqInput
from sglang.test.ci.ci_register import (
register_amd_ci,
register_cpu_ci,
register_cuda_ci,
)
from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_URL_FOR_TEST,
... | 826 | 31,306 |
sglang | test/registered/unit/managers/test_mm_hashes.py | .py | """Tests for caller-supplied mm_hashes plumbing.
Verifies the contract that:
1. GenerateReqInput.mm_hashes is an optional list of hex strings.
2. MultimodalDataItem.set_pad_value() honors a pre-set hash and does NOT
overwrite it via hash_feature().
3. The derived pad_value is deterministic across requests w... | 117 | 4,605 |
sglang | test/registered/unit/managers/test_stop_str_speculative.py | .py | """Regression for stop-string / stop-regex finishing under speculative decoding
(multi-token commits): a stop committed mid-chunk must (1) trigger the finish
check and (2) set finished_len so the emitted output is trimmed at the stop, not
leaking tokens accepted after it. Drives the real `Req.update_finish_state` with
... | 152 | 6,170 |
sglang | test/registered/unit/managers/test_mamba_checkpoint_depth.py | .py | """The donated mamba checkpoint depth must land on the tree page.
DCP widens the tree page past the mamba chunk grid. A checkpoint picked on the
finer grid names a depth no radix node can carry, so it gets attached to the
preceding node and a later request resumes from a state that already covers
tokens past that node... | 75 | 2,732 |
sglang | test/registered/unit/managers/test_scheduler_recv_skipper.py | .py | import unittest
from types import SimpleNamespace
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase, maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.managers.scheduler_components.recv_skipper import ( # noqa: E402
SchedulerRecvSkipper,
)
from ... | 100 | 4,028 |
sglang | test/registered/unit/managers/test_tokenizer_config_updates.py | .py | """Control-plane config updates stay on the tokenizer manager.
Regression: runtime updates (weight version, model path, HiCache attach) were
written onto the manager's ServerArgs instance so that the readback endpoints
would show them. They are per-engine — several Engines can share a tokenizer
process — so they live ... | 217 | 8,431 |
sglang | test/registered/unit/managers/test_scheduler_decision_batch_params.py | .py | import inspect
import unittest
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.disaggregation.decode import SchedulerDisaggregationDecodeMixin
from sglang.srt.disaggregation.prefill import SchedulerDisaggregationP... | 53 | 1,964 |
sglang | test/registered/unit/managers/test_profile_merger_http_api.py | .py | import unittest
from sglang.srt.managers.io_struct import ProfileReq
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=8, suite="base-a-test-cpu")
class TestProfileMergerHTTPAPI(CustomTestCase):
def test_profile_req_merge_profiles_j... | 62 | 2,073 |
sglang | test/registered/unit/managers/test_mm_utils_split.py | .py | """Unit tests for ``get_new_expanded_mm_items`` per-image splitting.
This is the load-bearing behavioral path for multi-image requests: a bundled
``MultimodalDataItem`` (one item carrying N image offsets + a concatenated
feature) must be split back into N per-image items so RadixAttention can cache
each image independ... | 146 | 6,039 |
sglang | test/registered/unit/managers/test_batch_result_processor_spec_grammar.py | .py | """Unit tests for Spec V2 grammar truncation in _resolve_spec_v2_tokens.
The grammar-constrained spec path stops accepting at the grammar-terminating
token, so the over-drafted suffix is never committed to KV nor emitted.
"""
import unittest
from types import SimpleNamespace
import torch
from sglang.srt.managers.sc... | 153 | 4,853 |
sglang | test/registered/unit/managers/test_grammar_stop_speculative.py | .py | """Regression tests for grammar termination during speculative decoding."""
import unittest
from array import array
from sglang.srt.managers.schedule_batch import Req
from sglang.srt.sampling.sampling_params import SamplingParams
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=5, suit... | 70 | 2,036 |
sglang | test/registered/unit/managers/test_schedule_batch_out_of_place.py | .py | import dataclasses
import types
import unittest
from array import array
from unittest.mock import MagicMock
import torch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.managers.schedule_batch import ScheduleBatc... | 237 | 9,551 |
sglang | test/registered/unit/managers/test_scheduler_pause_generation.py | .py | import unittest
from collections import deque
from types import SimpleNamespace
from typing import List, Optional
from unittest.mock import MagicMock, patch
import torch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglan... | 484 | 20,767 |
sglang | test/registered/unit/managers/test_customized_info_streaming.py | .py | from __future__ import annotations
import unittest
from typing import TYPE_CHECKING, List
import torch
from sglang.srt.entrypoints.engine import Engine
from sglang.srt.layers.sampler import Sampler, register_sampler_backend
from sglang.srt.managers.scheduler import run_scheduler_process
from sglang.test.ci.ci_regist... | 173 | 6,515 |
sglang | test/registered/unit/managers/test_batch_result_processor_mamba_boundary.py | .py | import unittest
from array import array
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import torch
from sglang.srt.managers.schedule_batch import Req, ScheduleBatch
from sglang.srt.managers.scheduler import Scheduler
from sglang.srt.managers.scheduler_components.batch_result_processor i... | 184 | 7,183 |
sglang | test/registered/unit/managers/test_data_parallel_controller.py | .py | """DPBudget + DataParallelController dispatch tests.
`total_tokens` (the most complex algorithm) is exercised end-to-end in
test/registered/disaggregation/test_disaggregation_dp_attention.py; its
tie-break on `total_requests` transitively covers that state.
Fragility: scheduler tests bypass `DataParallelController.__... | 284 | 10,708 |
sglang | test/registered/unit/managers/test_prefill_adder.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import sglang.srt.managers.schedule_policy as schedule_policy
from sglang.srt.managers.schedule_batch import Req
from sglang.srt.managers.schedule_policy import (
AddReqResult,
PrefillAdder,
estimate_prefill_extend... | 896 | 37,691 |
sglang | test/registered/unit/managers/test_tokenizer_manager_rid_cleanup.py | .py | """
Unit tests for rid_to_state cleanup in TokenizerManager.
Verifies that request IDs are properly removed from rid_to_state after
completion or abort, allowing resubmission with the same rid without
triggering "Duplicate request ID detected" errors.
Covers:
- _handle_abort_req cleans up rid_to_state
- _handle_b... | 610 | 20,635 |
sglang | test/registered/unit/managers/test_finish_length_speculative.py | .py | """Regression for stop/EOS vs max_new_tokens ordering under speculative decoding
(multi-token commits): a stop token (or stop string) committed mid-run must
finish the request and trim at the stop even when the same run crosses
max_new_tokens. The old length-first ordering finished such steps as
FINISH_LENGTH with fini... | 203 | 9,116 |
sglang | test/registered/unit/managers/test_pp_cp_rank_offsets.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.distributed.parallel_state_wrapper import ParallelState # noqa: E402
from sglang.s... | 127 | 3,910 |
sglang | test/registered/unit/managers/test_lora_update_result_merge.py | .py | # Copyright 2023-2024 SGLang Team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 79 | 3,287 |
sglang | test/registered/unit/managers/test_embed_overrides.py | .py | """Unit tests for token embedding override support.
Covers:
- PositionalEmbeds dataclass (embed_types.py)
- convert_embeds_to_tensors (utils.py)
- TokenizerManager._resolve_embed_overrides (tokenizer_manager.py)
- positional_embed_overrides on GenerateReqInput/EmbeddingReqInput (io_struct.py)
- Score mixin override re... | 603 | 22,772 |
sglang | test/registered/unit/managers/test_scheduler_flush_cache.py | .py | import unittest
from unittest.mock import MagicMock, patch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.managers.io_struct import FlushCacheReqInput
from sglang.srt.managers.scheduler import Scheduler
from sgla... | 128 | 4,763 |
sglang | test/registered/unit/managers/test_mm_process_config.py | .py | import os
import threading
import unittest
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import torch
from sglang.srt.environ import envs
from sglang.srt.server_args import ServerArgs
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCas... | 806 | 31,467 |
sglang | test/registered/unit/managers/test_hidden_state_server_mode.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import Mock
from sglang.srt.managers.io_struct import GenerateReqInput
from sglang.srt.managers.tokenizer_manager import TokenizerManager
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
regist... | 73 | 2,309 |
sglang | test/registered/unit/managers/test_trim_matched_stop.py | .py | """Unit test for DetokenizerManager.trim_matched_stop.
Under speculative decoding the output handed to trim_matched_stop may carry
content after the matched stop. With no_stop_trim the stop string must be kept
but the trailing over-generation still dropped (`output[:end]`); without it the
stop is removed (`output[:pos... | 69 | 2,573 |
sglang | test/registered/unit/managers/test_load_snapshot_backends.py | .py | """Unit tests for LoadSnapshot SHM and ZMQ backends."""
import os
import tempfile
import time
import unittest
from types import SimpleNamespace
from sglang.srt.managers.load_snapshot import (
LoadSnapshot,
ShmLoadSnapshotReader,
ShmLoadSnapshotWriter,
ZmqLoadSnapshotWriter,
ZmqShmLoadSnapshotReade... | 435 | 15,103 |
sglang | test/registered/unit/managers/test_scheduler_init_req_max_new_tokens.py | .py | import logging
import unittest
from types import SimpleNamespace
from sglang.srt.environ import envs
from sglang.srt.managers.scheduler import Scheduler
from sglang.srt.runtime_context import get_parallel
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=1, suite="base-a-test-cpu")
cla... | 186 | 8,280 |
sglang | test/registered/unit/managers/test_prefill_delayer_high_watermark.py | .py | import unittest
from unittest.mock import MagicMock
from sglang.srt.managers.prefill_delayer import (
PrefillDelayerSinglePassExecutor,
RecentPrefillBatchSizeTracker,
_NegotiateOutput,
)
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_c... | 144 | 5,788 |
sglang | test/registered/unit/managers/test_kv_page_invariants.py | .py | """Unit tests for SGLANG_CHECK_KV_PAGE_INVARIANTS: watermark + double-free checks."""
import unittest
from types import SimpleNamespace
import torch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
_PAGE_SI... | 108 | 3,958 |
sglang | test/registered/unit/managers/test_scheduler_hicache_attach.py | .py | """Runtime HiCache attach/detach lands on the config bags.
The attach RPC used to mutate the scheduler's ServerArgs so the readback would
show the change; the namespace readers never saw it. Both now go through
get_context().override, so get_memory() and the resolved-config readback agree
and the published instance st... | 77 | 2,907 |
sglang | test/registered/unit/managers/test_priority_scheduling_disaggregation.py | .py | import json
import sys
import threading
import unittest
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import numpy as np
import torch
from sglang.srt.disaggregation.decode import ( # noqa: E402
DecodePreallocQueue,
SchedulerDisaggregationDecodeMixin,
)
from sglang.srt.disaggreg... | 467 | 19,181 |
sglang | test/registered/unit/managers/test_hisparse_unit.py | .py | """Unit tests for HiSparse hierarchical sparse KV cache system.
Tests cover:
- CUDA kernel correctness (swap_in_selected_pages vs naive_load_topk oracle)
- Memory allocator lifecycle (alloc / free / available_size)
- Request lifecycle (staging path, direct-to-host path)
- Batch multi-request correctness
"""
import os... | 854 | 36,670 |
sglang | test/registered/unit/managers/test_scheduler_timeouts.py | .py | """Boundary tests for the scheduler's waiting / running request timeouts.
Both paths are pure bookkeeping over timestamps -- no model, no GPU, no draft
worker -- so they are driven here directly instead of through a server. The
e2e side (503 reaching the client, server stays up) is covered by
scheduler/test_scheduler_... | 122 | 4,380 |
sglang | test/registered/unit/managers/test_output_streamer_customized_info.py | .py | import unittest
from types import SimpleNamespace
from sglang.srt.disaggregation.utils import DisaggregationMode
from sglang.srt.managers.io_struct import unwrap_from_pickle
from sglang.srt.managers.scheduler_components.output_streamer import (
_GenerationStreamAccumulator,
)
from sglang.srt.speculative.spec_info ... | 96 | 3,189 |
sglang | test/registered/unit/managers/test_batch_result_processor_hidden_states.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import Mock, patch
import torch
from sglang.srt.managers.scheduler_components.batch_result_processor import (
SchedulerBatchResultProcessor,
)
from sglang.srt.model_executor.forward_batch_info import CaptureHiddenMode
from sglang.test.ci.ci_regi... | 226 | 7,946 |
sglang | test/registered/unit/managers/test_msgpack_ipc_roundtrip.py | .py | """Round-trip coverage for the IPC structs that used to be pickle-wrapped.
Issue #29465 Task 4 tightened the 13 types in `_REQ_TYPES_WITH_OPAQUE_FIELDS` to
precise msgspec-native annotations and deleted the registry. This test proves
each type now encodes natively over the msgpack IPC path (no `PickleWrapper`
frame) b... | 242 | 9,885 |
sglang | test/registered/unit/managers/scheduler_components/test_output_sender.py | .py | import asyncio
import unittest
from unittest.mock import MagicMock, patch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase, maybe_stub_sgl_kernel
maybe_stub_sgl_kernel()
from sglang.srt.managers.io_struct import AbortReq
from sglang.srt.managers.multi_tokenizer... | 64 | 2,263 |
sglang | test/registered/unit/cli/test_serve_backends.py | .py | # SPDX-License-Identifier: Apache-2.0
import unittest
from unittest.mock import MagicMock, patch
from sglang.cli.serve import serve
from sglang.cli.serve_backends import (
SERVE_BACKEND_API_VERSION,
RegisteredServeBackend,
ServeBackend,
ServeBackendDetection,
ServeBackendRegistry,
ServeRequest... | 250 | 9,609 |
sglang | test/registered/unit/batch_overlap/test_tbo_cuda_graph_num_token_device.py | .py | """Regression: the TBO cuda-graph plugin must allocate its children
``num_token_non_padded`` buffer on the model device, not CPU.
``ForwardBatch.num_token_non_padded`` is a scalar tensor on the model device
(see ``ForwardBatch.compute``, which does ``.to(device, ...)``). The eager TBO
split path already honors this --... | 77 | 3,246 |
sglang | test/registered/unit/batch_overlap/test_tbo_filter_batch_marker.py | .py | """Regression: TBO filter_batch resets the attention plan marker on children.
filter_batch's completeness guard raises for any non-None ForwardBatch field
missing from the child dict; the plan marker defaults to False (non-None) and
crashed TBO cuda-graph capture until reset. CPU-only.
"""
import unittest
import tor... | 152 | 6,135 |
sglang | test/registered/unit/multimodal/test_preprocess_cache.py | .py | import asyncio
import base64
import os
import tempfile
import unittest
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch
import numpy as np
import torch
from PIL import Image
from sglang.srt.multimodal.cache import (
MultimodalPreprocessCache,
build_artifact_key,
b... | 403 | 15,032 |
sglang | test/registered/unit/multimodal/test_audio_container_decode.py | .py | """Regression tests for explicit ``input_audio`` media containers."""
import asyncio
import base64
import concurrent.futures
import io
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch
import av
import numpy as np
import soundfile
from sglang.srt.managers.schedule_batch import ... | 272 | 10,092 |
sglang | test/registered/unit/multimodal/test_media_url_security.py | .py | """Security tests for client-supplied remote multimodal media URLs."""
import http.server
import threading
import unittest
from unittest.mock import patch
import requests
from sglang.srt.utils.common import (
_normalize_video_input,
configure_media_url_security,
download_remote_media,
get_image_bytes... | 184 | 6,647 |
sglang | test/registered/unit/multimodal/test_mrope_encoder_utils.py | .py | """CPU coverage for mRoPE DP vision-encoder helpers."""
import unittest
from types import SimpleNamespace
import torch
from sglang.srt.multimodal.mm_utils import (
_pad_mrope_vision_embeddings_for_tp_gather,
run_dp_sharded_mrope_vision_model,
)
from sglang.srt.runtime_context import get_parallel
from sglang.... | 93 | 3,050 |
sglang | test/registered/unit/multimodal/test_evs.py | .py | from dataclasses import asdict, dataclass
from types import SimpleNamespace
import pytest
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import run_doctests
register_cpu_ci(est_time=8, suite="base-a-test-cpu")
def test_resolve_evs_config():
from sglang.srt.multimodal.evs imp... | 60 | 1,779 |
sglang | test/registered/unit/multimodal/test_base_processor_image_decode.py | .py | """Unit tests for ``BaseMultimodalProcessor._load_single_item`` image decoding.
Regression test for the change that forces the (otherwise lazy) PIL decode inside
``_load_single_item`` — which runs in the ``io_executor`` worker thread — instead of
letting it fire lazily on the main event-loop thread later (inside
``pil... | 225 | 8,868 |
sglang | test/registered/unit/multimodal/test_vit_cuda_graph_runner.py | .py | import sys
from types import SimpleNamespace
from unittest.mock import patch
import pytest
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=3, suite="base-a-test-cpu")
from sglang.srt.multimodal.internvl_vit_cuda_graph_runner import (
InternViTCudaGraphRunner,
)
from sglang.srt.mu... | 94 | 2,436 |
sglang | test/registered/unit/multimodal/test_cuda_ipc_pool_budget.py | .py | """CPU-only regression tests for CUDA IPC multimodal pool budgeting."""
import unittest
from sglang.srt.multimodal.transport.cuda_ipc import (
get_mm_feature_pool_size_per_worker,
)
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=10, suite="base-a-test-cpu")
class TestCudaIpcPoo... | 36 | 1,245 |
sglang | test/registered/unit/multimodal/test_cuda_vmm_transport.py | .py | """CUDA VMM multimodal feature transport regression tests."""
from __future__ import annotations
import gc
import multiprocessing as mp
import os
import pickle
import queue
import threading
import unittest
from unittest.mock import MagicMock, patch
import torch
from sglang.srt.runtime_context import get_parallel
fr... | 491 | 18,280 |
sglang | test/registered/unit/multimodal/test_base_processor_bad_input.py | .py | """Unit tests for bad-input classification in ``BaseMultimodalProcessor._load_single_item``.
Media the client supplied but that cannot be fetched or decoded must raise
``ValueError``; anything else must stay a ``RuntimeError``.
"""
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=10, s... | 109 | 4,157 |
sglang | test/registered/unit/multimodal/test_kimi_k3_gpu_preprocess.py | .py | """K3 GPU preprocess: shared batched pipeline hook contract (CPU parts)."""
import sys
import numpy as np
import pytest
import torch
from PIL import Image
from sglang.srt.multimodal.processors.kimi_k3 import _fill_transparent_bg
from sglang.srt.multimodal.processors.kimi_k25 import _resize_bicubic_if_needed
from sgl... | 115 | 4,392 |
sglang | test/registered/unit/multimodal/test_processor_device_selection.py | .py | """The fast-image-processor device comes from the processor's own ServerArgs.
Regression: the device decision read the published global ServerArgs, which is
last-publish-wins. Two engines in one tokenizer process then shared whichever
config published last, so one engine's images were preprocessed on the other
engine'... | 82 | 2,944 |
sglang | test/registered/unit/multimodal/test_feature_materialization.py | .py | """Tests for the shared multimodal feature materialization helper."""
import unittest
import torch
from sglang.srt.multimodal.mm_utils import materialize_multimodal_features
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=5, suite="ba... | 40 | 1,321 |
sglang | test/registered/unit/multimodal/test_cuda_ipc_transport.py | .py | """CUDA IPC multimodal feature transport regression tests.
This covers the production path where a tokenizer worker places a feature in
the bounded pool and the scheduler process opens the shared CUDA allocation.
CPU-only policy tests intentionally cannot exercise this cross-process handle.
"""
import gc
import multi... | 143 | 5,231 |
sglang | test/registered/unit/multimodal/test_gpu_feature_transport.py | .py | import unittest
from contextlib import nullcontext
from types import SimpleNamespace
from unittest.mock import MagicMock, call, patch
import torch
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=10, suite="base-a-test-cpu")
class TestCudaVmmFeatureTransport(unittest.TestCase):
d... | 646 | 24,474 |
sglang | test/registered/unit/multimodal/rust/_mm_rust_utils.py | .py | """Shared fixtures for the native Rust multimodal suites.
Imported via ``sys.path`` from the sibling suites (unittest runs these files by
path, so a package-relative import would break ``python <file>``); the module
name is deliberately specific so it cannot shadow another suite's helpers on the
process-global ``sys.p... | 100 | 2,600 |
sglang | test/registered/unit/multimodal/rust/qwen/test_token_layout_mrope.py | .py | """Qwen placeholder expansion, offsets, and M-RoPE parity.
Covers ``layout_by_placeholder`` / ``apply_layout`` in
``rust/sglang-mm/src/common/token_layout.rs`` and ``mrope_image_only`` in
``rust/sglang-mm/src/qwen_vl/mod.rs`` (via the
``_core.qwen_vl.process_native_mm`` and ``mrope_image_only_py``
bindings), against `... | 105 | 4,020 |
sglang | test/registered/unit/multimodal/rust/qwen/_fixtures.py | .py | from types import SimpleNamespace
import numpy as np
from tokenizers import Tokenizer, decoders
from tokenizers.models import WordLevel
from tokenizers.pre_tokenizers import WhitespaceSplit
from transformers import (
PreTrainedTokenizerFast,
Qwen2VLProcessor,
Qwen2VLVideoProcessor,
)
from transformers.mode... | 105 | 3,540 |
sglang | test/registered/unit/multimodal/rust/qwen/test_driver.py | .py | """Native driver error paths: out-of-scope and malformed inputs are rejected.
Covers ``process`` in ``rust/sglang-mm/src/driver.rs`` (via the
``_core.qwen_vl.process_native_mm`` binding). The wire-payload parsing that
feeds this driver (modality/shape rejection) lives in ``sglang-server``'s
message layer and is tested... | 110 | 4,111 |
sglang | test/registered/unit/multimodal/rust/qwen/test_preprocess.py | .py | """Qwen native image preprocessing parity against Transformers.
Covers ``QwenVlProcessor::process_item`` and ``smart_resize`` in
``rust/sglang-mm/src/qwen_vl/mod.rs`` (via the ``_core.qwen_vl.preprocess``
and ``smart_resize_py`` bindings), against the HF Qwen2-VL image processors
and the Python ``smart_resize``.
Both... | 96 | 3,620 |
sglang | test/registered/unit/multimodal/rust/qwen/test_e2e_parity.py | .py | """End-to-end parity at the scheduler-input boundary.
`test_preprocess.py` pins the `preprocess` binding; this drives the whole native
path — the `process_native_mm` driver, then `NativeMmHost.build_native_mm` — and
compares every field the scheduler reads against the Python `mm_processor`.
Bitwise, for both HF backen... | 163 | 6,444 |
sglang | test/registered/unit/multimodal/rust/qwen/test_native_mm_host.py | .py | """The mm-item hash contract of the native Qwen path.
The two paths hash different things, deliberately. Native hashes are `content_hash`
over the raw encoded source bytes, computed on an MM worker; the Python path hashes
the decoded feature tensor. Both feed `set_pad_value`, so the native drain can skip
`hash_feature... | 106 | 4,302 |
sglang | test/registered/unit/multimodal/rust/shared/test_fetch.py | .py | """Model-independent parity tests for Rust multimodal source loading.
Covers ``fetch_bytes`` in ``rust/sglang-mm/src/common/fetch.rs`` (via the
``_core.common.fetch_bytes`` binding), against the Python reference
``sglang.srt.utils.common.get_image_bytes``.
"""
import base64
import http.server
import sys
import tempfi... | 84 | 3,016 |
sglang | test/registered/unit/multimodal/rust/shared/test_native_mm_gate.py | .py | """The native-MM launch gate's family selection (managers/rust_server.py).
``NATIVE_MM_FAMILIES`` decides which models the Rust pipeline serves natively;
for everything else ``native_mm_family_for`` must return ``None``, which
``RustServer.launch`` turns into a hard launch error. Pins that non-Qwen
multimodal models —... | 62 | 2,509 |
sglang | test/registered/unit/multimodal/rust/shared/test_image_decode.py | .py | """Model-independent image decode parity for native Rust MM.
Covers ``decode_rgb`` in ``rust/sglang-mm/src/common/mod.rs`` (via the
``_core.common.image_decode_rgb`` binding), against PIL's
``Image.open(...).convert("RGB")``.
"""
import io
import sys
import unittest
from pathlib import Path
import numpy as np
from P... | 103 | 3,880 |
sglang | test/registered/unit/multimodal/rust/shared/test_build_native_mm.py | .py | """``NativeMmHost.build_native_mm`` (managers/rust_server.py): the drain-time
wrapping contracts — tensors are zero-copy views over the Rust-owned buffers, and
pad values come from worker-precomputed hashes, since the scheduler loop must
never hash features. Synthetic buffers, so this needs no Rust extension."""
impor... | 167 | 6,070 |
sglang | test/registered/unit/multimodal/rust/shared/test_partition_cores.py | .py | """``RustServer._partition_cores`` (managers/rust_server.py): the pool cores must
be a *bounded* slice of this rank's allowed cores, not the whole remainder —
sibling TP ranks share the NUMA node, so an unbounded mask lets MM preprocessing
bursts preempt a sibling's CUDA-launch thread (measured: ~20 ms of ViT wall time... | 55 | 2,271 |
sglang | test/registered/unit/multimodal/rust/inkling/test_bindings.py | .py | """Smoke coverage for the ``_core.inkling`` PyO3 bindings.
Covers the ``#[pyfunction]``s in ``rust/sglang-mm/src/inkling/mod.rs``
(``patchify_rgb`` / ``decode_patchify`` / ``decode_patchify_batch`` /
``preprocess_images`` / ``rescale_patchify_hash``) plus
``_core.common.content_hash``.
The inkling bindings are otherw... | 75 | 2,922 |
sglang | test/registered/unit/npu/attention/test_npu_ascend_backend.py | .py | """
Unit tests for sglang.srt.hardware_backend.npu.attention.ascend_backend.
"""
import sys
import unittest
from dataclasses import fields, is_dataclass
from types import SimpleNamespace
from unittest.mock import MagicMock
import torch
from sglang.test.ci.ci_register import register_npu_ci
register_npu_ci(est_time=... | 766 | 28,249 |
sglang | test/registered/unit/npu/attention/test_npu_ascend_torch_native_backend.py | .py | """
Unit tests for sglang.srt.hardware_backend.npu.attention.ascend_torch_native_backend.
"""
import math
import unittest
import torch
from torch.nn.functional import scaled_dot_product_attention
from sglang.srt.hardware_backend.npu.attention.ascend_torch_native_backend import (
AscendTorchNativeAttnBackend,
)
f... | 832 | 27,644 |
sglang | test/registered/unit/npu/attention/test_npu_ascend_dsv4_backend.py | .py | """
Unit tests for sglang.srt.hardware_backend.npu.attention.ascend_dsv4_backend.
"""
import math
import sys
import unittest
from types import ModuleType, SimpleNamespace
from unittest.mock import MagicMock, patch
import torch
from sglang.test.ci.ci_register import register_npu_ci
register_npu_ci(est_time=4, suite=... | 461 | 19,283 |
sglang | test/registered/unit/npu/attention/test_npu_mla_preprocess.py | .py | """
Unit tests for sglang.srt.hardware_backend.npu.attention.mla_preprocess.
"""
import os
import unittest
from unittest.mock import patch
import torch
from sglang.test.ci.ci_register import register_npu_ci
register_npu_ci(est_time=4, suite="stage-a-unit-test-npu")
from sglang.srt.hardware_backend.npu.attention.ml... | 208 | 7,442 |
sglang | test/registered/unit/models/test_kimi_k3_vision.py | .py | from contextlib import nullcontext
from types import SimpleNamespace
import pytest
import torch
import torch.nn.functional as F
from sglang.srt.layers.attention.vision import (
prepare_flashinfer_cudnn_vision_attention_metadata,
)
from sglang.srt.models import kimi_k3_vl
from sglang.srt.models.kimi_k3_vl import (... | 604 | 20,381 |
sglang | test/registered/unit/models/test_qwen3_vl_feature_materialization.py | .py | """Regression tests for Qwen3-VL multimodal feature materialization."""
import unittest
from types import SimpleNamespace
from unittest.mock import Mock, patch
import torch
from sglang.srt.managers.schedule_batch import Modality, MultimodalDataItem
from sglang.srt.models.qwen3_vl import Qwen3VLForConditionalGenerati... | 185 | 7,169 |
sglang | test/registered/unit/models/test_shared_experts_fusion_gates.py | .py | """Every MoE family's fusion gate, asked the way the loader asks it.
`install_shared_experts_fusion_decision` calls
`<model class>.shared_experts_fusion_disable_reason(hf_config, quant_config)`
before the model is built, so the gate must answer from the config and
quantization it is handed — no instance, no layers. Th... | 515 | 19,992 |
sglang | test/registered/unit/models/test_draft_entry_hook_parity.py | .py | """A draft entry class answers the loader's questions exactly when its target does.
The loader asks the *entry class* it instantiates for the shared-experts-fusion
decision (`install_shared_experts_fusion_decision`). A draft is its own entry
class -- `...NextN`, `...MTP`, `...DSpark`, `...Eagle3` -- so when the target... | 96 | 4,159 |
sglang | test/registered/unit/models/test_kimi_vl.py | .py | """CPU-only coverage for Kimi-VL encoder parallelism wiring."""
from types import SimpleNamespace
from unittest.mock import patch
import pytest
import torch
import torch.nn as nn
from sglang.srt.layers.linear import (
ColumnParallelLinear,
QKVParallelLinear,
RowParallelLinear,
)
from sglang.srt.managers.... | 147 | 5,068 |
sglang | test/registered/unit/models/test_zaya_mod_tp.py | .py | """Numerical correctness test for ZAYA1 MoE + MOD under TP>1.
Background: the MOD (mixture-of-depths) skip-expert residual blend must be
combined with the experts output on the correct side of the cross-rank
all-reduce. ``mod_out = hidden_states * prob`` is replicated on every TP rank,
so all-reducing it would multipl... | 179 | 7,320 |
sglang | test/registered/unit/models/test_fusion_gate_coverage.py | .py | """Every loader entry class that can reach a fusion-gated family answers for it.
The loader installs the shared-experts-fusion decision for the class it
instantiates (`install_shared_experts_fusion_decision`). A model whose layers
read `is_shared_experts_fusion_disabled()` therefore gets whatever answer that
*entry* c... | 182 | 7,343 |
sglang | test/registered/unit/models/test_moss_vl_processor.py | .py | import re
from types import SimpleNamespace
import pytest
import torch
from sglang.srt.multimodal.processors.moss_vl import MossVLImageProcessor
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=1, suite="base-a-test-cpu")
def _vision_info(frame_count: int):
return [
{
... | 86 | 2,447 |
sglang | test/registered/unit/models/test_hunyuan_v3_nextn_weight_loading.py | .py | """
Unit tests for HYV3ForCausalLMNextN.load_weights.
Regression test for the released Hy3 MTP checkpoint key
``model.layers.<num_hidden_layers>.final_layernorm.weight``, which must load
into the draft head's output norm (``model.shared_head.norm``) instead of
being remapped to a nonexistent decoder parameter and sile... | 94 | 3,151 |
sglang | test/registered/unit/models/test_llava.py | .py | import unittest
from unittest.mock import patch
from sglang.srt.models.llava import AutoModel, LlavaForConditionalGeneration
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=8, suite="base-a-test-cpu")
class PixtralVisionConfig:
pa... | 92 | 2,658 |
sglang | test/registered/unit/models/test_qwen3_5_modelopt_fp4.py | .py | """Unit tests for modelopt_fp4 checkpoints that quantize Qwen3.5 attention.
Covers three things:
1. ModelOptFp4Config.is_layer_excluded() decides per prefix whether attention is
quantized or kept in BF16.
2. RadixAttention registers k_scale/v_scale when built with a quant_config that
declares kv_cache_qu... | 158 | 6,153 |
sglang | test/registered/unit/models/test_kimi_k3_bfa_overlap.py | .py | """KDA bfa side-stream overlap: forward_qkvbfg_fused must produce outputs
bit-identical to the serial path, both eager and under CUDA graph
capture/replay (the overlap only engages in capture mode)."""
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.srt.mode... | 103 | 3,532 |
sglang | test/registered/unit/models/test_kimi_vl_moonvit.py | .py | import pytest
import torch
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=3, suite="base-a-test-cpu")
from sglang.srt.models import kimi_vl_moonvit
from sglang.srt.models.kimi_vl_moonvit import Learnable2DInterpPosEmb
def test_learnable_2d_pos_emb_caches_inference_interpolation(mon... | 65 | 2,118 |
sglang | test/registered/unit/models/test_qwen3_5_packed_weight_loader.py | .py | """
Unit tests for Qwen3_5GatedDeltaNet._make_packed_weight_loader.
Validates that per-tensor FP8 scales (scalar or single-element tensors)
are broadcast to every logical shard, while normal multi-element weights
are split correctly.
Regression test for https://github.com/sgl-project/sglang/issues/23051
"""
from sgl... | 217 | 7,694 |
sglang | test/registered/unit/models/test_kimi_k25.py | .py | """CPU coverage for Kimi-K2.5/K2.7 encoder-DP wiring."""
import asyncio
import functools
from types import SimpleNamespace
from unittest.mock import AsyncMock, Mock, patch
import numpy as np
import pytest
import torch
import torch.nn as nn
import torch.nn.functional as F
from PIL import Image
from sglang.srt.manager... | 919 | 31,943 |
sglang | test/registered/unit/models/test_qwen3_5_pipeline_parallel.py | .py | import unittest
from types import SimpleNamespace
from sglang.srt.layers.utils import PPMissingLayer
from sglang.srt.models.qwen3_5 import Qwen3_5MoeForConditionalGeneration
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=2, suite="base... | 70 | 2,126 |
sglang | test/registered/unit/models/test_deepseek_v4_shared_expert_fusion.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from torch import nn
from sglang.srt.configs.deepseek_v4 import DeepSeekV4Config
from sglang.srt.layers.moe.utils import (
install_shared_experts_fusion_decision,
is_shared_experts_fusion_disabled,
)
from sglang.srt... | 175 | 6,143 |
sglang | test/registered/unit/models/test_longcat_flash_router_hpc_gemm.py | .py | """Unit tests for LongCat-Flash router GEMM dispatch to the HPC-Ops bf16xfp32 kernel."""
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase, maybe_stub_sgl_kernel
mayb... | 117 | 3,718 |
sglang | test/registered/unit/models/test_mellum.py | .py | """Unit tests for the Mellum model implementation."""
import unittest
import torch
from sglang.srt.models.mellum import MellumForCausalLM
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
class TestMellumFo... | 34 | 1,021 |
sglang | test/registered/unit/models/test_deepseek_v4_fused_mhc_policy.py | .py | """Unit tests for the DeepSeek-V4 fused-MHC enable policy."""
import unittest
from unittest.mock import patch
import sglang.srt.models.deepseek_v4 as deepseek_v4
from sglang.srt.environ import envs
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_c... | 80 | 2,247 |
sglang | test/registered/unit/models/test_kimi_k25_mm_projection.py | .py | """CPU coverage for the Kimi vision-projector packing fast path."""
import pytest
import torch
import torch.nn as nn
from sglang.srt.models.kimi_k25 import mm_projection_auto
from sglang.test.ci.ci_register import register_cpu_ci
register_cpu_ci(est_time=3, suite="base-a-test-cpu")
class _FlattenProjector(nn.Modul... | 42 | 1,265 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.