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/lang/backend/anthropic.py
.py
from sglang.lang.backend.base_backend import BaseBackend from sglang.lang.chat_template import get_chat_template from sglang.lang.interpreter import StreamExecutor from sglang.lang.ir import SglSamplingParams try: import anthropic except ImportError as e: anthropic = e class Anthropic(BaseBackend): def _...
74
2,019
sglang
python/sglang/lang/backend/runtime_endpoint.py
.py
import atexit import json import multiprocessing import time import warnings from typing import Dict, List, Optional, Union import aiohttp import requests from sglang.global_config import global_config from sglang.lang.backend.base_backend import BaseBackend from sglang.lang.chat_template import get_chat_template, ge...
552
18,570
sglang
python/sglang/lang/backend/litellm.py
.py
from typing import Mapping, Optional from sglang.lang.backend.base_backend import BaseBackend from sglang.lang.chat_template import get_chat_template_by_model_path from sglang.lang.interpreter import StreamExecutor from sglang.lang.ir import SglSamplingParams try: import litellm except ImportError as e: litel...
91
2,450
sglang
python/sglang/lang/backend/vertexai.py
.py
import os import warnings from sglang.lang.backend.base_backend import BaseBackend from sglang.lang.chat_template import get_chat_template from sglang.lang.interpreter import StreamExecutor from sglang.lang.ir import SglSamplingParams try: import vertexai from vertexai.preview.generative_models import ( ...
149
4,827
sglang
python/sglang/eval/llama3_eval.py
.py
# Adapt from https://github.com/fw-ai/llm_eval_meta import argparse import asyncio import os import pickle import re import shutil from collections import defaultdict from dataclasses import dataclass import httpx import numpy as np import openai from datasets import load_dataset from openai import AsyncOpenAI from t...
316
9,997
sglang
python/sglang/eval/loogle_eval.py
.py
import argparse import asyncio import os import pickle from pathlib import Path from typing import List import openai import torch from bert_score import BERTScorer from datasets import load_dataset from tqdm import tqdm def get_client(api_url: str) -> openai.AsyncOpenAI: if os.getenv("OPENAI_API_KEY") is None: ...
165
4,557
sglang
python/sglang/multimodal_gen/utils.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/utils.py import argparse import ctypes import importlib import importlib.util import inspect import math import os import signal import sy...
798
27,522
sglang
python/sglang/multimodal_gen/registry.py
.py
# SPDX-License-Identifier: Apache-2.0 """ Central registry for multimodal models. This module provides a centralized registry for multimodal models, including pipelines and sampling parameters. It allows for easy registration and retrieval of model information based on model paths or other identifiers. """ import dat...
1,278
47,313
sglang
python/sglang/multimodal_gen/envs.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # Adapted from vllm: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/envs.py import logging import os from typing import TYPE_CHECKING, Any, Callable from sglang.multimodal_gen.runtime.utils.common import g...
360
15,749
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/utils.py
.py
import base64 import io import os import shutil import time import uuid import folder_paths import numpy as np import torch from comfy_api.input import VideoInput from PIL import Image def _ensure_dir(path: str) -> None: os.makedirs(path, exist_ok=True) def _to_numpy_image(image: torch.Tensor) -> np.ndarray: ...
177
4,994
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/nodes.py
.py
""" ComfyUI nodes for SGLang Diffusion integration. Provides nodes for connecting to SGLang Diffusion server and generating images/videos. """ import os import uuid import folder_paths import torch from .core import SGLDiffusionGenerator, SGLDiffusionServerAPI from .utils import ( convert_b64_to_tensor_image, ...
716
22,576
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/__init__.py
.py
""" ComfyUI SGLang Diffusion nodes package. """ try: from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"] except ImportError: # ComfyUI dependencies not available (e.g., in test environment) NODE_CLASS_MAPPINGS = {} NODE...
14
416
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/executors/qwen_image.py
.py
""" QwenImage executor for SGLang Diffusion ComfyUI integration. """ import torch try: from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.utils import prepare_request except ImportError: print( "Error: sglang.multimodal_ge...
173
6,015
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/executors/flux.py
.py
""" Flux executor for SGLang Diffusion ComfyUI integration. """ import torch try: from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.utils import prepare_request except ImportError: print( "Error: sglang.multimodal_gen is ...
70
2,595
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/executors/__init__.py
.py
""" ComfyUI SGLang Diffusion executors package. Provides executor classes for different model types. """ from .base import SGLDiffusionExecutor from .flux import FluxExecutor from .qwen_image import QwenImageEditExecutor, QwenImageExecutor from .zimage import ZImageExecutor __all__ = [ "SGLDiffusionExecutor", ...
18
415
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/executors/zimage.py
.py
""" ZImage executor for SGLang Diffusion ComfyUI integration. """ import torch try: from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.utils import prepare_request except ImportError: print( "Error: sglang.multimodal_gen i...
65
2,316
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/executors/base.py
.py
""" Base executor class for SGLang Diffusion ComfyUI integration. """ import torch class SGLDiffusionExecutor(torch.nn.Module): """Base executor class for SGLang Diffusion models in ComfyUI.""" def __init__(self, generator, model_path, model, config): super(SGLDiffusionExecutor, self).__init__() ...
57
2,057
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/__init__.py
.py
""" Core components for SGLang Diffusion ComfyUI integration. Provides generator, model patcher, and server API client. """ from .generator import SGLDiffusionGenerator from .model_patcher import SGLDModelPatcher from .server_api import SGLDiffusionServerAPI __all__ = [ "SGLDiffusionGenerator", "SGLDModelPatc...
15
357
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/generator.py
.py
""" Generator for SGLang Diffusion ComfyUI integration. """ import logging import os import psutil from comfy import model_detection, model_management from comfy.utils import ( calculate_parameters, load_torch_file, state_dict_prefix_replace, unet_to_diffusers, ) logger = logging.getLogger(__name__) ...
232
8,457
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py
.py
""" SGLang Diffusion Server API client. Provides a low-level interface for interacting with SGLang Diffusion HTTP server. """ import base64 import io import os import time from typing import Any, Dict, Optional import requests from PIL import Image class SGLDiffusionServerAPI: """Client for SGLang Diffusion HTT...
540
20,106
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/model_patcher.py
.py
""" Model patcher for SGLang Diffusion ComfyUI integration. """ import copy from comfy.model_patcher import ModelPatcher class SGLDModelPatcher(ModelPatcher): """Model patcher for SGLang Diffusion models in ComfyUI.""" def __init__( self, model, load_device, offload_device, ...
83
2,211
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_qwen_image_edit_pipeline.py
.py
"""Test for ComfyUIQwenImageEditPipeline with pass-through scheduler (I2I/edit mode).""" import os import sys import pytest import torch from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.diffusion_generator import DiffGenerator from sglang....
137
4,380
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/__init__.py
.py
""" Test suite for ComfyUI SGLDiffusion pipelines. This package contains tests for each ComfyUI pipeline integration: - ZImagePipeline - FluxPipeline - QwenImagePipeline - QwenImageEditPipeline """
10
199
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_qwen_image_pipeline.py
.py
"""Test for ComfyUIQwenImagePipeline with pass-through scheduler.""" import os import sys import pytest import torch from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.diffusion_generator import DiffGenerator from sglang.multimodal_gen.runti...
121
3,793
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_flux_pipeline.py
.py
"""Test for ComfyUIFluxPipeline with pass-through scheduler.""" import os import sys import pytest import torch from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.diffusion_generator import DiffGenerator from sglang.multimodal_gen.runtime.en...
157
4,641
sglang
python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/test/test_zimage_pipeline.py
.py
"""Test for ComfyUIZImagePipeline with pass-through scheduler.""" import os import sys import pytest import torch from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams from sglang.multimodal_gen.runtime.entrypoints.diffusion_generator import DiffGenerator from sglang.multimodal_gen.runtime....
123
3,752
sglang
python/sglang/multimodal_gen/apps/webui/main.py
.py
import argparse import os from sglang.multimodal_gen.configs.sample.sampling_params import ( DataType, SamplingParams, ) from sglang.multimodal_gen.runtime.entrypoints.utils import ( post_process_sample, prepare_request, ) from sglang.multimodal_gen.runtime.scheduler_client import sync_scheduler_client...
266
9,889
sglang
python/sglang/multimodal_gen/apps/webui/__init__.py
.py
from .main import run_sgl_diffusion_webui __all__ = ["run_sgl_diffusion_webui"]
4
81
sglang
python/sglang/multimodal_gen/csrc/attn/vmoba_attn/setup.py
.py
# SPDX-License-Identifier: Apache-2.0 from setuptools import find_packages, setup PACKAGE_NAME = "vmoba" VERSION = "0.0.0" AUTHOR = "JianzongWu" DESCRIPTION = "VMoBA: Mixture-of-Block Attention for Video Diffusion Models" URL = "https://github.com/KwaiVGI/VMoBA" setup( name=PACKAGE_NAME, version=VERSION, ...
27
635
sglang
python/sglang/multimodal_gen/csrc/attn/vmoba_attn/vmoba/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 from .vmoba import ( moba_attn_varlen as moba_attn_varlen, process_moba_input as process_moba_input, process_moba_output as process_moba_output, ) __all__ = ["moba_attn_varlen", "process_moba_input", "process_moba_output"]
9
274
sglang
python/sglang/multimodal_gen/csrc/attn/vmoba_attn/vmoba/vmoba.py
.py
# SPDX-License-Identifier: Apache-2.0 # Adapt from https://github.com/KwaiVGI/VMoBA/blob/main/src/vmoba.py import random import time from typing import Tuple import torch try: from flash_attn import ( # Use the new flash attention function flash_attn_varlen_func, ) from flash_attn.flash_attn_int...
1,084
39,676
sglang
python/sglang/multimodal_gen/csrc/attn/vmoba_attn/tests/test_vmoba_attn.py
.py
# SPDX-License-Identifier: Apache-2.0 import random import pytest import torch from sglang.multimodal_gen.csrc.attn.vmoba_attn.vmoba import moba_attn_varlen def generate_test_data( batch_size, total_seqlen, num_heads, head_dim, dtype, device="cuda" ): """ Generates random data for testing the variable-l...
138
4,291
sglang
python/sglang/multimodal_gen/third_party/pynvml.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # copied from https://pypi.org/project/nvidia-ml-py # version 12.570.86 ##### # Copyright (c) 2011-2023, NVIDIA Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or wit...
7,228
228,516
sglang
python/sglang/multimodal_gen/tools/build_minimax_h3_adaln_cache.py
.py
# SPDX-License-Identifier: Apache-2.0 """Build an inference-only AdaLN cache from a local MiniMax H3 transformer.""" from __future__ import annotations import argparse import json import math from contextlib import ExitStack from pathlib import Path from typing import Any import torch import torch.nn.functional as F...
269
8,894
sglang
python/sglang/multimodal_gen/tools/convert_hf_to_fp8.py
.py
# copied and adapted from Slime """ Convert HuggingFace safetensors model to FP8 format for efficient inference. Example usage: # convert FLUX.1-dev transformer to FP8 python -m sglang.multimodal_gen.tools.convert_hf_to_fp8 \ --model-dir /path/to/FLUX.1-dev/transformer \ --save-dir /path/to/FLU...
321
10,248
sglang
python/sglang/multimodal_gen/tools/build_modelopt_nvfp4_transformer.py
.py
"""Build an SGLang-loadable ModelOpt NVFP4 diffusion transformer. This tool keeps the ModelOpt-exported NVFP4 tensors for most transformer modules, but can replace a validated subset of numerically sensitive modules with their original BF16 tensors from the base transformer checkpoint. It is primarily intended for FL...
401
13,333
sglang
python/sglang/multimodal_gen/tools/wan_repack.py
.py
### Based on https://github.com/huggingface/diffusers/blob/main/scripts/convert_wan_to_diffusers.py import argparse import json import pathlib import shutil from typing import Any, Dict, List from safetensors.torch import load_file, save_file from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger ...
229
8,209
sglang
python/sglang/multimodal_gen/tools/build_modelopt_fp8_transformer.py
.py
"""Build an SGLang-loadable ModelOpt FP8 diffusion transformer. The core conversion path is model-agnostic: - read the ModelOpt diffusers transformer export - rebuild per-layer `weight_scale` / `input_scale` tensors from `backbone.pt` - materialize SGLang-native `float8_e4m3fn` weights - preserve ModelOpt `ignore` lay...
884
31,709
sglang
python/sglang/multimodal_gen/tools/compare_diffusion_trajectory_similarity.py
.py
"""Compare diffusion BF16 and quantized runs via trajectory-latent similarity. This tool runs two SGLang diffusion variants with the same prompt and seed, captures intermediate denoising latents via `return_trajectory_latents`, and reports cosine / error metrics for each timestep plus final frame metrics. The intende...
632
22,382
sglang
python/sglang/multimodal_gen/benchmarks/bench_offline_throughput.py
.py
""" Benchmark offline throughput for multimodal generation models (Image/Video Generation). This script benchmarks generation throughput without running a server, using low-level APIs. It provides detailed metrics on throughput, latency, and resource utilization. # Usage Examples ## Text-to-Video with VBench dataset...
730
25,602
sglang
python/sglang/multimodal_gen/benchmarks/datasets.py
.py
import glob import json import os import random import re import subprocess import uuid from abc import ABC, abstractmethod from dataclasses import dataclass, field from typing import Any, Dict, List, Optional import requests from PIL import Image from sglang.multimodal_gen.runtime.utils.logging_utils import init_log...
362
13,582
sglang
python/sglang/multimodal_gen/benchmarks/compare_perf.py
.py
import argparse import json import os import re from datetime import datetime from typing import Any, Dict, List, Tuple def calculate_diff(base: float, new: float) -> Tuple[float, float]: """Returns (diff, diff_percent).""" diff = new - base if base == 0: percent = 0.0 else: percent = ...
302
9,620
sglang
python/sglang/multimodal_gen/benchmarks/bench_serving.py
.py
""" Benchmark online serving for diffusion models (Image/Video Generation). Usage: # launch a server and benchmark on it # T2V or T2I or any other multimodal generation model sglang serve --model-path Wan-AI/Wan2.2-T2V-A14B-Diffusers --num-gpus 1 --port 1231 # benchmark it and make sure the port is ...
885
32,537
sglang
python/sglang/multimodal_gen/benchmarks/request_manifest.py
.py
"""JSONL request manifests for reproducible offline diffusion benchmarks.""" from __future__ import annotations import hashlib import json from dataclasses import dataclass from pathlib import Path from typing import Any from urllib.parse import urlparse _TOP_LEVEL_SAMPLING_FIELDS = { "fps", "guidance_scale"...
184
5,915
sglang
python/sglang/multimodal_gen/benchmarks/bench_pi05_openpi.py
.py
# SPDX-License-Identifier: Apache-2.0 """Manual Pi0.5 SGLang vs OpenPI benchmark. This script is intentionally outside the unit-test path. It needs GPU memory, Pi0.5 checkpoints, and an OpenPI install for the baseline. """ from __future__ import annotations import argparse import asyncio import copy import dataclas...
1,352
46,324
sglang
python/sglang/multimodal_gen/test/run_suite.py
.py
""" Test runner for multimodal_gen that manages test suites and parallel execution. For diffusion 1-gpu/2-gpu suites, cases are partitioned by estimated runtime using LPT so each CI shard has a similar total runtime. """ import argparse import copy import json import os import random import subprocess import sys impo...
694
23,475
sglang
python/sglang/multimodal_gen/test/partitioning.py
.py
from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class PartitionItem: kind: str item_id: str est_time: float used_fallback_estimate: bool = False def partition_items_by_lpt( items: list[PartitionItem], num_partitions: int ) -> list[list[PartitionItem]...
47
1,337
sglang
python/sglang/multimodal_gen/test/test_utils.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo import base64 import html import io import json import math import os import socket import subprocess import sys import tempfile import time from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, Any from urllib.par...
2,145
74,001
sglang
python/sglang/multimodal_gen/test/server/realtime_consistency.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import asyncio import os import statistics import tempfile from dataclasses import dataclass from pathlib import Path from typing import Any import imageio import msgspec.msgpack import numpy as np import pytest from openai import Client from ...
404
13,899
sglang
python/sglang/multimodal_gen/test/server/test_server_1_gpu.py
.py
""" Config-driven diffusion performance test with pytest parametrization. If the actual run is significantly better than the baseline, the improved cases with their updated baseline will be printed """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffus...
24
701
sglang
python/sglang/multimodal_gen/test/server/test_server_b200.py
.py
""" Config-driven diffusion performance test with pytest parametrization. """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.gpu_cases import ONE_GPU_B200_CASES from sglang.multimodal_gen.test...
21
609
sglang
python/sglang/multimodal_gen/test/server/test_server_1_gpu_5090.py
.py
""" Config-driven diffusion canary tests for the 1-GPU 5090 PR runner. """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.gpu_cases import ONE_GPU_5090_CASES from sglang.multimodal_gen.test.se...
21
601
sglang
python/sglang/multimodal_gen/test/server/test_server_4_gpu_h100.py
.py
"""PR-blocking diffusion smoke tests that require four H100 GPUs.""" from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.gpu_cases import ( MINIMAX_H3_FOUR_GPU_H100_CASES, ) from sglang.multimo...
19
558
sglang
python/sglang/multimodal_gen/test/server/test_server_common.py
.py
""" Config-driven diffusion generation test with pytest parametrization. Each collected request prints a performance log before validation. """ from __future__ import annotations import json import os import queue import threading import time from pathlib import Path from typing import Any, Callable import numpy a...
1,481
56,808
sglang
python/sglang/multimodal_gen/test/server/test_request_logger.py
.py
""" Test request logging for diffusion models. Tests the --log-requests CLI flags for diffusion model serving, verifying that request logs are correctly written to stdout and files. """ import json import os import shutil import tempfile import time from pathlib import Path import pytest from openai import OpenAI f...
234
7,318
sglang
python/sglang/multimodal_gen/test/server/test_server_utils.py
.py
""" Server management and performance validation for diffusion tests. """ from __future__ import annotations import asyncio import base64 import os import shlex import subprocess import sys import tempfile import threading import time from dataclasses import dataclass, field from pathlib import Path from typing impor...
1,642
59,629
sglang
python/sglang/multimodal_gen/test/server/testcase_configs.py
.py
""" Configuration and data structures for diffusion performance tests. Usage: pytest python/sglang/multimodal_gen/test/server/test_server_1_gpu.py # for a single testcase, look for the name of the testcase in ONE_GPU_CASES, # ONE_GPU_MODELOPT_FP8_CASES, ONE_GPU_B200_CASES, or TWO_GPU_CASES pytest python/sglang/multim...
884
30,549
sglang
python/sglang/multimodal_gen/test/server/gpu_cases.py
.py
from dataclasses import replace from pathlib import Path from sglang.multimodal_gen.runtime.platforms import current_platform from sglang.multimodal_gen.test.server.testcase_configs import ( MODELOPT_FLUX1_FP8_TRANSFORMER, MODELOPT_FLUX1_NVFP4_TRANSFORMER, MODELOPT_FLUX2_FP8_TRANSFORMER, MODELOPT_FLUX2...
1,258
43,351
sglang
python/sglang/multimodal_gen/test/server/test_server_2_gpu.py
.py
""" 2 GPU tests """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.gpu_cases import TWO_GPU_CASES from sglang.multimodal_gen.test.server.test_server_common import ( # noqa: F401 Diffusion...
21
517
sglang
python/sglang/multimodal_gen/test/server/conftest.py
.py
import json import os import pytest print("[CONFTEST] Loading conftest.py at import time") def pytest_configure(config): """ Create the perf results StashKey once and store it in config. This hook runs once per test session, before module double-import issues. """ if not hasattr(config, "_diffus...
166
6,057
sglang
python/sglang/multimodal_gen/test/server/musa/run_suite.py
.py
""" Test runner for multimodal_gen MUSA suites that manages partitioned execution. Usage: python3 -m sglang.multimodal_gen.test.server.musa.run_suite --suite <suite_name> """ from __future__ import annotations import argparse import os import sys from pathlib import Path import tabulate TEST_ROOT = Path(__file...
173
4,793
sglang
python/sglang/multimodal_gen/test/server/musa/test_server_1_gpu_musa_nightly.py
.py
""" MUSA-specific 1-GPU diffusion performance tests for nightly suite. """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.musa.testcase_configs_musa import ( ONE_GPU_NIGHTLY_MUSA_CASES, ) ...
23
658
sglang
python/sglang/multimodal_gen/test/server/musa/test_server_1_gpu_musa.py
.py
""" MUSA-specific 1-GPU diffusion performance tests. """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.musa.testcase_configs_musa import ( ONE_GPU_MUSA_CASES, ) from sglang.multimodal_gen...
23
602
sglang
python/sglang/multimodal_gen/test/server/musa/testcase_configs_musa.py
.py
from __future__ import annotations from dataclasses import replace from functools import lru_cache from sglang.multimodal_gen.test.server.testcase_configs import ( T2V_PROMPT, DiffusionSamplingParams, DiffusionServerArgs, DiffusionTestCase, MULTI_FRAME_I2I_sampling_params, MULTI_IMAGE_TI2I_sam...
135
3,780
sglang
python/sglang/multimodal_gen/test/server/musa/test_server_2_gpu_musa.py
.py
""" MUSA-specific 2-GPU diffusion performance tests. """ from __future__ import annotations from sglang.multimodal_gen.test.server.common.case_fixtures import ( diffusion_case_fixture, ) from sglang.multimodal_gen.test.server.musa.testcase_configs_musa import ( TWO_GPU_MUSA_CASES, ) from sglang.multimodal_gen...
23
602
sglang
python/sglang/multimodal_gen/test/server/common/slack.py
.py
""" This file upload the media generated in diffusion-nightly-test to a slack channel of SGLang """ import logging import os import tempfile from datetime import datetime from typing import List, Union from urllib.parse import urlparse from urllib.request import urlopen from sglang.multimodal_gen.runtime.utils.perf_l...
217
7,468
sglang
python/sglang/multimodal_gen/test/server/common/case_fixtures.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, Sequence import pytest if TYPE_CHECKING: from sglang.multimodal_gen.test.server.testcase_configs import DiffusionTestCase def diffusion_case_fixture(cases: Sequence[DiffusionTestCase]): @pytest.fixture(params=cases, ids=lambda case: case....
17
420
sglang
python/sglang/multimodal_gen/test/server/ascend/test_server_2_npu.py
.py
""" Config-driven diffusion performance test with pytest parametrization. If the actual run is significantly better than the baseline, the improved cases with their updated baseline will be printed """ from __future__ import annotations from sglang.multimodal_gen.test.server.ascend.testcase_configs_npu import TWO_N...
24
719
sglang
python/sglang/multimodal_gen/test/server/ascend/test_server_1_npu.py
.py
""" Config-driven diffusion performance test with pytest parametrization. If the actual run is significantly better than the baseline, the improved cases with their updated baseline will be printed """ from __future__ import annotations from sglang.multimodal_gen.test.server.ascend.testcase_configs_npu import ONE_N...
24
719
sglang
python/sglang/multimodal_gen/test/server/ascend/testcase_configs_npu.py
.py
import os from sglang.multimodal_gen.test.server.testcase_configs import ( T2V_PROMPT, DiffusionSamplingParams, DiffusionServerArgs, DiffusionTestCase, T2I_sampling_params, TI2V_sampling_params, ) MODELSCOPE_MODEL_WEIGHTS_DIR = "/root/.cache/modelscope/hub/models/" def use_modelscope(name: s...
201
5,756
sglang
python/sglang/multimodal_gen/test/scripts/gen_perf_baselines.py
.py
import argparse import inspect import json import os import re import sys from pathlib import Path from openai import OpenAI from sglang.multimodal_gen.runtime.platforms import current_platform from sglang.multimodal_gen.test.server.test_server_utils import ( ServerManager, get_generate_fn, ) from sglang.mult...
216
6,891
sglang
python/sglang/multimodal_gen/test/scripts/gen_diffusion_ci_outputs.py
.py
#!/usr/bin/env python3 """ Generate diffusion CI outputs for consistency testing. This script reuses the CI test code by calling run_suite.py with SGLANG_GEN_GT=1, ensuring that GT generation uses exactly the same code path as CI tests. Usage: python gen_diffusion_ci_outputs.py --suite 1-gpu --partition-id 0 --to...
229
7,970
sglang
python/sglang/multimodal_gen/test/unit/test_minimax_h3_adaln_cache.py
.py
# SPDX-License-Identifier: Apache-2.0 import torch from safetensors.torch import save_file from sglang.multimodal_gen.configs.models.dits.minimax_h3 import ( MiniMaxH3DiTArchConfig, ) from sglang.multimodal_gen.runtime.models.dits.minimax_h3 import ( MiniMaxH3AdalnCache, ) def test_minimax_h3_adaln_cache_ma...
60
1,941
sglang
python/sglang/multimodal_gen/test/unit/test_video_sparse_attention.py
.py
import math import torch from sglang.multimodal_gen.runtime.layers.attention.backends import ( video_sparse_attn as vsa_module, ) from sglang.multimodal_gen.runtime.layers.attention.backends.video_sparse_attn import ( VSA_TILE_SIZE, VideoSparseAttentionImpl, VideoSparseAttentionMetadataBuilder, _c...
107
3,435
sglang
python/sglang/multimodal_gen/test/unit/test_hf_diffusers_utils.py
.py
import json import modelscope import pytest from huggingface_hub.errors import LocalEntryNotFoundError from sglang.multimodal_gen.runtime.utils import hf_diffusers_utils from sglang.multimodal_gen.runtime.utils.hf_diffusers_utils import ( _check_index_files_for_missing_shards, _is_revisionless_snapshot_root, ...
342
11,637
sglang
python/sglang/multimodal_gen/test/unit/test_minimax_h3_admission.py
.py
# SPDX-License-Identifier: Apache-2.0 """High-value task, partition, and public request admission contracts.""" from __future__ import annotations from types import SimpleNamespace from unittest.mock import patch import pytest import torch from sglang.multimodal_gen.configs.pipeline_configs.minimax_h3 import ( ...
370
12,157
sglang
python/sglang/multimodal_gen/test/unit/test_vae_loader.py
.py
import unittest from unittest.mock import patch import torch from sglang.multimodal_gen.configs.pipeline_configs.ltx_2 import LTX2PipelineConfig from sglang.multimodal_gen.configs.pipeline_configs.qwen_image import ( QwenImagePipelineConfig, ) from sglang.multimodal_gen.configs.pipeline_configs.wan import ( F...
206
9,338
sglang
python/sglang/multimodal_gen/test/unit/test_scheduler_client.py
.py
import asyncio import pickle import uuid from types import SimpleNamespace from unittest.mock import AsyncMock, MagicMock import pytest import zmq import zmq.asyncio from sglang.multimodal_gen.runtime.scheduler_client import ( AsyncSchedulerClient, SchedulerClient, run_zeromq_broker, ) from sglang.multimo...
161
5,314
sglang
python/sglang/multimodal_gen/test/unit/test_served_model_name.py
.py
import asyncio from types import SimpleNamespace from unittest.mock import patch from sglang.multimodal_gen.runtime.entrypoints.openai import common_api from sglang.multimodal_gen.runtime.entrypoints.openai.common_api import ( DiffusionModelCard, ) from sglang.multimodal_gen.runtime.entrypoints.openai.protocol imp...
59
1,947
sglang
python/sglang/multimodal_gen/test/unit/test_glm_image_ar.py
.py
import unittest from types import SimpleNamespace from unittest.mock import MagicMock, patch import torch from PIL import Image from sglang.multimodal_gen.configs.sample.glmimage import GlmImageSamplingParams from sglang.multimodal_gen.runtime.entrypoints.openai.image_api import ( _build_image_response_kwargs, ) ...
371
13,026
sglang
python/sglang/multimodal_gen/test/unit/test_precision_consistency.py
.py
import importlib.util import sys import types import unittest from contextlib import nullcontext from pathlib import Path from types import SimpleNamespace import torch def _load_precision_module(): package_names = ( "sglang", "sglang.multimodal_gen", "sglang.multimodal_gen.runtime", ...
235
8,717
sglang
python/sglang/multimodal_gen/test/unit/test_sp_shard.py
.py
"""Unit tests for the unified SP shard helpers (pure logic, no distributed).""" import sys import pytest import torch from sglang.multimodal_gen.runtime.distributed import sp_shard_utils as sps from sglang.multimodal_gen.runtime.distributed.sp_shard_utils import ( SpShard, shard_like, tail_attn_meta, ) ...
227
8,168
sglang
python/sglang/multimodal_gen/test/unit/test_text_encoder_loader.py
.py
import unittest from types import SimpleNamespace from unittest import mock import transformers from sglang.multimodal_gen.runtime.loader.component_loaders.text_encoder_loader import ( TextEncoderLoader, ) from sglang.multimodal_gen.runtime.models.encoders.minimax_h3_qwen3vl import ( MiniMaxH3Qwen3VLEncoder, ...
107
4,172
sglang
python/sglang/multimodal_gen/test/unit/test_weight_only_fp8_dequant_cache.py
.py
import os import unittest from unittest.mock import patch import torch from sglang.multimodal_gen.runtime.layers.quantization.weight_only_fp8 import ( FP8_WEIGHT_DTYPE, WeightOnlyFP8Linear, dequantize_rowwise_fp8_weight, ) from sglang.test.test_utils import CustomTestCase def _make_linear(device: torch....
95
3,835
sglang
python/sglang/multimodal_gen/test/unit/test_subblock_sparse_attention.py
.py
# SPDX-License-Identifier: Apache-2.0 """SubBlock block-sparse attention backend. The schedule tests are pure CPU. The numerical tests need an SM100 GPU with FlashInfer's ``bsa_attn_blk64_fwd`` and are skipped otherwise. The trick that makes the sparse kernel checkable against dense attention: at ``sparsity`` just ab...
358
13,656
sglang
python/sglang/multimodal_gen/test/unit/test_diffusion_bcg_padding.py
.py
import unittest from types import SimpleNamespace from unittest.mock import patch import torch from sglang.multimodal_gen.runtime.breakable_cuda_graph.runner import ( DiffusionBreakableCudaGraphRunner, _CaptureEntry, _signature_kwargs, ) from sglang.multimodal_gen.runtime.layers.attention import ( Dyn...
564
23,361
sglang
python/sglang/multimodal_gen/test/unit/test_component_accuracy_inputs.py
.py
from types import SimpleNamespace import torch.nn as nn from sglang.multimodal_gen.test.single_test_file.component_accuracy.hooks import ( _build_transformer_hook_inputs, ) class _TransformerWithOptionalMask(nn.Module): def forward( self, hidden_states, encoder_hidden_states, ...
46
1,185
sglang
python/sglang/multimodal_gen/test/unit/test_wan_attention_backend.py
.py
import unittest from unittest.mock import patch from torch import nn from sglang.multimodal_gen.runtime.models.dits.wanvideo import WanSelfAttention from sglang.multimodal_gen.runtime.platforms import AttentionBackendEnum _WAN = "sglang.multimodal_gen.runtime.models.dits.wanvideo" class TestWanAttentionBackendRole...
37
1,251
sglang
python/sglang/multimodal_gen/test/unit/test_resolve_prompts.py
.py
import os import tempfile import unittest from types import SimpleNamespace from sglang.multimodal_gen.runtime.entrypoints.diffusion_generator import DiffGenerator def _make_generator(prompt_file_path=None): """Return a DiffGenerator-shaped object with only server_args populated.""" obj = object.__new__(Diff...
101
3,567
sglang
python/sglang/multimodal_gen/test/unit/test_cfg_gating.py
.py
import os import unittest from types import SimpleNamespace from unittest.mock import patch import torch from sglang.multimodal_gen.runtime.distributed.cfg_policy import CFGPolicy from sglang.multimodal_gen.runtime.pipelines_core.stages.denoising import ( DenoisingStage, ) class _PipelineConfig: def get_cla...
181
6,318
sglang
python/sglang/multimodal_gen/test/unit/test_fsdp_load.py
.py
# SPDX-License-Identifier: Apache-2.0 import tempfile import unittest from pathlib import Path from unittest.mock import patch import torch from safetensors.torch import safe_open, save_file from torch import nn from sglang.multimodal_gen.runtime.layers.linear import ReplicatedLinear from sglang.multimodal_gen.runti...
361
14,314
sglang
python/sglang/multimodal_gen/test/unit/test_encoder_world_folding.py
.py
"""Unit test for the encoder_parallel decision. adjust_pipeline_config proposes a fold group from the parallelism alone; finalize_encoder_folding resolves fold-vs-replicate per policy on real dims; encoder_dp_worthwhile gates the runtime batch data-parallel. Pure logic, no GPU / distributed init (the fold group is mon...
287
10,228
sglang
python/sglang/multimodal_gen/test/unit/test_cfg_parallel_warmup.py
.py
"""Unit tests for the --enable-cfg-parallel warmup fix and guard. Covers warmup and cfg-parallel guard paths introduced alongside this file: - build_warmup_reqs synthesizes warmup Reqs that actually enable classifier-free guidance when cfg-parallel is on. - DiffGenerator sends explicit warmup resolutions through the...
972
38,503
sglang
python/sglang/multimodal_gen/test/unit/test_dp_routing.py
.py
"""Routing invariants for DP serving. Generation requests go to exactly one replica, control ops reach every replica, and a realtime session always lands on the same replica it started on. """ import itertools from sglang.multimodal_gen.runtime.entrypoints.utils import SetLoraReq, ShutdownReq from sglang.multimodal_...
72
2,538
sglang
python/sglang/multimodal_gen/test/unit/test_component_accuracy_parallel_runtime.py
.py
from contextlib import ExitStack from types import SimpleNamespace from unittest.mock import call, patch from sglang.multimodal_gen.runtime.distributed import parallel_state from sglang.multimodal_gen.runtime.distributed.device_communicators.ipc_a2a import ( IPC_A2A, ) from sglang.multimodal_gen.runtime.distribute...
116
4,263
sglang
python/sglang/multimodal_gen/test/unit/test_qwen3_encoder.py
.py
from types import SimpleNamespace import torch from sglang.multimodal_gen.runtime.models.encoders.qwen3 import Qwen3ForCausalLM class _CaptureLayer(torch.nn.Module): def __init__(self): super().__init__() self.position_ids = None self.attention_lengths = None def forward(self, posit...
51
1,674
sglang
python/sglang/multimodal_gen/test/unit/test_usp_attention_kv_gather.py
.py
import unittest from types import SimpleNamespace from unittest.mock import patch import torch import torch.nn.functional as F from sglang.multimodal_gen.runtime.layers.attention.layer import ( UlyssesAttention, UlyssesAttention_VSA, USPAttention, _count_active_replicated_modes, _kv_gather_unsuppo...
367
13,858
sglang
python/sglang/multimodal_gen/test/unit/test_pipeline_stage_profiling.py
.py
import unittest from types import SimpleNamespace from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req from sglang.multimodal_gen.runtime.pipelines_core.stages.base import PipelineStage class NamedNoOpStage(PipelineStage): def __init__(self): self.server_args = SimpleNamespace( ...
42
1,364
sglang
python/sglang/multimodal_gen/test/unit/test_varlen_meta_host_build.py
.py
"""Host-built varlen metadata must match the mask-based (nonzero) builder.""" import unittest import torch from sglang.multimodal_gen.runtime.layers.attention.layer import ( build_varlen_mask_meta, build_varlen_mask_meta_from_ranges, ) class TestHostVarlenMetaEquivalence(unittest.TestCase): def test_pr...
37
1,166
sglang
python/sglang/multimodal_gen/test/unit/test_wan_pipeline_config.py
.py
from types import SimpleNamespace import torch from sglang.multimodal_gen.configs.pipeline_configs.wan import WanT2V480PConfig def test_wan_prompt_embed_accessors_return_transformer_tensor(): prompt_embeds = torch.empty(1, 2, 3) negative_prompt_embeds = torch.empty(1, 2, 3) batch = SimpleNamespace( ...
20
589