[Rebase] Rebase to vllm v0.24.0 (#4709)

This commit is contained in:
Zhou Taichang authored and GitHub committed 2026-06-30 19:41:06 +08:00
1 parent 9a105bf90d
commit a560ed184d
60 files changed
+789 -203

No files matched your search

@@ -18,7 +18,6 @@ from vllm.config.load import LoadConfig
from vllm.logger import init_logger
from vllm.model_executor.layers.quantization.base_config import QuantizeMethodBase
from vllm.model_executor.model_loader.weight_utils import (
download_gguf,
download_safetensors_index_file_from_hf,
download_weights_from_hf,
filter_duplicate_safetensors_files,
@@ -42,6 +41,39 @@ from vllm_omni.diffusion.models.diffusers_adapter.pipeline_diffusers_adapter imp
from vllm_omni.diffusion.offloader.module_collector import ModuleDiscovery
from vllm_omni.diffusion.registry import initialize_model
# download_gguf was removed from upstream vLLM (commit 6635279d8).
# Inlined from the last upstream version before the GGUF plugin migration.
def download_gguf(
repo_id: str,
quant_type: str,
cache_dir: str | None = None,
revision: str | None = None,
ignore_patterns: str | list[str] | None = None,
) -> str:
allow_patterns = [
f"*-{quant_type}.gguf",
f"*-{quant_type}-*.gguf",
f"*/*-{quant_type}.gguf",
f"*/*-{quant_type}-*.gguf",
]
folder = download_weights_from_hf(
model_name_or_path=repo_id,
cache_dir=cache_dir,
allow_patterns=allow_patterns,
revision=revision,
ignore_patterns=ignore_patterns,
)
local_files: list[str] = []
for pattern in allow_patterns:
glob_pattern = os.path.join(folder, pattern)
local_files.extend(glob.glob(glob_pattern))
if not local_files:
raise ValueError(f"Downloaded GGUF files not found in {folder} for quant_type {quant_type}")
local_files.sort(key=lambda x: (x.count("-"), x))
return local_files[0]
logger = init_logger(__name__)
@@ -6,10 +6,18 @@ from collections.abc import Generator
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
import gguf
import numpy as np
import torch
try:
import gguf
except ImportError:
# Optional dependency: only required for GGUF-quantized diffusion models.
# Keep this import lazy so a missing ``gguf`` does not break importing the
# diffusion model loader (and thus inspection/loading of every other
# diffusion model that imports through this package).
gguf = None
if TYPE_CHECKING:
from vllm_omni.diffusion.data import OmniDiffusionConfig
from vllm_omni.diffusion.model_loader.diffusers_loader import (
@@ -65,6 +73,11 @@ def gguf_quant_weights_iterator(gguf_file: str) -> Generator[tuple[str, torch.Te
layer with different quant types.
"""
if gguf is None:
raise ImportError(
"The 'gguf' package is required to load GGUF-quantized diffusion models. "
"Install it with `pip install gguf`."
)
reader = gguf.GGUFReader(gguf_file)
for tensor in reader.tensors:
@@ -53,7 +53,6 @@ from vllm_omni.diffusion.models.dreamzero.utils import (
)
from vllm_omni.diffusion.models.schedulers.scheduling_flow_unipc_multistep import FlowUniPCMultistepScheduler
from vllm_omni.diffusion.worker.request_batch import DiffusionRequestBatch
from vllm_omni.platforms import current_omni_platform
logger = logging.getLogger(__name__)
MAX_DREAMZERO_SESSIONS = 64
@@ -487,10 +486,12 @@ class DreamZeroPipeline(nn.Module, CFGParallelMixin):
latents: tuple[torch.Tensor, torch.Tensor],
do_true_cfg: bool,
) -> tuple[torch.Tensor, torch.Tensor]:
"""Post-step sync: .contiguous() + platform synchronize."""
"""Post-step sync: .contiguous() + cuda.synchronize()"""
latents = tuple(t.contiguous() for t in latents)
if do_true_cfg and get_classifier_free_guidance_world_size() > 1:
current_omni_platform.synchronize()
device = next((t.device for t in latents if t.is_cuda), None)
if device is not None:
torch.cuda.current_stream(device).synchronize()
return latents
# -----------------------------------------------------------------------
@@ -284,10 +284,17 @@ class HeliosPipeline(
) -> DiffusionRequestState:
"""Initialize Helios request state for chunk-wise step execution."""
del kwargs
req = OmniDiffusionRequest(
prompt=state.prompt,
sampling_params=state.sampling,
request_id=state.request_id,
# Wrap the single request in a DiffusionRequestBatch so the batch
# compatibility properties (`prompts`, etc.) used below are available;
# OmniDiffusionRequest itself only exposes a singular `prompt`.
req = DiffusionRequestBatch(
requests=[
OmniDiffusionRequest(
prompt=state.prompt,
sampling_params=state.sampling,
request_id=state.request_id,
)
]
)
extra = getattr(state.sampling, "extra_args", {}) or {}
@@ -1282,10 +1282,14 @@ class LTX2TwoStagesPipeline(nn.Module, SupportsComponentDiscovery):
self.pipe.scheduler = new_scheduler
# We only want to change num_inference_steps here, so no need
# to deep copy the whole request
# to deep copy the whole request. `req` is a DiffusionRequestBatch
# whose `sampling_params` is a read-only property, so clone the
# underlying request(s) and override their sampling params instead.
stage_2_req = copy.copy(req)
stage_2_req.sampling_params = req.sampling_params.clone()
stage_2_req.sampling_params.num_inference_steps = 3
stage_2_req.requests = [copy.copy(r) for r in req.requests]
for stage_2_request in stage_2_req.requests:
stage_2_request.sampling_params = stage_2_request.sampling_params.clone()
stage_2_request.sampling_params.num_inference_steps = 3
stage2_output = self.pipe(
req=stage_2_req,
@@ -870,9 +870,14 @@ class LTX2ImageToVideoTwoStagesPipeline(nn.Module, SupportsComponentDiscovery):
)
self.pipe.scheduler = new_scheduler
# `req` is a DiffusionRequestBatch whose `sampling_params` is a
# read-only property; clone the underlying request(s) and override
# their sampling params instead of assigning to the batch.
stage_2_req = copy.copy(req)
stage_2_req.sampling_params = req.sampling_params.clone()
stage_2_req.sampling_params.num_inference_steps = 3
stage_2_req.requests = [copy.copy(r) for r in req.requests]
for stage_2_request in stage_2_req.requests:
stage_2_request.sampling_params = stage_2_request.sampling_params.clone()
stage_2_request.sampling_params.num_inference_steps = 3
stage2_output = self.pipe(
req=stage_2_req,
+4 -4
View File
@@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""HSDP/FSDP2 compatibility for online FP8 quantization.
vllm's ``Fp8OnlineLinearMethod.process_weights_after_loading`` ends with
vllm's ``Fp8LinearMethod.process_weights_after_loading`` ends with
``layer.weight = qweight.t()`` so that the Cutlass FP8 GEMM kernel sees its
B operand as column-major ``[K, N]`` (the TN layout required by Hopper FP8
``wgmma`` instructions). The resulting tensor is a non-contiguous transpose
@@ -32,7 +32,7 @@ import types
from torch import nn
from vllm.logger import init_logger
from vllm.model_executor.layers.quantization.fp8 import Fp8OnlineLinearMethod
from vllm.model_executor.layers.quantization.fp8 import Fp8LinearMethod
logger = init_logger(__name__)
@@ -55,7 +55,7 @@ def _build_transposed_get_layer_params(original_bound_method):
def prepare_fp8_layers_for_fsdp(model: nn.Module) -> int:
"""Make online-FP8 linear layers in ``model`` FSDP2-compatible.
For every layer whose ``quant_method`` is an :class:`Fp8OnlineLinearMethod`
For every layer whose ``quant_method`` is an :class:`Fp8LinearMethod`
and whose weight is currently a non-contiguous transpose view, this
function:
@@ -76,7 +76,7 @@ def prepare_fp8_layers_for_fsdp(model: nn.Module) -> int:
patched_kernel_ids: set[int] = set()
for module in model.modules():
qm = getattr(module, "quant_method", None)
if not isinstance(qm, Fp8OnlineLinearMethod):
if not isinstance(qm, Fp8LinearMethod):
continue
weight = getattr(module, "weight", None)
@@ -81,6 +81,10 @@ class _DiffusionVllmModelConfig:
def is_nvfp4_quantized(self) -> bool:
return self.quantization == "modelopt_fp4"
@property
def is_diffusion(self) -> bool:
return False
def _make_diffusion_vllm_model_config(od_config: OmniDiffusionConfig) -> _DiffusionVllmModelConfig:
quant_config = getattr(od_config, "quantization_config", None)