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/entrypoints/action/ws_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import time
import traceback
from collections.abc import Callable
from typing import Any
from fastapi import WebSocket, WebSocketDisconnect
from sglang.multimodal_gen.runtime.entrypoints.action.protocol import (
action_metadata,
infer_... | 58 | 1,882 |
sglang | python/sglang/multimodal_gen/runtime/entrypoints/cli/generate.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/entrypoints/cli/serve.py
import argparse
import dataclasses
import json
import os
from typing import cast
from sglang.multimodal_gen impo... | 251 | 8,981 |
sglang | python/sglang/multimodal_gen/runtime/entrypoints/cli/main.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/entrypoints/cli/main.py
from sglang.multimodal_gen.runtime.entrypoints.cli.cli_types import CLISubcommand
from sglang.multimodal_gen.runti... | 45 | 1,504 |
sglang | python/sglang/multimodal_gen/runtime/entrypoints/cli/utils.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import shlex
import subprocess
import sys
from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger
logger = init_logger(__name__)
class RaiseNotImplementedAction(argp... | 76 | 1,990 |
sglang | python/sglang/multimodal_gen/runtime/entrypoints/cli/cli_types.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/entrypoints/cli/types.py
import argparse
from sglang.multimodal_gen.utils import FlexibleArgumentParser
class CLISubcommand:
"""Bas... | 31 | 893 |
sglang | python/sglang/multimodal_gen/runtime/entrypoints/cli/serve.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
from typing import cast
from sglang.multimodal_gen.apps.webui import run_sgl_diffusion_webui
from sglang.multimodal_gen.runtime.entrypoints.cli.cli_types import CLISubcommand
from sglang... | 78 | 2,427 |
sglang | python/sglang/multimodal_gen/runtime/distributed/sp_shard_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Unified sequence-parallel shard / pad / gather helpers.
Layout invariant: padding always sits at the end of the LAST rank's local
chunk, so the ulysses-gathered sequence carries one contiguous pad block at its
global tail. `tail_attn_meta` then lets attention skip that block fo... | 228 | 8,249 |
sglang | python/sglang/multimodal_gen/runtime/distributed/utils.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/distributed/utils.py
# Copyright 2023 The vLLM team.
# Adapted from
# https... | 197 | 7,381 |
sglang | python/sglang/multimodal_gen/runtime/distributed/communication_op.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/distributed/communication_op.py
import torch
import torch.distributed as di... | 68 | 2,395 |
sglang | python/sglang/multimodal_gen/runtime/distributed/parallel_groups.py | .py | # Reference: https://github.com/feifeibear/long-context-attention/blob/main/yunchang/globals.py
import torch
class Singleton:
_instance = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
return cls.... | 92 | 3,210 |
sglang | python/sglang/multimodal_gen/runtime/distributed/cfg_parallel_utils.py | .py | from __future__ import annotations
import dataclasses
from typing import TYPE_CHECKING, Callable
import torch
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.distributed.cfg_policy import (
_apply_cfg_postprocess,
_unwrap,
_wrap,
)
from sgla... | 182 | 6,532 |
sglang | python/sglang/multimodal_gen/runtime/distributed/__init__.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
from sglang.multimodal_gen.runtime.distributed.communication_op import *
from sglang.multimodal_gen.runtime.distributed.group_coordinator import (
get_local_torch_device,
)
from sglang.multimodal_gen.runtime.distributed.parallel_state import (
... | 64 | 1,769 |
sglang | python/sglang/multimodal_gen/runtime/distributed/cfg_policy.py | .py | from __future__ import annotations
import dataclasses
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any
import torch
if TYPE_CHECKING:
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
@dataclass
class CFGBranch:
"""Immutable specification of one CFG b... | 160 | 5,452 |
sglang | python/sglang/multimodal_gen/runtime/distributed/group_coordinator.py | .py | # SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# Copyright 2024 xDiT team.
# Adapted from
# https://github.com/vllm-project/vllm/blob/main/vllm/distributed/parallel_state.py
# Copyright 2023 T... | 1,294 | 49,393 |
sglang | python/sglang/multimodal_gen/runtime/distributed/parallel_state.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/distributed/parallel_state.py
# Copyright 2023 The vLLM team.
# Adapted from... | 960 | 32,295 |
sglang | python/sglang/multimodal_gen/runtime/distributed/device_communicators/base_device_communicator.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/distributed/device_communicators/base_device_communicator.py
from typing im... | 347 | 13,383 |
sglang | python/sglang/multimodal_gen/runtime/distributed/device_communicators/cuda_communicator.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/distributed/device_communicators/cuda_communicator.py
import torch
from tor... | 81 | 3,101 |
sglang | python/sglang/multimodal_gen/runtime/distributed/device_communicators/pynccl.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/distributed/device_communicators/pynccl.py
# ===================== import r... | 362 | 13,673 |
sglang | python/sglang/multimodal_gen/runtime/distributed/device_communicators/ipc_a2a.py | .py | # SPDX-License-Identifier: Apache-2.0
"""CUDA-IPC transport for 2-rank Ulysses all-to-all.
Each rank maps the peer's staging buffers into its own device context
(handles are re-opened locally, so every access is same-device semantics over
NVLink) and writes its half of the exchange directly into them. Rank
synchroniza... | 338 | 13,474 |
sglang | python/sglang/multimodal_gen/runtime/distributed/device_communicators/cpu_communicator.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/main/vllm/distributed/device_communicators/cpu_communicator.py
import os
import torch... | 163 | 5,535 |
sglang | python/sglang/multimodal_gen/runtime/distributed/device_communicators/pynccl_wrapper.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/distributed/device_communicators/pynccl_wrapper.py
# This file is a pure Py... | 464 | 15,288 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/composed_pipeline_base.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Base class for composed pipelines.
This module defines the base class for pipelines that are composed of multiple stages.
"""
import os
from abc import ABC, abstractmethod
from typing import Any, Callable, It... | 1,092 | 41,254 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/__init__.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Diffusion pipelines for sglang.multimodal_gen.
This package contains diffusion pipelines for generating videos and images.
"""
from typing import cast
from sglang.multimodal_gen.registry import get_model_inf... | 94 | 3,249 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/diffusion_scheduler_utils.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from copy import deepcopy
from typing import Any
import torch
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.platforms import current_platform
def calculate_linear_shift(
im... | 86 | 2,894 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/schedule_batch.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/model_executor/forward_batch_info.py
"""
Data structures for functional pipeline processing.
This module defines the dataclas... | 482 | 17,946 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/lora_format_adapter.py | .py | from __future__ import annotations
import logging
from enum import Enum
from typing import Dict, Iterable, Mapping, Optional
import torch
from diffusers.loaders import lora_conversion_utils as lcu
logger = logging.getLogger("LoRAFormatAdapter")
class LoRAFormat(str, Enum):
"""Supported external LoRA formats be... | 570 | 19,953 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/lora_pipeline.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
import json
import os
from collections import defaultdict
from collections.abc import Hashable
from contextlib import contextmanager, nullcontext
from typing import Any
import torch
import torch.distributed as dis... | 1,194 | 49,920 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/denoising.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Denoising stage for diffusion pipelines.
"""
import gc
import inspect
import math
import time
import weakref
from collections.abc import Callable
from contextlib import contextmanager
from dataclasses import d... | 2,411 | 95,633 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/vla.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import time
from typing import Any
import numpy as np
import torch
from sglang.multimodal_gen.runtime.disaggregation.roles import RoleType
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import (
OutputBatch,
Req,
)
fr... | 508 | 17,887 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/condition_encoding.py | .py | # SPDX-License-Identifier: Apache-2.0
from collections.abc import Mapping
import torch
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.pipelines_core.stages.base import PipelineStage
from sglang.multimodal_gen.runtime.server_args import ServerArgs
clas... | 36 | 1,257 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/causal_denoising.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
from collections.abc import Callable
from contextlib import nullcontext
from dataclasses import dataclass
from typing import Any
import torch # type: ignore
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.mul... | 1,415 | 51,379 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/__init__.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Pipeline stages for diffusion models.
This package contains the various stages that can be composed to create
complete diffusion pipelines.
"""
from sglang.multimodal_gen.runtime.pipelines_core.stages.base im... | 74 | 2,513 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/dedup.py | .py | """Stage-local grouped-request dedup helpers."""
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from copy import deepcopy
from typing import TYPE_CHECKING, Any, ClassVar
import torch
if TYPE_CHECKING:
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from ... | 192 | 8,117 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/image_encoding.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Image encoding stages for I2V diffusion pipelines.
This module contains implementations of image encoding stages for diffusion pipelines.
"""
import inspect
from dataclasses import dataclass
from typing impor... | 1,117 | 43,668 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Input validation stage for diffusion pipelines.
"""
import numpy as np
import torch
import torchvision.transforms.functional as TF
from PIL import Image
from sglang.multimodal_gen.configs.pipeline_configs imp... | 478 | 20,013 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/encoding.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Encoding stage for diffusion pipelines.
"""
import torch
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.managers.memory_managers.component_mana... | 126 | 4,461 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/comfyui_latent_preparation.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
ComfyUI latent preparation stage with device mismatch fix.
This stage extends LatentPreparationStage to handle device mismatch issues
that occur when tensors are pickled and unpickled via broadcast_pyobj in
multi-GPU scenarios.
"""
import dataclasses
import torch
from sglang... | 115 | 4,591 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/text_encoding.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Prompt encoding stages for diffusion pipelines.
This module contains implementations of prompt encoding stages for diffusion pipelines.
"""
import inspect
from dataclasses import dataclass
from functools impo... | 867 | 33,726 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/timestep_preparation.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Timestep preparation stages for diffusion pipelines.
This module contains implementations of timestep preparation stages for diffusion pipelines.
"""
import inspect
from dataclasses import dataclass
from typi... | 267 | 9,803 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/latent_preparation.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Latent preparation stage for diffusion pipelines.
"""
from dataclasses import dataclass
from typing import Any
import torch
from diffusers.utils.torch_utils import randn_tensor
from sglang.multimodal_gen.run... | 380 | 13,688 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/decoding.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Decoding stage for diffusion pipelines.
"""
import weakref
import torch
import torch.nn as nn
from sglang.multimodal_gen.runtime.distributed import (
get_decode_parallel_world_size,
get_local_torch_d... | 363 | 14,117 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/base.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Base classes for pipeline stages.
This module defines the abstract base classes for pipeline stages that can be
composed to create complete diffusion pipelines.
"""
from abc import ABC, abstractmethod
from co... | 437 | 15,266 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/denoising_dmd.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
import time
import torch
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.managers.forward_context import set_forward_context
from sglang.multimodal_gen.runtime.models.schedulers.scheduli... | 227 | 9,195 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/validators.py | .py | # Copied and adapted from: https://github.com/hao-ai-lab/FastVideo
# SPDX-License-Identifier: Apache-2.0
"""
Common validators for pipeline stage verification.
This module provides reusable validation functions that can be used across
all pipeline stages for input/output verification.
"""
from collections.abc import... | 523 | 19,414 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/qwen_image.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Qwen-Image-specific progressive-resolution denoising stage.
Provides pack/unpack for Qwen-Image's patchify format and updates the RoPE
positional embeddings (freqs_cis) and image shape metadata (img_shapes) when
the latent resolution changes between progressive stages.
Qwen-I... | 168 | 5,999 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/denoising.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Progressive-resolution denoising stage.
Extends DenoisingStage with a multi-stage coarse-to-fine denoising loop:
Stage 1 runs at 1/(2^levels) of the full latent resolution.
Between stages, the latent is upsampled via the spectral method selected by
progressive_mode.
St... | 647 | 25,204 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/upsample.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
GPU-native latent upsample operations for progressive resolution growing.
All ops run entirely on GPU via torch.fft — no CPU↔GPU data movement.
Supported modes: "dct", "dct_rewind".
Each function takes a spatial latent tensor (..., H, W) and returns a 2× larger
tensor (..., 2... | 109 | 3,791 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/flux.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
FLUX.1-specific progressive-resolution denoising stage.
Provides pack/unpack for FLUX's patchify format and updates the RoPE
positional embeddings (freqs_cis) when the latent resolution changes
between progressive stages.
"""
from __future__ import annotations
import torch
... | 136 | 4,521 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/spectral_ops.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
GPU DCT-II / IDCT-II via torch.fft — no CPU↔GPU transfers.
Algorithm: Makhoul (1980) "A fast cosine transform in one and two dimensions",
adapted for PyTorch. Operates on the last two spatial dims; input can be any
shape (..., H, W).
"""
import math
import torch
# ---------... | 79 | 2,667 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/flux_2.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
FLUX.2-specific progressive-resolution denoising stage.
Provides pack/unpack for FLUX.2's simple row-major token format and updates
both batch.latent_ids and freqs_cis when the latent resolution changes
between progressive stages.
FLUX.2 latent layout (before packing):
spat... | 201 | 7,408 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/wan.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Wan video progressive-resolution denoising stage.
Extends ProgressiveDenoisingStage for the Wan T2V video model:
- Latent format: [B, C, T, H, W] (already spatial — no pack/unpack required)
- Upsample: spatial H×W dims only; T (temporal frames) is fixed across all stages
... | 188 | 7,674 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/ideogram.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Ideogram 4 progressive-resolution denoising stage.
Ideogram 4 latent layout:
packed: [B, grid_h * grid_w, in_channels] (row-major, same as FLUX.2)
spatial: [B, in_channels, grid_h, grid_w]
where grid_h = height // (patch_size * ae_scale_factor) = height // 16
gr... | 472 | 19,719 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/progressive_resolution/zimage.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Z-Image-specific progressive-resolution denoising stage.
Provides pack/unpack for Z-Image's 5-D latent format [B, C, F, H, W] and updates
the RoPE positional embeddings (freqs_cis) when the latent resolution changes
between progressive stages.
"""
from __future__ import annot... | 170 | 6,093 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/mova.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
MOVA-specific pipeline stages.
Sequence Parallelism (SP) Support:
- Video latents are sharded along the sequence dimension (T*H*W) after patchify
- Audio latents are sharded along the sequence dimension (L) after patchify
- USPAttention handles all-to-all communication interna... | 1,008 | 39,977 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/wan_ti2v.py | .py | """WAN TI2V-specific helpers shared by the generic denoising stage."""
import math
import torch
import torch.nn.functional as F
from einops import rearrange
from sglang.multimodal_gen.configs.pipeline_configs.base import ModelTaskType
from sglang.multimodal_gen.configs.pipeline_configs.wan import (
Wan2_2_TI2V_5... | 194 | 6,751 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/qwen_image_layered.py | .py | import inspect
import math
from typing import List, Optional, Union
import numpy as np
import torch
from diffusers.image_processor import VaeImageProcessor
from diffusers.utils.torch_utils import randn_tensor
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runti... | 607 | 25,355 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/helios_denoising.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Helios-specific chunked denoising stage.
Implements Stage 1 chunked denoising with multi-term memory history
and CFG Zero Star guidance. VAE decoding is handled by the standard
DecodingStage downstream.
"""
import math
import numpy as np
import torch
import torch.nn.function... | 753 | 31,780 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py | .py | import inspect
import re
import time
from copy import copy, deepcopy
from typing import Any, Iterator, List, Optional, Tuple, Union
import numpy as np
import PIL
import requests
import torch
from diffusers.image_processor import VaeImageProcessor
from diffusers.utils.torch_utils import randn_tensor
from sglang.multim... | 1,316 | 50,324 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Cosmos3 pipeline stages: image preprocess, tokenization, latent / timestep
prep, denoising, decode.
Cosmos3 has no separate text encoder — text is tokenized with Qwen2's chat
template and embedded inside the transformer's UND pathway. The same
``Cosmos3Pipeline`` serves T2V, I2... | 1,654 | 69,295 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/longlive2.py | .py | # SPDX-License-Identifier: Apache-2.0
from collections.abc import Callable
from typing import Any
import torch
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.pipelines_core.stages.causal_denoising import (
CAUSAL_BLOCK_PROMPTS_KEY,
CAUSAL_SCENE_C... | 902 | 34,861 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_guardrails.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Cosmos3 guardrail stages.
Text and video safety checks via the ``cosmos_guardrail`` package.
Install with: pip install cosmos-guardrail==0.3.1
Enabled by default when available; opt out with
``SGLANG_DISABLE_COSMOS3_GUARDRAILS=1``.
"""
from __future__ import annotations
impo... | 114 | 3,431 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/helios_decoding.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Helios-specific decoding stage.
Decodes latent chunks one at a time (matching diffusers HeliosPipeline behavior)
to avoid temporal artifacts at chunk boundaries caused by Wan VAE's causal convolutions.
"""
import torch
from sglang.multimodal_gen.runtime.pipelines_core.schedu... | 78 | 2,793 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/longcat_image.py | .py | """Prompt-rewriting stage for LongCat-Image (T2I).
`LongCatPromptRewriteStage` optionally rewrites the prompt via the native
Qwen2.5-VL encoder and sets the CPU generator for
seed reproducibility. Text encoding, latent preparation, RoPE and denoising are
all handled by the standard stages + `LongCatImagePipelineConfig... | 305 | 25,962 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/krea2.py | .py | """Krea-2 (K2) pre-processing stage: text encode + latent/timestep preparation.
Consolidates everything before the denoising loop: Qwen3-VL text encoding with
the K2 system-prompt template and 12-layer hidden-state stacking, initial noise
latent packing, and the rectified-flow timestep schedule. Produces a batch the
s... | 168 | 7,212 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ideogram.py | .py | # SPDX-License-Identifier: Apache-2.0
import math
from dataclasses import dataclass
import torch
from sglang.multimodal_gen.configs.pipeline_configs.ideogram import (
LATENT_SCALE,
LATENT_SHIFT,
)
from sglang.multimodal_gen.configs.sample.ideogram import IDEOGRAM4_PRESETS
from sglang.multimodal_gen.runtime.d... | 549 | 22,003 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/pi05_preprocess.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import Any
import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image
from transformers import AutoTokenizer
from sglang.multimodal_gen.configs.pipeline_configs.pi05 import Pi05PipelineConfig
from sglang.... | 235 | 9,141 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ernie_image_pe.py | .py | # SPDX-License-Identifier: Apache-2.0
"""
Prompt enhancement stage for ErnieImage pipeline.
"""
import json
import torch
from sglang.multimodal_gen.runtime.managers.memory_managers.component_manager import (
ComponentUse,
)
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.m... | 109 | 3,379 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/cosmos3_action.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Cosmos3 action modality helpers: domain mapping, mode constants, the
structured JSON caption, and dataset-derived action (de)normalization.
"""
import json
import math
from pathlib import Path
import numpy as np
import torch
ACTION_MODE_POLICY = "policy"
ACTION_MODE_FORWARD_D... | 202 | 6,410 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/denoising_av.py | .py | import torch
from diffusers.utils.torch_utils import randn_tensor
from sglang.multimodal_gen.configs.pipeline_configs.ltx_2 import is_ltx23_native_variant
from sglang.multimodal_gen.runtime.distributed import (
get_decode_parallel_world_size,
model_parallel_is_initialized,
)
from sglang.multimodal_gen.runtime.... | 410 | 16,179 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/denoising.py | .py | import math
from contextlib import contextmanager
from dataclasses import dataclass, field
import torch
from diffusers.utils.torch_utils import randn_tensor
from sglang.multimodal_gen.configs.pipeline_configs.ltx_2 import (
is_ltx23_native_variant,
)
from sglang.multimodal_gen.runtime.distributed import (
get... | 2,694 | 117,131 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/latent_preparation_av.py | .py | import torch
from diffusers.utils.torch_utils import randn_tensor
from sglang.multimodal_gen.configs.pipeline_configs.ltx_2 import (
is_ltx23_native_variant,
)
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
fr... | 232 | 8,999 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
"""LTX-2-specific pipeline stages"""
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.ltx_2.decoding_av import (
LTX2AVDecodingStage,
)
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.ltx_2.denoising import (
LT... | 42 | 1,402 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/decoding_av.py | .py | import torch
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.managers.memory_managers.component_manager import (
ComponentUse,
)
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import OutputBatch, Req
from sglang.multimodal_gen.runtim... | 285 | 12,203 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/duration.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Auto-duration stage for LTX-2.5.
Runs between the text connectors and latent preparation, so it can rewrite
`batch.num_frames` before any latent shape is derived from it.
"""
import torch
from sglang.multimodal_gen.runtime.managers.memory_managers.component_manager import (
... | 95 | 3,399 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/text_connector.py | .py | import torch
from sglang.multimodal_gen.runtime.managers.forward_context import set_forward_context
from sglang.multimodal_gen.runtime.managers.memory_managers.component_manager import (
ComponentUse,
)
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.p... | 112 | 4,602 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/ltx_2/upsampling.py | .py | import torch
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.managers.memory_managers.component_manager import (
ComponentUse,
)
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.pipelines_c... | 145 | 5,323 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/denoising.py | .py | # SPDX-License-Identifier: Apache-2.0
import dataclasses
import torch
from sglang.multimodal_gen.configs.pipeline_configs.joy_echo import (
JoyEchoPipelineConfig,
)
from sglang.multimodal_gen.runtime.distributed import get_sp_world_size
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
f... | 576 | 23,378 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/setup.py | .py | # SPDX-License-Identifier: Apache-2.0
"""JoyEcho pre-denoising setup stages (multi-shot session + sigma schedule)."""
from __future__ import annotations
from typing import TYPE_CHECKING
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.pipelines_core.stage... | 93 | 3,234 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
"""JoyEcho-specific pipeline stages."""
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.joy_echo.denoising import (
JoyEchoDMDDenoisingStage,
)
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.joy_echo.memory import ... | 25 | 804 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/joy_echo/memory.py | .py | # SPDX-License-Identifier: Apache-2.0
"""JoyEcho memory bank utilities and memory-related pipeline stages."""
from __future__ import annotations
import math
import random
from dataclasses import dataclass, field
from typing import Any, Literal, Optional
import numpy as np
import torch
import torchaudio
from PIL impo... | 1,016 | 36,782 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/lingbot_video_moe/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
"""LingBot-Video MoE model-specific pipeline stages."""
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.lingbot_video_moe.text_encoding import ( # noqa: F401
LingBotVideoTextEncodingStage,
)
| 7 | 266 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/lingbot_video_moe/text_encoding.py | .py | # SPDX-License-Identifier: Apache-2.0
import torch
from sglang.multimodal_gen.runtime.distributed import get_local_torch_device
from sglang.multimodal_gen.runtime.pipelines_core.schedule_batch import Req
from sglang.multimodal_gen.runtime.pipelines_core.stages.text_encoding import (
TextEncodingStage,
)
from sgla... | 153 | 6,156 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/canvas.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 keyframe target-canvas preparation.
Geometry behavior:
- auto-aspect canvases delegate to the shared adaptive v2 shape resolver;
- cover-crop: aspect-preserving max-scale LANCZOS resize + center crop,
upscaling refused unless explicitly allowed.
Both the Qwen pres... | 279 | 10,430 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 ResolvedPlan: the data-only per-request execution plan.
`minimax_h3_resolve_plan` turns a validated canonical request (see
request_validation.py) into the data-only plan consumed by stages 1-8.
Stages never branch on task names; skips must be explicit in the plan.
S... | 448 | 16,583 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/reference_encoding.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 ref2va reference-material encoding.
Encoding recipes for user-provided reference materials:
- image reference: independent 2048px short-edge resize with upscale enabled,
LANCZOS, and nearest-32 dimensions, then the SAME keyframe tokenizer recipe
as fl2va (seed-4... | 919 | 33,643 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/task_profiles.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 task profiles.
Data table driving request validation and plan resolution for the three v1
tasks (t2va / fl2va / ref2va). One row per task; stages and the request
projector consume rows instead of branching on task names.
Design summary: keyframes bind target geometr... | 290 | 10,328 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/release_metadata.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Public MiniMax H3 model-index admission contract."""
from __future__ import annotations
import math
from dataclasses import dataclass
from typing import Any, Mapping
from sglang.multimodal_gen.configs.sample.sampling_params import QUALITY_LEVELS
from sglang.multimodal_gen.run... | 212 | 8,244 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/material_io.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Request-owned material URI localization for the MiniMax H3 pipeline.
The canonical MiniMax H3 contract intentionally carries semantic URIs rather
than worker-local paths. Direct media consumers (Pillow, ffmpeg and
torchaudio) cannot consume every URI scheme in that contract, s... | 914 | 33,208 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/__init__.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3-specific pipeline stages."""
from .stages.audio_encoding import MiniMaxH3AudioEncodingStage
from .stages.decoding import MiniMaxH3DecodingStage
from .stages.denoising import MiniMaxH3DenoisingStage
from .stages.latent_preparation import MiniMaxH3LatentPreparationSta... | 22 | 785 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/constants.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
# Direct-encode text embeddings: {"positive":
# {"hidden_states": Tensor[text_len, 5120] bf16 cpu, "text_len": int}}
MINIMAX_H3_TEXT_EMBEDDINGS_EXTRA_KEY = "minimax_h3_text_embeddings"
# Direct keyframe encode: {"rows": Tensor[n_rows, 96] fp32 ... | 37 | 1,981 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_sequence.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 packed-sequence materialization from the validated workspace
builder, covering fl2va and t2va layouts.
Layout: [text L | imgvid_cond C | audio A(=t*2ch) | video_target V | pad P].
Builder rules:
- block-derived position infos, update masks, token tags, and cu_seqlens... | 503 | 19,570 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/keyframe_encoding.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 keyframe (imgvid) condition encoding.
Condition anchor row recipe:
- ``video_vae.encode_images(PIL, use_fp16_latent=True)`` under a
scoped seed-42 RNG fork — the DiagonalGaussian is SAMPLED
(use_mean=False) with seed 42, so the seed is part of
the contract, no... | 140 | 4,971 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/denoise_loop.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 cfg-distilled full denoise loop.
Per step, the positive presentation is forwarded exactly once. Video and audio
target rows chain through the Euler-eta0 update while visual and audio condition
rows stay pinned to their noised step-0 anchors.
"""
from __future__ impo... | 526 | 23,707 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/packed_tokens.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from collections.abc import Sequence
import torch
def _int_tuple(value: Sequence[int], name: str, length: int) -> tuple[int, ...]:
if len(value) != length:
raise ValueError(f"{name} must have length {length}, got {list(value)!r}")
... | 105 | 3,767 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/prequeue.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 probe -> resolve-once admission hook.
This module is intentionally data/CPU only. It localizes condition media,
caches display-geometry facts, freezes every target/material canvas, and
resolves the real aligned workload before a video job is published or sent to
the ... | 347 | 13,771 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/time_request.py | .py | # SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
def minimax_h3_align_frame_count(frame_count: int) -> int:
"""Snap ``frame_count`` up to the MiniMax H3 17n+5 frame boundary."""
if frame_count <= 0:
return 1
current = int(frame_count)
return current + (5 - current) % 17... | 60 | 1,966 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/presentation.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 Qwen presentation building.
Builds the positive presentation token stream:
- fl2va: '<Picture 1>: ' label + vision block (<|vision_start|> +
N*<|image_pad|> + <|vision_end|>) + prompt text.
- t2va: prompt text only (no vision block).
Prompt text passes through verb... | 279 | 10,355 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/request_validation.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 canonical request validation.
Entry fail-fast for `minimax_h3.request/v1`: every violation raises ValueError
with the offending field path. Output is a normalized canonical dict (frame
indices validated but semantic -1 preserved, nothing else rewritten — prompt passe... | 362 | 14,610 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/condition_noise.py | .py | # SPDX-License-Identifier: Apache-2.0
"""MiniMax H3 visual/audio condition-noise augmentation.
The request's condition timestep is applied to both the tensor value and the
DiT timestep. Tokenizer artifacts remain clean
and reusable; this module materializes the fixed noised anchors immediately
before the denoise loop.... | 195 | 7,422 |
sglang | python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/video_adapter.py | .py | # SPDX-License-Identifier: Apache-2.0
"""Video API lowering and strict delivery hooks for MiniMax H3."""
from __future__ import annotations
import json
import math
import subprocess
from concurrent.futures import ThreadPoolExecutor
from typing import TYPE_CHECKING, Any
from sglang.multimodal_gen.configs.pipeline_con... | 556 | 22,038 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.