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/runtime/server_args/auto_tune.py
.py
""" ServerArgsAutoTuner tunes the ServerArgs based on the desired performance mode """ from __future__ import annotations from typing import TYPE_CHECKING from sglang.multimodal_gen import envs from sglang.multimodal_gen.configs.pipeline_configs.model_deployment_config import ( ModelDeploymentConfig, ) from sgla...
617
25,257
sglang
python/sglang/multimodal_gen/runtime/server_args/server_args.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # Inspired by SGLang: https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/server_args.py """The arguments of sglang-diffusion Inference.""" import argparse import dataclasses import json import math ...
3,271
134,740
sglang
python/sglang/multimodal_gen/runtime/utils/request_logger.py
.py
# Copyright 2026 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 writing, so...
205
7,695
sglang
python/sglang/multimodal_gen/runtime/utils/distributed.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo import pickle from typing import Any, List, Optional import numpy as np import torch import torch.distributed as dist from sglang.multimodal_gen.runtime.platforms import current_platform def broadcast_pyobj( data: List[Any], rank: int, ...
235
8,464
sglang
python/sglang/multimodal_gen/runtime/utils/camera_geometry.py
.py
# SPDX-License-Identifier: Apache-2.0 """Camera pose and Plucker ray utilities.""" from __future__ import annotations import torch def se3_inverse(T: torch.Tensor) -> torch.Tensor: rot = T[:, :3, :3] trans = T[:, :3, 3:] r_inv = rot.transpose(-1, -2) t_inv = -torch.bmm(r_inv, trans) T_inv = tor...
119
3,485
sglang
python/sglang/multimodal_gen/runtime/utils/profiler.py
.py
import gzip import os import torch from sglang.multimodal_gen.runtime.platforms import current_platform from sglang.multimodal_gen.runtime.utils.logging_utils import CYAN, RESET, init_logger from sglang.srt.utils.torch_npu_patch_utils import apply_torch_npu_patches if current_platform.is_npu(): import torch_npu ...
195
6,540
sglang
python/sglang/multimodal_gen/runtime/utils/model_overlay.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import glob import hashlib import importlib.util import json import os import shutil from typing import Any, Callable, cast from huggingface_hub.errors import ( LocalEntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError,...
781
27,138
sglang
python/sglang/multimodal_gen/runtime/utils/logging_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/logger.py """Logging configuration for sglang.multimodal_gen.""" import argparse import contextlib import dataclasses import datetime impo...
677
21,207
sglang
python/sglang/multimodal_gen/runtime/utils/torch_compile.py
.py
# SPDX-License-Identifier: Apache-2.0 import os from collections.abc import Callable from dataclasses import dataclass, field from typing import Any import torch.nn as nn from sglang.multimodal_gen.runtime.platforms import current_platform from sglang.srt.utils.common import get_compiler_backend def maybe_enable_i...
141
3,844
sglang
python/sglang/multimodal_gen/runtime/utils/trace_wrapper.py
.py
"""Context-manager wrappers around sglang.srt.observability.trace for diffusion tracing. All tracing helpers for the multimodal_gen subsystem are consolidated here so that call sites can use simple ``with`` statements instead of manual start/end bookkeeping. """ from __future__ import annotations from contextlib imp...
78
2,022
sglang
python/sglang/multimodal_gen/runtime/utils/nvtx_pytorch_hooks.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...
215
7,900
sglang
python/sglang/multimodal_gen/runtime/utils/precision.py
.py
from contextlib import contextmanager, nullcontext from typing import Iterator, Optional, Union import torch from sglang.multimodal_gen.runtime.platforms import current_platform from sglang.multimodal_gen.runtime.utils.precision_types import PRECISION_TO_TYPE def precision_to_dtype(precision: str, field_name: str =...
162
5,172
sglang
python/sglang/multimodal_gen/runtime/utils/weight_attrs.py
.py
# SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Adapted from: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/utils.py from typing import Any import torch from sglang.multimodal_gen.runtime.platforms import current_platform def set_w...
34
1,050
sglang
python/sglang/multimodal_gen/runtime/utils/hf_diffusers_utils.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # Adapted from SGLang: https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/hf_transformers_utils.py # Copyright 2023-2024 SGLang Team # Licensed under the Apache License, Version 2.0 (the "License");...
1,173
43,529
sglang
python/sglang/multimodal_gen/runtime/utils/condition_expansion.py
.py
# SPDX-License-Identifier: Apache-2.0 from dataclasses import dataclass import torch @dataclass(frozen=True) class PromptToSampleBatchExpander: """Expand selected conditioning from prompt order to sample order.""" prompt_batch_size: int sample_batch_size: int @classmethod def from_batch(cls, b...
112
4,417
sglang
python/sglang/multimodal_gen/runtime/utils/mesh3d_utils.py
.py
"""Adapted from Hunyuan3D-2: https://github.com/Tencent/Hunyuan3D-2""" from __future__ import annotations import math from typing import Any, List, Optional, Tuple, Union import cv2 import numpy as np import torch import torch.nn.functional as F import trimesh from einops import rearrange, repeat from PIL import Ima...
1,115
38,051
sglang
python/sglang/multimodal_gen/runtime/utils/common.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo import ipaddress import logging import os import platform import signal import socket import sys import threading from functools import lru_cache from typing import Any import psutil import torch import zmq # use the native logger to avoid circular i...
425
13,546
sglang
python/sglang/multimodal_gen/runtime/utils/precision_types.py
.py
"""Canonical string→dtype map for diffusion precision configs.""" import torch PRECISION_TO_TYPE = { "fp32": torch.float32, "fp16": torch.float16, "bf16": torch.bfloat16, } __all__ = ["PRECISION_TO_TYPE"]
12
222
sglang
python/sglang/multimodal_gen/runtime/utils/vision.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import os import tempfile from collections.abc import Callable from io import BytesIO from urllib.parse import unquote, urlparse import imageio import numpy as np import PIL.Image import PIL.ImageOps import reque...
298
10,146
sglang
python/sglang/multimodal_gen/runtime/utils/perf_logger.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo import dataclasses import json import logging import os import subprocess import sys import time from datetime import datetime from functools import lru_cache from pathlib import Path from typing import Any, Dict, Optional import torch from dateutil.tz...
390
13,194
sglang
python/sglang/multimodal_gen/runtime/utils/quantization_utils.py
.py
import glob import json import os import re import struct from pathlib import Path from typing import Any, Dict, List, Optional from safetensors import safe_open from sglang.multimodal_gen.runtime.layers.quantization import ( QuantizationConfig, get_quantization_config, ) from sglang.multimodal_gen.runtime.ut...
568
21,316
sglang
python/sglang/multimodal_gen/runtime/utils/image_io.py
.py
# SPDX-License-Identifier: Apache-2.0 import base64 import os import re def save_base64_image_to_path(base64_data: str, target_path: str) -> str: b64_format_hint = ( "Failed to decode base64 image. " "Expected format: `data:[<media-type>];base64,<data>`" ) match = re.match(r"data:(.*?)(;b...
42
1,201
sglang
python/sglang/multimodal_gen/runtime/utils/realtime_video.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import time import zlib from collections.abc import Callable, Sequence from typing import TYPE_CHECKING, Any import numpy as np import torch from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger if TYPE_CHECKING: from ...
216
7,316
sglang
python/sglang/multimodal_gen/runtime/utils/component_load.py
.py
# SPDX-License-Identifier: Apache-2.0 """Shared helpers for lazily loading pipeline components onto stages.""" from __future__ import annotations from typing import Any from sglang.multimodal_gen.runtime.loader.component_loaders.transformer_loader import ( TransformerLoader, ) from sglang.multimodal_gen.runtime....
30
980
sglang
python/sglang/multimodal_gen/runtime/realtime/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 """session-scoped realtime state, control signals, and runtime-only helpers""" from sglang.multimodal_gen.runtime.realtime.control_signals import ( ControlScriptQueue, ControlSignal, ControlSignalQueue, ControlSignalSamplingParams, ControlStateQueue, Contr...
44
1,182
sglang
python/sglang/multimodal_gen/runtime/realtime/control_signals.py
.py
# SPDX-License-Identifier: Apache-2.0 """Realtime control signal primitives. This module owns the small, model-agnostic data structures that turn external realtime control inputs into chunk-sized payloads consumed by model adapters. It intentionally does not know about cameras, LingBot, or SANA-WM semantics; callers ...
465
15,119
sglang
python/sglang/multimodal_gen/runtime/realtime/session.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from collections import OrderedDict from typing import Any from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger logger = init_logger(__name__) class BaseRealtimeState: """per-session state owned by pipeline stages"""...
113
3,798
sglang
python/sglang/multimodal_gen/runtime/realtime/states/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 """reusable session-scoped state implementations for realtime pipelines""" from sglang.multimodal_gen.runtime.realtime.states.camera_control import ( RealtimeCameraControlState, ) from sglang.multimodal_gen.runtime.realtime.states.causal import ( RealtimeCausalDecodeState...
20
536
sglang
python/sglang/multimodal_gen/runtime/realtime/states/camera_control.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from collections.abc import Callable from typing import Any from sglang.multimodal_gen.runtime.realtime.control_signals import ( ControlScriptQueue, ControlStateQueue, ControlStateTransition, parse_control_event_payload, ) Came...
157
6,039
sglang
python/sglang/multimodal_gen/runtime/realtime/states/causal.py
.py
# SPDX-License-Identifier: Apache-2.0 from typing import Any, TypeVar, cast from sglang.multimodal_gen.runtime.realtime.session import ( BaseRealtimeState, RealtimeSession, ) class RealtimeCausalDiTState(BaseRealtimeState): """persist causal DiT cache, chunk frontier, and output buffer""" def __ini...
59
1,658
sglang
python/sglang/multimodal_gen/runtime/managers/scheduler.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import dataclasses import pickle import time from collections import deque from contextlib import contextmanager from copy import deepcopy from enum import Enum from typing import Any, Iterator, List import zmq f...
1,308
51,838
sglang
python/sglang/multimodal_gen/runtime/managers/cpu_worker.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import os import torch from sglang.multimodal_gen.runtime.server_args import ServerArgs from sglang.multimodal_gen.runtime.utils.logging_utils import ( init_logger, ) from sglang.srt.utils import cpu_has_amx_...
77
3,872
sglang
python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py
.py
# SPDX-License-Identifier: Apache-2.0 """Admission control for native diffusion batching. Native diffusion batching is model, resolution, device, and implementation dependent. The scheduler treats `--batching-max-size` as the public ceiling; `--batching-config` can apply stricter caps for specific model and shape comb...
350
12,654
sglang
python/sglang/multimodal_gen/runtime/managers/gpu_worker.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import gc import logging import multiprocessing as mp import os import tempfile import time from contextlib import ExitStack from dataclasses import dataclass, field from typing import Any, Callable, Iterator, List...
1,173
46,202
sglang
python/sglang/multimodal_gen/runtime/managers/forward_context.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/forward_context.py import time from collections import defaultdict from contextlib import contextmanager from dataclasses import dataclass ...
121
4,637
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/layerwise_offload.py
.py
import bisect import re from collections.abc import Mapping, Sequence from typing import Any, Dict, List, Set, Tuple import torch from torch.distributed.tensor import DTensor from sglang.multimodal_gen.runtime.disaggregation.roles import RoleType from sglang.multimodal_gen.runtime.managers.memory_managers.component_r...
1,102
47,637
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/component_loading_order.py
.py
"""Memory-aware ordering for pipeline component weight loads to avoid OOM while loading. Load the VRAM-intensive components earlier than others The pipeline owns component selection, path resolution, and actual loading; this module only ranks already-selected load specs. """ import glob import json import os from da...
175
5,879
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/component_residency_strategies.py
.py
"""Runtime strategies used by the component residency manager.""" from __future__ import annotations from typing import TYPE_CHECKING import torch import torch.nn as nn from torch.distributed.fsdp import FSDPModule from sglang.multimodal_gen.runtime.distributed import get_local_torch_device from sglang.multimodal_g...
230
6,552
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/memory_occupation_controller.py
.py
# SPDX-License-Identifier: Apache-2.0 import gc import torch from sglang.multimodal_gen.runtime.managers.memory_managers.layerwise_offload import ( is_layerwise_offloaded_module, ) from sglang.multimodal_gen.runtime.pipelines_core import ComposedPipelineBase from sglang.multimodal_gen.runtime.post_training.weigh...
226
7,854
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/component_manager.py
.py
from collections.abc import Iterator from contextlib import contextmanager from dataclasses import dataclass from typing import Mapping, MutableMapping, Protocol, Sequence import torch import torch.nn as nn from sglang.multimodal_gen.runtime.managers.memory_managers.component_residency import ( COMPONENT_OFFLOAD,...
676
26,381
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/layerwise_offload_components.py
.py
from collections.abc import Collection, Sequence LAYERWISE_OFFLOAD_ALL_COMPONENTS = "all" LAYERWISE_OFFLOAD_DIT_GROUP = "dit" LAYERWISE_OFFLOAD_TEXT_ENCODER_GROUP = "text_encoder" LAYERWISE_OFFLOAD_IMAGE_ENCODER_GROUP = "image_encoder" LAYERWISE_OFFLOAD_VAE_GROUP = "vae" LAYERWISE_OFFLOAD_DEFAULT_GROUP = "default" # ...
219
7,679
sglang
python/sglang/multimodal_gen/runtime/managers/memory_managers/component_residency.py
.py
"""Parsing and resolution for component residency CLI modes.""" from __future__ import annotations from collections.abc import Mapping, Sequence from sglang.multimodal_gen.runtime.managers.memory_managers.layerwise_offload_components import ( LAYERWISE_OFFLOAD_ALL_COMPONENTS, LAYERWISE_OFFLOAD_DIT_GROUP, ...
163
5,577
sglang
python/sglang/multimodal_gen/runtime/postprocess/realesrgan_upscaler.py
.py
# SPDX-License-Identifier: Apache-2.0 """ Real-ESRGAN upscaling for SGLang diffusion pipelines. Real-ESRGAN model code is vendored and adapted from: - https://github.com/xinntao/Real-ESRGAN (BSD-3-Clause License) Copyright (c) 2021 xinntao The ImageUpscaler wrapper and integration code are original work. """ im...
823
30,718
sglang
python/sglang/multimodal_gen/runtime/postprocess/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 """Frame interpolation and upscaling support for SGLang diffusion pipelines.""" from sglang.multimodal_gen.runtime.postprocess.realesrgan_upscaler import ( ImageUpscaler, batch_upscale_frames, upscale_frames, ) from sglang.multimodal_gen.runtime.postprocess.rife_interp...
21
534
sglang
python/sglang/multimodal_gen/runtime/postprocess/rife_interpolator.py
.py
# SPDX-License-Identifier: Apache-2.0 """ RIFE 4.22.lite frame interpolation for SGLang diffusion pipelines. RIFE model code is vendored and adapted from: - https://github.com/hzwer/ECCV2022-RIFE (MIT License) - https://github.com/hzwer/Practical-RIFE (MIT License) Copyright (c) 2021 Zhewei Huang The FrameInt...
539
17,840
sglang
python/sglang/multimodal_gen/runtime/models/parameter.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project # Adapted from: https://github.com/vllm-project/vllm/blob/v0.7.3/vllm/model_executor/parameter.py from collections.abc import Callable from frac...
425
14,990
sglang
python/sglang/multimodal_gen/runtime/models/registry.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/model_executor/models/registry.py import ast import importlib import os import pickle import subprocess import sys import tempfile from ab...
430
15,260
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_self_forcing_flow_match.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import torch from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.schedulers.scheduling_utils import SchedulerMixin from diffusers.utils import BaseOutput from sglang.multimodal...
143
5,094
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_comfyui_passthrough.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 """ Pass-through scheduler for ComfyUI integration. This scheduler does not modify latents - it simply returns the input sample unchanged. The actual denoising logic is handled by ComfyUI. """ import torch from di...
194
6,043
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_dpm_solver_multistep.py
.py
# SPDX-License-Identifier: Apache-2.0 # # DPM-Solver++ multistep scheduler wrapper for SANA. # # SANA uses DPM-Solver++ (Lu et al., 2022) as its noise scheduler, which # is a high-order ODE solver that converges in fewer steps than DDIM. # With solver_order=2 and 20 steps, SANA achieves high-quality results. # # This w...
149
5,214
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_minimax_h3_euler_ancestral.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import math from typing import Any import torch def _require_finite_tensor(tensor: torch.Tensor, name: str) -> None: if not bool(torch.isfinite(tensor).all().item()): raise ValueError(f"{name} must be finite") def _validate_unit_...
215
7,281
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_unipc_multistep.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # Copyright 2025 TSAIL Team and The HuggingFace Team. All rights reserved. # # 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 ...
1,233
50,871
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_unipc_multistep.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # Copied from https://github.com/huggingface/diffusers/blob/v0.31.0/src/diffusers/schedulers/scheduling_unipc_multistep.py # Convert unipc for flow matching # Copyright 2024-2025 The Alibaba Wan Team Authors. All r...
844
34,234
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/flow_match_pair.py
.py
# Copied and adapted from: https://github.com/OpenMOSS/MOVA/tree/main/mova/diffusion/schedulers/flow_match.py and flow_match_pair.py # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import math import torch from sglang.multimodal_gen.runtime.models.schedulers.base import BaseScheduler clas...
532
20,879
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_helios.py
.py
# SPDX-License-Identifier: Apache-2.0 # Adapted from Helios diffusers scheduler: # https://github.com/BestWishYsh/Helios """ Helios scheduler implementing flow-matching with UniPC/Euler solvers. For Phase 1 T2V (stages=1), this simplifies to standard flow-matching with dynamic shifting and UniPC multistep solver. """ ...
745
26,447
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/scheduling_flow_match_euler_discrete.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 # Copyright 2024 Stability AI, Katherine Crowson and The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance ...
709
29,074
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/hunyuan3d_scheduler.py
.py
# Copied and adapted from: https://github.com/Tencent-Hunyuan/Hunyuan3D-2 from __future__ import annotations import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import ConfigMixin, register_to_config from diff...
372
12,967
sglang
python/sglang/multimodal_gen/runtime/models/schedulers/base.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 from abc import ABC, abstractmethod import torch class BaseScheduler(ABC): timesteps: torch.Tensor order: int num_train_timesteps: int def __init__(self, *args, **kwargs) -> None: # Che...
38
983
sglang
python/sglang/multimodal_gen/runtime/models/dits/qwen_image.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import functools from typing import Any, Dict, List, Optional, Tuple, Union import diffusers import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from diffusers.models.embeddings ...
1,633
62,448
sglang
python/sglang/multimodal_gen/runtime/models/dits/joy_image.py
.py
# SPDX-License-Identifier: Apache-2.0 import math from functools import lru_cache from typing import Any, Optional, Tuple import torch import torch.nn as nn from einops import rearrange from sglang.multimodal_gen.configs.models.dits.joy_image import JoyImageDiTConfig from sglang.multimodal_gen.configs.models.fsdp im...
597
20,770
sglang
python/sglang/multimodal_gen/runtime/models/dits/glm_image.py
.py
# Copyright 2025 The CogView team, Tsinghua University & ZhipuAI and The HuggingFace Team. All rights reserved. # # 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/l...
1,156
41,311
sglang
python/sglang/multimodal_gen/runtime/models/dits/causal_wanvideo.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import math from typing import Any import torch import torch.nn as nn from torch.nn.attention.flex_attention import ( BlockMask, create_block_mask, flex_attention, ) from sglang.multimodal_gen.runtim...
754
26,712
sglang
python/sglang/multimodal_gen/runtime/models/dits/longlive2.py
.py
# SPDX-License-Identifier: Apache-2.0 from typing import Any import torch import torch.nn as nn from torch.nn.attention.flex_attention import BlockMask from sglang.multimodal_gen.configs.models.dits.longlive2 import LongLive2VideoConfig from sglang.multimodal_gen.configs.models.fsdp import is_block from sglang.multim...
191
6,876
sglang
python/sglang/multimodal_gen/runtime/models/dits/ltx_2.py
.py
# Copied and adapted from LTX-2 and WanVideo implementations. # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import Any, Optional, Tuple, Union import torch import torch.nn as nn import torch.nn.functional as F from sglang.kernels.ops.diffusion.bitexact_gate import BitExactFu...
2,347
94,084
sglang
python/sglang/multimodal_gen/runtime/models/dits/flux.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # Copyright 2025 Black Forest Labs, The HuggingFace Team and The InstantX Team. All rights reserved. # # 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...
1,390
52,284
sglang
python/sglang/multimodal_gen/runtime/models/dits/helios.py
.py
# SPDX-License-Identifier: Apache-2.0 # Adapted from Helios diffusers transformer: # https://github.com/BestWishYsh/Helios """ Helios Transformer 3D model for video generation. Implements the HeliosTransformer3DModel with multi-term memory patches, 3D rotary position embeddings, and per-block scale-shift modulation. "...
975
36,846
sglang
python/sglang/multimodal_gen/runtime/models/dits/flux_2.py
.py
# Copyright 2025 Black Forest Labs, The HuggingFace Team and The InstantX Team. All rights reserved. # # 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/LIC...
1,290
49,194
sglang
python/sglang/multimodal_gen/runtime/models/dits/stable_diffusion.py
.py
# SPDX-License-Identifier: Apache-2.0 """Native Stable Diffusion 2.1 UNet blocks used by Hunyuan3D texture models.""" from __future__ import annotations import math from dataclasses import dataclass from typing import Any import torch import torch.nn.functional as F from torch import nn from sglang.multimodal_gen.r...
919
33,393
sglang
python/sglang/multimodal_gen/runtime/models/dits/sana_wm_refiner_transformer.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import Any, Optional import torch import torch.nn as nn from sglang.multimodal_gen.configs.models.dits.sana_wm_refiner import ( SanaWMRefinerArchConfig, SanaWMRefinerConfig, ) from sglang.multimodal_gen.configs.models.fsdp ...
427
15,189
sglang
python/sglang/multimodal_gen/runtime/models/dits/longcat_image.py
.py
# Copied and adapted from: https://github.com/huggingface/diffusers # main/src/diffusers/models/transformers/transformer_longcat_image.py """LongCat-Image Transformer2D model for SGLang. Implements the LongCatImageTransformer2DModel architecture from diffusers adapted for SGLang's inference pipeline. Key adaptation: ...
711
26,728
sglang
python/sglang/multimodal_gen/runtime/models/dits/krea2.py
.py
"""Krea-2 (K2) single-stream MMDiT. Text and image tokens are concatenated into a single joint-attention stream. The model uses GQA attention with a sigmoid output gate, 6-way shared adaLN modulation, a text-fusion transformer that fuses the selected text-encoder hidden-state layers into one, and interleaved 3-axis Ro...
757
25,805
sglang
python/sglang/multimodal_gen/runtime/models/dits/sana.py
.py
# SPDX-License-Identifier: Apache-2.0 import torch import torch.nn as nn import torch.nn.functional as F from diffusers.models.embeddings import PixArtAlphaTextProjection, TimestepEmbedding from sglang.kernels.ops.diffusion.bitexact_gate import BitExactFusionGate from sglang.kernels.ops.diffusion.triton.layernorm_mod...
548
20,396
sglang
python/sglang/multimodal_gen/runtime/models/dits/sana_wm_components.py
.py
# SPDX-License-Identifier: Apache-2.0 """SANA-WM DiT building blocks (components). Reusable primitives, RoPE / UCPE camera geometry, GDN scan kernels, embedders, FFN, and the SANA-WM attention modules. """ import math from typing import Callable, List, Optional, Tuple import torch import torch.nn as nn import torch....
3,036
108,209
sglang
python/sglang/multimodal_gen/runtime/models/dits/cosmos3video.py
.py
# SPDX-License-Identifier: Apache-2.0 """Cosmos3 Omni transformer. Dual-pathway DiT: an Understanding (UND) pathway runs causal self-attention over the text tokens once and caches its K/V; a Generation (GEN) pathway cross-attends from noisy visual tokens to that cache at every denoising step. """ import math from col...
1,849
70,807
sglang
python/sglang/multimodal_gen/runtime/models/dits/mova_video_dit.py
.py
# Copied and adapted from: mossVG/mova/diffusion/models/wan_video_dit.py # SPDX-License-Identifier: Apache-2.0 # # NOTE: This module shares common functions (sinusoidal_embedding_1d, precompute_freqs_cis, etc.) # with wanvideo.py. These functions are kept here for MOVA-specific model architecture, # but could be refact...
587
21,266
sglang
python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py
.py
# SPDX-License-Identifier: Apache-2.0 """MiniMax H3 packed-token DiT. Native SGLang implementation of the MiniMax H3 audio-video DiT. The forward contract accepts packed inference keyword arguments and returns packed logits. """ from __future__ import annotations import math import os import struct from contextlib i...
2,142
81,710
sglang
python/sglang/multimodal_gen/runtime/models/dits/ideogram.py
.py
# SPDX-License-Identifier: Apache-2.0 import math from typing import Any import torch import torch.nn as nn import torch.nn.functional as F from sglang.kernels.ops.diffusion.bitexact_gate import ( BitExactFusionGate, tensors_equal, ) from sglang.kernels.ops.diffusion.fused_gate_rmsnorm import ( fused_gat...
779
26,086
sglang
python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py
.py
# SPDX-License-Identifier: Apache-2.0 import os from typing import Callable, List, Optional, Tuple import torch import torch.nn as nn from sglang.multimodal_gen.configs.models.dits.sana_wm import SanaWMConfig from sglang.multimodal_gen.configs.models.fsdp import ( is_blocks_or_transformer_blocks, ) from sglang.m...
909
34,883
sglang
python/sglang/multimodal_gen/runtime/models/dits/zimage.py
.py
import math from typing import Any, List, Optional, Tuple import torch import torch.nn as nn from sglang.multimodal_gen.configs.models.dits.zimage import ZImageDitConfig from sglang.multimodal_gen.configs.models.fsdp import is_zimage_layer from sglang.multimodal_gen.runtime.distributed import ( get_sp_world_size,...
1,641
59,629
sglang
python/sglang/multimodal_gen/runtime/models/dits/common.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from typing import Any import torch def modulate( x: torch.Tensor, shift: torch.Tensor | None = None, scale: torch.Tensor | None = None, ) -> torch.Tensor: """Modulate by shift and scale.""" if scale is None and shift is N...
66
2,268
sglang
python/sglang/multimodal_gen/runtime/models/dits/lingbot_world.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # Adapted from: https://github.com/Robbyant/lingbot-world # SPDX-License-Identifier: Apache-2.0 import math from functools import lru_cache from typing import Any import torch import torch.distributed as dist import torch.nn as nn import torch.nn.fun...
1,637
60,880
sglang
python/sglang/multimodal_gen/runtime/models/dits/wanvideo.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 import math from functools import lru_cache from typing import Any import torch import torch.nn as nn from sglang.kernels.ops.diffusion.bitexact_gate import ( BitExactFusionGate, tensors_equal, ) from sg...
1,339
47,067
sglang
python/sglang/multimodal_gen/runtime/models/dits/stablediffusion3.py
.py
# SPDX-License-Identifier: Apache-2.0 """StableDiffusion3 Transformer model implementation. NOTE: This initial implementation uses diffusers' JointTransformerBlock directly. A native SGLang attention implementation is needed for FlashAttention, TP/SP, quantization, and LoRA support. """ from typing import Any import...
196
7,430
sglang
python/sglang/multimodal_gen/runtime/models/dits/ernie_image.py
.py
# Copyright 2026 Baidu ERNIE-Image Team and The HuggingFace Team. All rights reserved. # # 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 # # U...
845
28,658
sglang
python/sglang/multimodal_gen/runtime/models/dits/mova_audio_dit.py
.py
# Copied and adapted from: mossVG/mova/diffusion/models/wan_audio_dit.py # SPDX-License-Identifier: Apache-2.0 # # NOTE: This module reuses common functions from mova_video_dit.py to reduce # code duplication. Audio-specific precompute_freqs_cis_1d is kept here. import math from typing import Any, Optional, Tuple imp...
253
9,370
sglang
python/sglang/multimodal_gen/runtime/models/dits/hunyuan3d.py
.py
# Copied and adapted from: https://github.com/Tencent-Hunyuan/Hunyuan3D-2 from __future__ import annotations import math from dataclasses import dataclass from typing import Optional, Tuple import torch import torch.nn as nn import torch.nn.functional as F from sglang.multimodal_gen.configs.models.dits.hunyuan3d imp...
615
21,234
sglang
python/sglang/multimodal_gen/runtime/models/dits/hunyuanvideo.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 from typing import Any import numpy as np import torch import torch.nn as nn from sglang.kernels.ops.diffusion.bitexact_gate import ( BitExactFusionGate, tensors_equal, ) from sglang.kernels.ops.diffusio...
1,278
42,194
sglang
python/sglang/multimodal_gen/runtime/models/dits/lingbot_video_moe.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import math from typing import Any, Iterable, Iterator, Optional import torch import torch.nn.functional as F from diffusers.models.embeddings import TimestepEmbedding, Timesteps from torch import nn from sglang.multimodal_gen.configs.models.d...
580
21,647
sglang
python/sglang/multimodal_gen/runtime/models/dits/base.py
.py
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo # SPDX-License-Identifier: Apache-2.0 from abc import ABC, abstractmethod from typing import Any import torch from torch import nn from sglang.multimodal_gen.configs.models.dits.base import DiTArchConfig, DiTConfig # NOTE: SpectrumMixin lives in run...
152
5,782
sglang
python/sglang/multimodal_gen/runtime/models/dits/sana_video.py
.py
# Copyright 2025 The HuggingFace Team and SANA-Video Team. # SPDX-License-Identifier: Apache-2.0 """Native SGLang implementation of the SANA-Video 3D transformer.""" import math import torch import torch.nn as nn import torch.nn.functional as F from diffusers.models.embeddings import PixArtAlphaTextProjection from s...
514
19,343
sglang
python/sglang/multimodal_gen/runtime/models/dits/hunyuan3d_paint.py
.py
# SPDX-License-Identifier: Apache-2.0 """Native multi-view UNet used by Hunyuan3D Paint.""" from __future__ import annotations import copy from typing import Any import torch from einops import rearrange from torch import nn from sglang.multimodal_gen.runtime.managers.memory_managers.layerwise_offload import ( ...
387
14,467
sglang
python/sglang/multimodal_gen/runtime/models/vlas/pi05_policy.py
.py
# SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import json import os from dataclasses import dataclass, field from pathlib import Path from typing import Any, Iterator import torch from safetensors import safe_open from torch import nn from torch.distributed.fsdp import MixedPrecisionPolicy...
1,177
44,429
sglang
python/sglang/multimodal_gen/runtime/models/vlas/pi05_core.py
.py
# SPDX-License-Identifier: Apache-2.0 # Adapted from OpenPI and LeRobot Pi0.5 PyTorch inference semantics. from __future__ import annotations import math from dataclasses import dataclass from typing import Any, Literal import torch import torch.nn.functional as F from torch import Tensor, nn from transformers.model...
1,533
57,322
sglang
python/sglang/multimodal_gen/runtime/models/vlas/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 from sglang.multimodal_gen.runtime.models.vlas.pi05_policy import Pi05PolicyModel __all__ = ["Pi05PolicyModel"]
6
152
sglang
python/sglang/multimodal_gen/runtime/models/bridges/__init__.py
.py
# SPDX-License-Identifier: Apache-2.0 from sglang.multimodal_gen.runtime.models.bridges.mova_dual_tower import ( DualTowerConditionalBridge, ) __all__ = ["DualTowerConditionalBridge"]
8
190
sglang
python/sglang/multimodal_gen/runtime/models/bridges/mova_dual_tower.py
.py
# SPDX-License-Identifier: Apache-2.0 # Copied and adapted from: mossVG/mova/diffusion/models/interactionv2.py from typing import Any, Dict, List, Optional, Tuple import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from sglang.multimodal_gen.configs.models.bridges.mova_du...
679
25,603
sglang
python/sglang/multimodal_gen/runtime/models/decoders/ltx_2_5_diffusion_decoder.py
.py
# SPDX-License-Identifier: Apache-2.0 """LTX-2.5 diffusion video decoder. An alternative to the convolutional VAE decoder: stages 1-4 deterministically upsample the latent into a context volume, and stage 5 denoises patchified pixels conditioned on it. As shipped (`model_output_type="x0"`, one step) that single predic...
1,024
41,093
sglang
python/sglang/multimodal_gen/runtime/models/vocoder/ltx_2_vocoder.py
.py
import math from abc import ABC from contextlib import nullcontext from typing import Tuple import einops import torch import torch.nn as nn import torch.nn.functional as F from sglang.multimodal_gen.configs.models.vocoder.ltx_vocoder import LTXVocoderConfig from sglang.multimodal_gen.runtime.managers.memory_managers...
766
28,318
sglang
python/sglang/multimodal_gen/runtime/models/encoders/mistral_3.py
.py
# coding=utf-8 # Copyright 2025 HuggingFace Inc. team. All rights reserved. # # # 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 req...
749
26,044
sglang
python/sglang/multimodal_gen/runtime/models/encoders/minimax_h3_qwen3vl.py
.py
# SPDX-License-Identifier: Apache-2.0 """Native, TP-foldable Qwen3-VL layer-50 encoder for MiniMax H3.""" from __future__ import annotations import re from collections.abc import Iterable from typing import Any import torch import torch.nn as nn from sglang.multimodal_gen.configs.models.encoders.base import BaseEnc...
208
8,280