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 | python/sglang/multimodal_gen/test/unit/test_openai_image_api.py | .py | import os
from fastapi import HTTPException
from PIL import Image
from sglang.multimodal_gen.configs.sample.glmimage import GlmImageSamplingParams
from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams
from sglang.multimodal_gen.runtime.entrypoints.openai.image_api import (
_build_image_r... | 176 | 5,669 |
sglang | python/sglang/multimodal_gen/test/unit/test_ernie_rope_geglu_fusion.py | .py | import unittest
import torch
import torch.nn.functional as F
from sglang.multimodal_gen.runtime.models.dits.ernie_image import (
_ernie_geglu,
_ernie_rope,
_precompute_rope_cos_sin,
)
def _reference_rotary_bshd(x: torch.Tensor, freqs: torch.Tensor) -> torch.Tensor:
"""The pre-fusion eager chain (per... | 85 | 3,068 |
sglang | python/sglang/multimodal_gen/test/unit/test_usp_ring_replicated.py | .py | """Replicated-token paths under ring parallelism: dispatch, merge, KV order."""
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.attention.layer import USPAttention
from sglang.multimodal_gen.runtime.layers.usp import _merge_atte... | 192 | 7,126 |
sglang | python/sglang/multimodal_gen/test/unit/test_suite_partitioning.py | .py | """Shard assignment invariants for the diffusion suites.
Lanes that hardcode ``--total-partitions`` (AMD) must still schedule the whole
suite when standalone files outnumber the shards, and the shards must agree on
who runs what without talking to each other.
"""
from types import SimpleNamespace
import pytest
from... | 111 | 3,972 |
sglang | python/sglang/multimodal_gen/test/unit/test_qvg_packed_kv.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Unit tests for Quant-VideoGen packed KV-cache (QVGPackedCausalKVCache).
- config parsing + defaults: CPU, no deps.
- packed-storage equivalence vs the dense cache (quant disabled -> bf16
segments): CPU-only, exercises the segment / sliding-window / eviction /
reconstruction... | 238 | 8,302 |
sglang | python/sglang/multimodal_gen/test/unit/test_helios_denoising_profiler.py | .py | import unittest
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.helios_denoising import (
HeliosChunkedDenoisingStage,
)
class _Transformer:
def __call__(self, **kwargs):
return torch.zeros_like(kwargs["hidden_states"])
cl... | 68 | 2,087 |
sglang | python/sglang/multimodal_gen/test/unit/test_attention_backend_selector.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.attention.backends.attention_backend import (
AttentionRequirements,
)
from sglang.multimodal_gen.runtime.layers.attention.selector import (
_cached_get_attn_backend,
ge... | 189 | 6,296 |
sglang | python/sglang/multimodal_gen/test/unit/test_video_job_lifecycle.py | .py | import asyncio
from sglang.multimodal_gen.runtime.entrypoints.openai import video_api
def test_video_job_registry_holds_task_until_completion():
async def run_test():
started = asyncio.Event()
finish = asyncio.Event()
async def job():
started.set()
await finish.wa... | 48 | 1,249 |
sglang | python/sglang/multimodal_gen/test/unit/test_vae_fast_path_gate.py | .py | import torch.nn as nn
from sglang.multimodal_gen.runtime.models.vaes.fast_path_gate import (
VaeFastPathGate,
register_vae_fast_path_gate,
use_vae_fast_path,
)
def test_vae_fast_path_gate_is_decode_scoped_and_nestable():
vae = nn.Module()
gate = VaeFastPathGate()
register_vae_fast_path_gate(v... | 22 | 535 |
sglang | python/sglang/multimodal_gen/test/unit/test_usp_ring_tail_pad.py | .py | """Ring + tail-pad dispatch: a2a within Ulysses, ring clamped to pad_start."""
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.attention.layer import USPAttention
from sglang.multimodal_gen.runtime.platforms import AttentionBack... | 87 | 3,140 |
sglang | python/sglang/multimodal_gen/test/unit/test_ideogram_rope_swiglu_fusion.py | .py | import unittest
import torch
import torch.nn.functional as F
from sglang.multimodal_gen.runtime.layers.rotary_embedding import (
qwen3_apply_rotary_pos_emb,
)
from sglang.multimodal_gen.runtime.models.dits.ideogram import (
_ideogram_rope,
_ideogram_swiglu,
)
def _make_qk_cos_sin(batch, seq, heads, head... | 64 | 2,521 |
sglang | python/sglang/multimodal_gen/test/unit/test_cfg_policy.py | .py | import unittest
from unittest.mock import MagicMock
import torch
from sglang.multimodal_gen.runtime.distributed.cfg_policy import CFGPolicy
class TestCFGPolicyCombine(unittest.TestCase):
def test_cfg_parallel_uses_parallel_arithmetic_order(self):
policy = CFGPolicy()
req = MagicMock()
re... | 34 | 1,054 |
sglang | python/sglang/multimodal_gen/test/unit/test_multi_output_grouping.py | .py | import unittest
from types import SimpleNamespace
import torch
from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams
from sglang.multimodal_gen.runtime.entrypoints.utils import (
expand_request_outputs,
normalize_output_seeds,
)
from sglang.multimodal_gen.runtime.pipelines_core.sched... | 213 | 8,053 |
sglang | python/sglang/multimodal_gen/test/unit/test_minimax_h3_denoise_loop.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Numerical contract for request-static H3 denoise metadata."""
from unittest.mock import patch
import torch
from sglang.multimodal_gen.configs.models.dits.minimax_h3 import (
MINIMAX_H3_ADALN_MODALITY_NUM,
)
from sglang.multimodal_gen.runtime.models.schedulers.scheduling_m... | 196 | 7,734 |
sglang | python/sglang/multimodal_gen/test/unit/test_storage.py | .py | """
Test suite for S3 CloudStorage integration.
Tests verify file upload, cleanup, URL generation, and error handling.
"""
import asyncio
import importlib
import os
from types import SimpleNamespace
import pytest
import sglang.multimodal_gen.runtime.entrypoints.openai.storage as storage_mod
from sglang.multimodal_g... | 233 | 7,795 |
sglang | python/sglang/multimodal_gen/test/unit/test_hunyuan3d_native_texture_models.py | .py | # SPDX-License-Identifier: Apache-2.0
import unittest
from types import SimpleNamespace
import torch
from diffusers import AutoencoderKL as DiffusersAutoencoderKL
from diffusers import LCMScheduler, UNet2DConditionModel
from sglang.multimodal_gen.configs.models.vaes.stable_diffusion import (
StableDiffusionVAECo... | 228 | 7,949 |
sglang | python/sglang/multimodal_gen/test/unit/test_decoding_stage_parallelism.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
import torch.nn as nn
from sglang.multimodal_gen.runtime.pipelines_core.stages.base import (
StageParallelismType,
)
from sglang.multimodal_gen.runtime.pipelines_core.stages.decoding import DecodingStage
from sglang.mul... | 189 | 7,106 |
sglang | python/sglang/multimodal_gen/test/unit/test_minimax_h3_vae_parallel_modes.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax-H3 released VAE decode contract."""
from unittest import mock
import pytest
import torch
import torch.nn as nn
from sglang.multimodal_gen.configs.models.vaes.minimax_h3_video import (
MiniMaxH3VideoVAEConfig,
)
from sglang.multimodal_gen.runtime.models.vaes.minima... | 118 | 3,764 |
sglang | python/sglang/multimodal_gen/test/unit/test_component_residency.py | .py | from types import SimpleNamespace
from unittest.mock import Mock
import torch
from sglang.multimodal_gen.runtime.managers.memory_managers.component_manager import (
ComponentResidencyManager,
ComponentUse,
ResidencyState,
)
from sglang.multimodal_gen.runtime.managers.memory_managers.component_residency_st... | 399 | 13,647 |
sglang | python/sglang/multimodal_gen/test/unit/test_video_api_profiling.py | .py | from types import SimpleNamespace
from unittest.mock import patch
from sglang.multimodal_gen.runtime.entrypoints.openai.protocol import (
VideoGenerationsRequest,
)
from sglang.multimodal_gen.runtime.entrypoints.openai.video_api import (
_build_video_sampling_params,
)
def test_video_api_forwards_profiling_o... | 53 | 1,560 |
sglang | python/sglang/multimodal_gen/test/unit/test_qwen2_5vl_generation.py | .py | from types import SimpleNamespace
import torch
from torch import nn
import sglang.multimodal_gen.runtime.models.encoders.qwen2_5vl as qwen2_5vl
from sglang.multimodal_gen.configs.models.encoders.qwen_image import Qwen2_5VLConfig
from sglang.multimodal_gen.configs.pipeline_configs.longcat_image import (
LongCatIma... | 227 | 7,970 |
sglang | python/sglang/multimodal_gen/test/unit/test_minimax_h3_packed_sequence.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Numerical contracts for MiniMax-H3 packed-sequence layouts."""
import unittest
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.minimax_h3.packed_sequence import (
minimax_h3_packed_sequence,
minimax_h3_packed_sequence_ref2va_blocks,
)
c... | 157 | 5,846 |
sglang | python/sglang/multimodal_gen/test/unit/test_cosmos3.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Unit tests for Cosmos3 config, weight mapping, and sampling params."""
import importlib.util
import json
import types
import unittest
from unittest import mock
import torch
from sglang.multimodal_gen.configs.models.dits.cosmos3video import (
_build_cosmos3_param_names_map... | 1,201 | 47,378 |
sglang | python/sglang/multimodal_gen/test/unit/test_ltx2_vae_channels_last.py | .py | import unittest
import torch
from sglang.multimodal_gen.runtime.models.vaes.ltx_2_vae import LTX2VideoCausalConv3d
@unittest.skipUnless(
hasattr(torch, "channels_last_3d"), "channels_last_3d is unavailable"
)
class TestLTX2CausalConvChannelsLast(unittest.TestCase):
"""The channels_last_3d causal-conv path m... | 94 | 4,090 |
sglang | python/sglang/multimodal_gen/test/unit/test_disagg_trace.py | .py | """Unit tests for OTel trace-context propagation across the diffusion disagg
JSON hop (encoder -> denoiser, denoiser -> decoder).
These exercise the serialization contract only (no GPUs, no server, no OTLP
collector required):
- ``extract_transfer_fields`` emits a JSON-safe ``_trace_state`` (W3C carrier)
when tra... | 233 | 9,673 |
sglang | python/sglang/multimodal_gen/test/unit/test_lora_pipeline.py | .py | from collections import defaultdict
from contextlib import contextmanager, nullcontext
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.lora.linear import BaseLayerWithLoRA
from sglang.multimodal_gen.runtime.pipelines_core.lora_pipeline import Lo... | 162 | 4,929 |
sglang | python/sglang/multimodal_gen/test/unit/test_krea2_fp8.py | .py | import torch
from sglang.multimodal_gen.configs.models.dits.krea2 import Krea2DitConfig
from sglang.multimodal_gen.runtime.distributed.parallel_state import (
maybe_init_distributed_environment_and_model_parallel,
model_parallel_is_initialized,
)
from sglang.multimodal_gen.runtime.layers.linear import Unquanti... | 65 | 2,391 |
sglang | python/sglang/multimodal_gen/test/unit/test_cache_dit_integration.py | .py | import importlib
import importlib.util
import sys
import types
import unittest
from pathlib import Path
from unittest.mock import patch
class _FakeDBCacheConfig:
def __init__(self, **kwargs):
self.kwargs = kwargs
def reset(self, **kwargs):
return kwargs
class _FakeForwardPattern:
# A cl... | 329 | 11,189 |
sglang | python/sglang/multimodal_gen/test/unit/test_usp_ipc_a2a_guard.py | .py | # SPDX-License-Identifier: Apache-2.0
"""`_ipc_input_a2a_qkv` must decline cross-attention shapes.
It sizes one staging slot from `q` and reuses it for q, k and v, which only
holds when all three share a sequence length. Cross-attention with unequal
query and key/value lengths -- LTX-2's video-to-audio blocks, say -- ... | 55 | 2,140 |
sglang | python/sglang/multimodal_gen/test/unit/test_lingbot_video_moe.py | .py | # SPDX-License-Identifier: Apache-2.0
import json
import os
import tempfile
from types import SimpleNamespace
import torch
from sglang.multimodal_gen.configs.models.dits.lingbot_video_moe import (
LingBotVideoMoEArchConfig,
)
from sglang.multimodal_gen.configs.pipeline_configs.lingbot_video_moe import (
Ling... | 368 | 12,994 |
sglang | python/sglang/multimodal_gen/test/unit/test_component_loading_order.py | .py | import json
from sglang.multimodal_gen.runtime.managers.memory_managers.component_loading_order import (
ComponentLoadSpec,
component_load_risk_rank,
infer_component_weight_size_bytes,
order_component_load_specs,
)
def _spec(
component_name: str, index: int, component_model_path: str = "/missing"... | 131 | 3,980 |
sglang | python/sglang/multimodal_gen/test/unit/test_spectrum.py | .py | # SPDX-License-Identifier: Apache-2.0
import unittest
import torch
from sglang.multimodal_gen.runtime.cache.spectrum import (
ChebyshevForecaster,
SpectrumForecaster,
)
class TestSpectrumForecaster(unittest.TestCase):
def test_chebyshev_fit_and_predict(self) -> None:
"""Predict returns the expec... | 93 | 3,865 |
sglang | python/sglang/multimodal_gen/test/unit/test_turbo_wan_backend.py | .py | import unittest
from sglang.multimodal_gen.runtime.layers.attention.turbo_layer import (
_resolve_turbo_wan_sparse_backend,
)
from sglang.multimodal_gen.runtime.platforms.interface import AttentionBackendEnum
class TestTurboWanBackendSelection(unittest.TestCase):
def test_non_sparse_requested_backend_falls_b... | 62 | 2,247 |
sglang | python/sglang/multimodal_gen/test/unit/test_pi05_action_api.py | .py | # SPDX-License-Identifier: Apache-2.0
import dataclasses
from types import SimpleNamespace
import numpy as np
from sglang.multimodal_gen.configs.pipeline_configs.pi05 import Pi05PipelineConfig
from sglang.multimodal_gen.configs.sample.action import ActionSamplingParams
from sglang.multimodal_gen.configs.sample.pi05 ... | 247 | 8,443 |
sglang | python/sglang/multimodal_gen/test/unit/test_ltx2_modulate_mount.py | .py | import unittest
import torch
from sglang.multimodal_gen.runtime.models.dits.ltx_2 import _ltx2_modulate
class TestLtx2ModulateMount(unittest.TestCase):
@unittest.skipUnless(torch.cuda.is_available(), "requires CUDA")
def test_row_broadcast_matches_eager(self):
torch.manual_seed(0)
x = torch.... | 49 | 2,186 |
sglang | python/sglang/multimodal_gen/test/unit/test_lora_format_adapter.py | .py | """
test_lora_format_adapter.py
Small regression test for the LoRA format adapter.
It downloads several public LoRA checkpoints from Hugging Face, runs
format detection and normalization, and prints a compact summary table.
"""
import logging
import os
import tempfile
from typing import Dict, List
import torch
from... | 349 | 10,932 |
sglang | python/sglang/multimodal_gen/test/unit/test_transformer_quant.py | .py | """
This unittest is introduced in #22360, preventing duplicate transformer safetensors variants being loaded together
"""
import json
import os
import sys
import tempfile
import types
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from safetensors.torch import save_fil... | 675 | 25,195 |
sglang | python/sglang/multimodal_gen/test/unit/test_pi05_runtime_helpers.py | .py | # SPDX-License-Identifier: Apache-2.0
from types import SimpleNamespace
import numpy as np
import torch
from torch import nn
import sglang.multimodal_gen.runtime.models.vlas.pi05_policy as pi05_policy_module
from sglang.multimodal_gen.configs.pipeline_configs.pi05 import Pi05PipelineConfig
from sglang.multimodal_gen... | 271 | 8,418 |
sglang | python/sglang/multimodal_gen/test/unit/test_ipc_a2a_lifecycle.py | .py | from unittest.mock import patch
from sglang.multimodal_gen.runtime.distributed.device_communicators.ipc_a2a import (
IpcA2AState,
_peer_cuda_device,
ipc_a2a_ready,
)
_IPC = "sglang.multimodal_gen.runtime.distributed.device_communicators.ipc_a2a"
def test_reinitializes_ipc_transport_for_replaced_process_... | 59 | 1,769 |
sglang | python/sglang/multimodal_gen/test/unit/test_ministral3_generation.py | .py | import pytest
import torch
import torch.nn.functional as F
from transformers import Ministral3Config
from transformers.models.ministral3.modeling_ministral3 import (
Ministral3ForCausalLM as HFMinistral3ForCausalLM,
)
from sglang.multimodal_gen.runtime.layers.attention.backends.sdpa import SDPAImpl
from sglang.mul... | 136 | 4,780 |
sglang | python/sglang/multimodal_gen/test/unit/test_qwen_image_layered.py | .py | import unittest
from types import SimpleNamespace
import torch
from sglang.multimodal_gen.configs.pipeline_configs.qwen_image import (
QwenImageLayeredPipelineConfig,
)
class TestQwenImageLayeredPipelineConfig(unittest.TestCase):
def test_unpack_uses_layered_img_shapes_not_stale_request_size(self):
... | 48 | 1,438 |
sglang | python/sglang/multimodal_gen/test/unit/test_ipc_array.py | .py | # SPDX-License-Identifier: Apache-2.0
import tempfile
from pathlib import Path
import numpy as np
import pytest
from sglang.multimodal_gen.runtime import ipc_array
from sglang.multimodal_gen.runtime.ipc_array import (
NumpyArrayFileRef,
is_local_endpoint,
materialize_file_refs,
spill_large_arrays_to_... | 82 | 2,472 |
sglang | python/sglang/multimodal_gen/test/unit/test_fp32_layernorm.py | .py | import pytest
import torch
import torch.nn.functional as F
from sglang.multimodal_gen.runtime.layers.layernorm import FP32LayerNorm
@pytest.mark.skipif(not torch.cuda.is_available(), reason="CUDA required")
def test_fp32_layernorm_cache_matches_reference():
norm = FP32LayerNorm(16, eps=1e-5).cuda().to(torch.bflo... | 72 | 2,550 |
sglang | python/sglang/multimodal_gen/test/unit/test_adapter_loader_offload_target.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Custom component loaders place each component by its own offload policy.
`connectors` follows `dit_cpu_offload`; the duration head and standalone
diffusion decoder stay resident by default.
"""
import unittest
from sglang.multimodal_gen.runtime.loader.component_loaders.adapte... | 69 | 2,947 |
sglang | python/sglang/multimodal_gen/test/unit/test_layernorm_cutedsl_dispatch.py | .py | import sys
from types import SimpleNamespace
from unittest.mock import patch
import pytest
import torch
from sglang.multimodal_gen.runtime.layers.layernorm import (
RMSNormScaleShift,
ScaleResidualRMSNormScaleShift,
)
_CUTEDSL_MODULE = "sglang.kernels.ops.diffusion.cutedsl.scale_residual_norm_scale_shift"
... | 72 | 2,275 |
sglang | python/sglang/multimodal_gen/test/unit/test_minimax_h3_dit_contract.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Mixed-precision weight and TP/Ulysses numerical contracts for H3 DiT."""
from unittest.mock import patch
import pytest
import torch
from sglang.multimodal_gen.configs.models.dits.minimax_h3 import (
MiniMaxH3DiTArchConfig,
MiniMaxH3DiTConfig,
)
from sglang.multimodal_... | 436 | 14,538 |
sglang | python/sglang/multimodal_gen/test/unit/test_weight_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Unit tests for multimodal weight-loading utilities."""
import os
import tempfile
import unittest
from unittest.mock import patch
from sglang.multimodal_gen.runtime.loader.weight_utils import (
_disable_runai_streamer_rank_discovery_collective,
get_lock,
)
_DIST_STREAM... | 111 | 4,301 |
sglang | python/sglang/multimodal_gen/test/unit/test_usp_attention_replicated_prefix.py | .py | """Regression test for USPAttention GQA replicated-prefix head sharding.
``USPAttention._forward_with_replicated_prefix`` keeps a replicated token prefix
(e.g. text) out of the Ulysses all-to-all and slices that prefix down to the local
head shard. For a GQA model (kv heads < q heads) the K/V prefix must be sliced by
... | 156 | 6,383 |
sglang | python/sglang/multimodal_gen/test/unit/test_pi05_prefix_cache.py | .py | # SPDX-License-Identifier: Apache-2.0
import torch
from sglang.multimodal_gen.runtime.vla.prefix_cache import (
PrefixContext,
VLAPrefixCacheManager,
)
def _context() -> PrefixContext:
return PrefixContext(
past_key_values=("kv",),
prefix_pad_masks=torch.ones(1, 3, dtype=torch.bool),
... | 62 | 1,512 |
sglang | python/sglang/multimodal_gen/test/unit/test_gpu_worker_cpu_threads.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Contract for the per-worker CPU intra-op thread budget."""
import unittest
from unittest.mock import patch
from sglang.multimodal_gen.runtime.managers.gpu_worker import (
_worker_cpu_intra_op_threads,
)
class TestWorkerCpuIntraOpThreads(unittest.TestCase):
def test_d... | 43 | 1,403 |
sglang | python/sglang/multimodal_gen/test/unit/test_pipeline_executor.py | .py | import contextlib
from types import SimpleNamespace
from unittest.mock import Mock
import pytest
import torch
from sglang.multimodal_gen.runtime.managers.memory_managers.component_residency import (
COMPONENT_OFFLOAD,
LAYERWISE_OFFLOAD,
)
from sglang.multimodal_gen.runtime.pipelines_core.executors import pipe... | 195 | 6,040 |
sglang | python/sglang/multimodal_gen/test/unit/test_lora_inference_mode.py | .py | import torch
from torch import nn
from sglang.multimodal_gen.runtime.layers.lora.linear import (
LinearWithLoRA,
_compute_lora_delta,
)
def test_stacked_lora_delta_preserves_projection_order():
x = torch.tensor([[2.0, 3.0]])
lora_a = torch.tensor([[[1.0, 0.0]], [[0.0, 1.0]]])
lora_b = torch.tenso... | 52 | 1,512 |
sglang | python/sglang/multimodal_gen/test/unit/test_sana_video.py | .py | from types import SimpleNamespace
import torch
from sglang.multimodal_gen.configs.pipeline_configs.sana_video import (
SanaVideoPipelineConfig,
)
from sglang.multimodal_gen.configs.sample.sana_video import SanaVideoSamplingParams
from sglang.multimodal_gen.registry import get_model_info
from sglang.multimodal_gen... | 88 | 2,980 |
sglang | python/sglang/multimodal_gen/test/unit/test_cuda_attention_backend.py | .py | import sys
import types
import unittest
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.attention.selector import (
_cached_get_attn_backend,
)
from sglang.multimodal_gen.runtime.platforms.cuda import (
CudaPlatformBase,
_SageAttentionBackendResolver,
)
from sglang.m... | 159 | 5,089 |
sglang | python/sglang/multimodal_gen/test/unit/test_disagg_roles.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Unit tests for disaggregation role-based module filtering."""
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.configs.pipeline_configs.hunyuan3d import (
Hunyuan3D2PipelineConfig,
)
from sglang.mult... | 655 | 25,428 |
sglang | python/sglang/multimodal_gen/test/unit/test_dit_config_boundary.py | .py | from dataclasses import fields
import torch
from sglang.multimodal_gen.configs.models.bridges.mova_dual_tower import (
MOVADualTowerArchConfig,
)
from sglang.multimodal_gen.configs.models.dits.base import DiTArchConfig, DiTConfig
from sglang.multimodal_gen.runtime.models.bridges.mova_dual_tower import (
DualT... | 67 | 2,305 |
sglang | python/sglang/multimodal_gen/test/unit/test_minimax_h3_encoder_device.py | .py | import unittest
from unittest import mock
import torch
from sglang.multimodal_gen.runtime.models.encoders import minimax_h3_qwen3vl
from sglang.multimodal_gen.runtime.models.encoders.minimax_h3_qwen3vl import (
MiniMaxH3Qwen3VLEncoder,
)
class TestMiniMaxH3EncoderDevice(unittest.TestCase):
"""`device` must ... | 52 | 1,861 |
sglang | python/sglang/multimodal_gen/test/unit/test_ltx2_5_config.py | .py | # SPDX-License-Identifier: Apache-2.0
"""LTX-2.5 config wiring.
These pin the handful of places where LTX-2.5 diverges from LTX-2 and where a
silent regression would produce wrong output rather than an error. Everything
here is CPU/meta-device only -- no weights, no GPU.
"""
import json
import tempfile
import unittes... | 644 | 25,419 |
sglang | python/sglang/multimodal_gen/test/unit/test_utils_parent_death.py | .py | import signal
import unittest
from unittest.mock import Mock, patch
from sglang.multimodal_gen import utils
class TestKillItselfWhenParentDied(unittest.TestCase):
def _run_linux_case(self, parent_pids):
libc = Mock()
libc.prctl.return_value = 0
with (
patch.object(utils.sys, ... | 56 | 1,787 |
sglang | python/sglang/multimodal_gen/test/unit/test_zimage_qknorm_fusion.py | .py | import unittest
import torch
from sglang.multimodal_gen.runtime.models.dits.zimage import (
ZImageRMSNorm,
zimage_native_qk_rmsnorm,
)
HEAD_DIM = 128
@unittest.skipUnless(torch.cuda.is_available(), "requires CUDA")
class TestZImageQkNormFusion(unittest.TestCase):
def _make_norm(self, seed):
tor... | 52 | 1,859 |
sglang | python/sglang/multimodal_gen/test/unit/test_zimage_pipeline_config.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.configs.pipeline_configs.zimage import ZImagePipelineConfig
from sglang.multimodal_gen.runtime.models.dits.zimage import (
ZImageRMSNorm,
ZImageTransformer2DModel,
)
class TestZImagePipe... | 138 | 4,845 |
sglang | python/sglang/multimodal_gen/test/unit/test_launch_server_shutdown.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import Mock, patch
from sglang.multimodal_gen.runtime import launch_server as ls
from sglang.multimodal_gen.runtime.disaggregation.roles import RoleType
from sglang.multimodal_gen.runtime.entrypoints.utils import ShutdownReq
class _FakeProcess:
... | 84 | 2,911 |
sglang | python/sglang/multimodal_gen/test/unit/test_parallel_linear_weight_loading.py | .py | import pytest
import torch
from sglang.multimodal_gen.runtime.layers.linear import (
MergedColumnParallelLinear,
QKVParallelLinear,
)
from sglang.multimodal_gen.runtime.models.parameter import PerTensorScaleParameter
def _per_tensor_scale(values: list[float]) -> PerTensorScaleParameter:
return PerTensorS... | 58 | 1,962 |
sglang | python/sglang/multimodal_gen/test/unit/test_rollout_api.py | .py | """Unit tests for the rollout generate API (serialization, io_struct, rollout_api)."""
import types
import unittest
import torch
from sglang.multimodal_gen.runtime.entrypoints.post_training.utils import (
_maybe_deserialize,
_maybe_serialize,
bytes_to_tensor,
tensor_to_bytes,
)
from sglang.multimodal... | 422 | 16,228 |
sglang | python/sglang/multimodal_gen/test/unit/test_diffusion_generator_shutdown.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import Mock, patch
from sglang.multimodal_gen.runtime.entrypoints import diffusion_generator as dg
from sglang.multimodal_gen.runtime.entrypoints.diffusion_generator import DiffGenerator
from sglang.multimodal_gen.runtime.entrypoints.utils import Shu... | 100 | 3,297 |
sglang | python/sglang/multimodal_gen/test/unit/test_server_warmup_progress.py | .py | """Unit tests for server warmup progress reporting."""
import unittest
from unittest.mock import MagicMock, patch
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import OutputBatch
from sglang.multimodal_gen.runtime.server_warmup import SchedulerWarmupMixin
class TestServerWarmupProgress(unittest.T... | 37 | 1,283 |
sglang | python/sglang/multimodal_gen/test/unit/test_ring_admission.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Ring admission is a backend capability, not a name whitelist."""
import unittest
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.attention.backends.attention_backend import (
AttentionBackend,
)
from sglang.multimodal_gen.runtime.lay... | 59 | 2,169 |
sglang | python/sglang/multimodal_gen/test/unit/test_vae_spatial_parallel_decode.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.configs.models.vaes.base import (
VAEConfig,
is_spatial_shard_parallel_decode_mode,
should_use_spatial_shard_parallel_decode,
)
from sglang.multimodal_gen.configs.models.vaes.ernie_ima... | 513 | 19,318 |
sglang | python/sglang/multimodal_gen/test/unit/test_lora_commit_as_base.py | .py | """Unit tests for BaseLayerWithLoRA.commit_merged_as_base.
Validates the "merge a fixed-strength LoRA into the base once, then apply the
rest as a dynamic delta" primitive used by LTX-2 original mode. Weight-level
invariants are checked on CPU with a plain nn.Linear base (the parallel forward
path needs a distributed ... | 104 | 4,033 |
sglang | python/sglang/multimodal_gen/test/unit/test_output_saving.py | .py | import numpy as np
import pytest
import torch
from PIL import Image
import sglang.multimodal_gen.runtime.entrypoints.utils as output_utils
from sglang.multimodal_gen.configs.sample.sampling_params import DataType
from sglang.multimodal_gen.runtime.entrypoints.utils import (
MaterializedOutput,
post_process_sam... | 246 | 7,202 |
sglang | python/sglang/multimodal_gen/test/unit/test_diffusion_bcg_tp_graph_capture.py | .py | """BCG capture must run inside the TP group's graph-capture context.
Custom all-reduce records every capture-time input into a rank-data slot whose
peer pointers are written only by the ``register_graph_buffers()`` that runs when
``CustomAllreduce.capture()`` exits. That registration is a host-side IPC
exchange, so it... | 208 | 7,773 |
sglang | python/sglang/multimodal_gen/test/unit/test_ideogram4.py | .py | import json
import os
import tempfile
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
import torch.nn.functional as F
from transformers.models.qwen3_vl.configuration_qwen3_vl import Qwen3VLTextConfig
from sglang.multimodal_gen.configs.models.dits.ideogram import (
Id... | 1,596 | 63,639 |
sglang | python/sglang/multimodal_gen/test/unit/test_wan_ti2v_helpers.py | .py | import unittest
from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.configs.pipeline_configs.base import maybe_unpad_latents
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.wan_ti2v import (
expand_wan_ti2v_timestep,
prepare_... | 85 | 2,971 |
sglang | python/sglang/multimodal_gen/test/unit/test_wan_temb_table_slices.py | .py | import unittest
import torch
from sglang.multimodal_gen.runtime.models.dits.wanvideo import (
_eager_temb_table_slices,
_wan_temb_table_slices,
)
class TestWanTembTableSlices(unittest.TestCase):
@unittest.skipUnless(torch.cuda.is_available(), "requires CUDA")
def test_fused_matches_eager_and_is_cont... | 49 | 1,907 |
sglang | python/sglang/multimodal_gen/test/unit/test_ernie_image_pipeline_config.py | .py | import unittest
from types import SimpleNamespace
import torch
from sglang.multimodal_gen.configs.models.encoders.base import BaseEncoderOutput
from sglang.multimodal_gen.configs.pipeline_configs.base import TextConditioningOutput
from sglang.multimodal_gen.configs.pipeline_configs.ernie_image import (
ErnieImage... | 86 | 3,377 |
sglang | python/sglang/multimodal_gen/test/unit/test_text_encoding_cache.py | .py | from types import SimpleNamespace
from unittest.mock import MagicMock, patch
import torch
from sglang.multimodal_gen.runtime.pipelines_core.stages.text_encoding import (
TextEncodingStage,
)
_GLOBAL_ARGS_PATCH = (
"sglang.multimodal_gen.runtime.pipelines_core.stages.base.get_global_server_args"
)
class Dum... | 103 | 3,151 |
sglang | python/sglang/multimodal_gen/test/unit/test_sampling_params.py | .py | import argparse
import math
import unittest
from types import SimpleNamespace
from unittest.mock import MagicMock, patch
from sglang.multimodal_gen.configs.pipeline_configs.glm_image import (
GlmImagePipelineConfig,
)
from sglang.multimodal_gen.configs.pipeline_configs.ltx_2 import (
LTX2PipelineConfig,
is... | 509 | 19,447 |
sglang | python/sglang/multimodal_gen/test/unit/test_usp_packed_qkv_a2a.py | .py | """The packed Ulysses Q/K/V input exchange must be bit-identical to the
unpacked path. The collective is emulated in-process with exact
``all_to_all_single`` chunk semantics (rank r's j-th chunk goes to rank j's
r-th chunk); the pack kernel and unpack views run unmodified on CUDA."""
import unittest
from unittest.mock... | 67 | 2,466 |
sglang | python/sglang/multimodal_gen/test/unit/test_glm_image_multi_output.py | .py | from types import SimpleNamespace
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime.layers.layernorm import (
_can_use_npu_fused_scale_shift,
)
from sglang.multimodal_gen.runtime.models.dits import glm_image as glm_model
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_... | 173 | 5,644 |
sglang | python/sglang/multimodal_gen/test/unit/test_logging_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
import logging
import unittest
from sglang.multimodal_gen.runtime.utils.logging_utils import (
globally_suppress_loggers,
)
class TestSuppressNoisyDependencyLogs(unittest.TestCase):
def test_filters_only_pytree_enum_registration_deprecation(self):
logger = loggi... | 32 | 1,047 |
sglang | python/sglang/multimodal_gen/test/unit/test_nvtx_pytorch_hooks.py | .py | """Unit tests for ``sglang.multimodal_gen.runtime.utils.nvtx_pytorch_hooks``.
These tests cover the CPU-only surface: the ``maybe_nvtx_range`` helper,
``DiffusionNvtxHooks.register_hooks`` / ``remove_hooks`` lifecycle, and the
shape-collection helper. The actual ``nvtx.range_push`` / ``range_pop`` calls
require CUDA a... | 388 | 15,316 |
sglang | python/sglang/multimodal_gen/test/unit/test_qwen3vl_vision.py | .py | from types import SimpleNamespace
import torch
from torch import nn
from sglang.multimodal_gen.configs.models.encoders.qwen3vl import Qwen3VLArchConfig
from sglang.multimodal_gen.runtime.models.encoders.minimax_h3_qwen3vl import (
MiniMaxH3Qwen3VLEncoder,
)
from sglang.multimodal_gen.runtime.models.encoders.qwen3... | 124 | 3,997 |
sglang | python/sglang/multimodal_gen/test/unit/test_latent_upsampler_group_norm_silu.py | .py | from __future__ import annotations
from unittest.mock import patch
import pytest
import torch
import sglang.multimodal_gen.runtime.models.upsampler.latent_upsampler as lu_mod
from sglang.kernels.ops.diffusion.group_norm_silu import apply_group_norm_silu
from sglang.multimodal_gen.runtime.models.upsampler.latent_upsa... | 307 | 9,882 |
sglang | python/sglang/multimodal_gen/test/unit/test_platform_detection.py | .py | # SPDX-License-Identifier: Apache-2.0
import unittest
from unittest.mock import patch
import torch
from sglang.multimodal_gen.runtime import platforms
class NVMLUnavailableError(Exception):
pass
class TestCudaPlatformDetection(unittest.TestCase):
def test_torch_fallback_excludes_hip(self):
cases ... | 43 | 1,297 |
sglang | python/sglang/multimodal_gen/test/unit/test_layerwise_offload.py | .py | from contextlib import nullcontext
from types import SimpleNamespace
import pytest
import torch
from sglang.multimodal_gen.runtime.disaggregation.roles import RoleType
from sglang.multimodal_gen.runtime.layers.quantization.fp8 import Fp8Config
from sglang.multimodal_gen.runtime.layers.quantization.modelopt_quant impo... | 1,172 | 41,102 |
sglang | python/sglang/multimodal_gen/test/unit/test_consistency_metrics.py | .py | import math
import numpy as np
import pytest
from sglang.multimodal_gen.test import test_utils
from sglang.multimodal_gen.test.test_utils import (
ConsistencyThresholds,
LoadedConsistencyGT,
compare_with_gt,
compute_mean_abs_diff,
compute_psnr,
compute_ssim,
save_consistency_failure_artifa... | 628 | 19,318 |
sglang | python/sglang/multimodal_gen/test/unit/test_openai_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
import asyncio
import io
from types import SimpleNamespace
from starlette.datastructures import UploadFile as StarletteUploadFile
from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams
from sglang.multimodal_gen.runtime.entrypoints.openai import utils as... | 110 | 3,218 |
sglang | python/sglang/multimodal_gen/test/unit/test_longlive2_pipeline_config.py | .py | # SPDX-License-Identifier: Apache-2.0
import unittest
from sglang.multimodal_gen.configs.pipeline_configs.longlive2 import LongLive2T2VConfig
class TestLongLive2AdjustNumFrames(unittest.TestCase):
def setUp(self):
self.config = LongLive2T2VConfig()
def test_reuses_wan_temporal_frame_adjustment(self)... | 27 | 873 |
sglang | python/sglang/multimodal_gen/test/unit/test_request_manifest.py | .py | import hashlib
import json
from types import SimpleNamespace
import pytest
from sglang.multimodal_gen.benchmarks.bench_offline_throughput import (
BatchOutput,
BenchArgs,
RequestOutput,
calculate_metrics,
generate_batch,
)
from sglang.multimodal_gen.benchmarks.request_manifest import load_request_... | 191 | 5,677 |
sglang | python/sglang/multimodal_gen/test/unit/test_sol_attn_backend.py | .py | import importlib.util
import unittest
from unittest.mock import MagicMock, patch
import torch
from sglang.multimodal_gen.runtime.layers.attention.backends.sol_attn import (
SolAttnBackend,
SolAttnImpl,
_parse_layer_ranges,
)
from sglang.multimodal_gen.runtime.platforms.cuda import CudaPlatformBase
from sg... | 119 | 3,675 |
sglang | python/sglang/multimodal_gen/test/unit/test_scheduler_rollout_unit.py | .py | import math
import types
import unittest
import torch
import sglang.multimodal_gen.runtime.post_training.scheduler_rl_mixin as rl_mixin_module
from sglang.multimodal_gen.runtime.post_training.scheduler_rl_mixin import (
SchedulerRLMixin,
)
class _DummyScheduler(SchedulerRLMixin):
def __init__(self):
... | 583 | 23,877 |
sglang | python/sglang/multimodal_gen/test/unit/test_health_warmup_gate.py | .py | """Unit tests for diffusion server liveness and readiness endpoints.
`/liveness` reports HTTP availability independently of model warmup.
`/health` and `/health_generate` report readiness for inference traffic.
"""
import asyncio
import unittest
from types import SimpleNamespace
from unittest import mock
from sglang... | 95 | 3,096 |
sglang | python/sglang/multimodal_gen/test/unit/test_cli_generate_common.py | .py | import os
import unittest
from unittest.mock import patch
from PIL import Image
from sglang.multimodal_gen.test.single_test_file import cli_generate_common
class TestCLIBaseHelpers(unittest.TestCase):
def _make_case(self):
class _ImageDataType:
@staticmethod
def get_default_exten... | 70 | 2,233 |
sglang | python/sglang/multimodal_gen/test/unit/test_regional_torch_compile.py | .py | from types import SimpleNamespace
from unittest.mock import patch
import pytest
import torch.nn as nn
from sglang.multimodal_gen.runtime.models.dits.ltx_2 import (
LTX2VideoTransformer3DModel,
)
from sglang.multimodal_gen.runtime.pipelines_core.stages.denoising import (
DenoisingStage,
)
from sglang.multimoda... | 129 | 3,860 |
sglang | python/sglang/multimodal_gen/test/unit/test_server_args.py | .py | import json
import os
import sys
import tempfile
import unittest
from contextlib import contextmanager
from unittest.mock import patch
from sglang.cli.utils import get_is_diffusion_model
from sglang.multimodal_gen.configs.models.fsdp import (
is_module_list_entry,
is_module_list_entry_in,
is_zimage_layer,
... | 3,011 | 114,268 |
sglang | python/sglang/multimodal_gen/test/unit/test_input_validation.py | .py | """Unit tests for InputValidationStage.preprocess_condition_image resolution logic."""
import unittest
from unittest.mock import MagicMock, patch
import numpy as np
import torch
from diffusers.pipelines.flux2.image_processor import Flux2ImageProcessor
from PIL import Image
from sglang.multimodal_gen.configs.pipeline... | 269 | 10,436 |
sglang | python/sglang/multimodal_gen/test/unit/test_minimax_h3_media.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Numerical boundaries for the one-pass Ref2VA media path."""
import json
import os
import subprocess
import sys
from types import SimpleNamespace
import numpy as np
import pytest
import torch
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.minima... | 259 | 9,058 |
sglang | python/sglang/multimodal_gen/test/unit/conftest.py | .py | # SPDX-License-Identifier: Apache-2.0
from types import SimpleNamespace
import pytest
from sglang.multimodal_gen.runtime import server_args as server_args_module
from sglang.multimodal_gen.runtime.server_args import set_global_server_args
def _make_unit_server_args():
dit_config = SimpleNamespace(
hidd... | 60 | 1,691 |
sglang | python/sglang/multimodal_gen/test/unit/musa/layers/test_musa_silu_and_mul.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Tests for MUSA-specific SiluAndMul custom op.
These tests call forward_musa directly and compare against forward_native
as the reference implementation.
"""
import pytest
import torch
# We need the MUSA platform to be available for these tests.
# Skip the entire module if MUS... | 120 | 4,720 |
sglang | python/sglang/multimodal_gen/test/unit/musa/layers/test_musa_rmsnorm.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Tests for MUSA-specific RMSNorm custom op.
These tests call forward_musa directly and compare against forward_native
as the reference implementation.
"""
import pytest
import torch
# We need the MUSA platform to be available for these tests.
# Skip the entire module if MUSA i... | 286 | 12,024 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.