[Rebase] Rebase to vllm releases/v0.22.0 (#3891)
Signed-off-by: tzhouam <tzhouam@connect.ust.hk> Signed-off-by: ZhengWG <zwg0606@gmail.com> Signed-off-by: david6666666 <530634352@qq.com> Signed-off-by: Yueqian Lin <linyueqian@outlook.com> Signed-off-by: nainiu258 <cperfect02@163.com> Signed-off-by: nainiu258 <101917677+nainiu258@users.noreply.github.com> Signed-off-by: JasonJ2021 <jasonj@zju.edu.cn> Signed-off-by: Zhou Taichang <tzhouam@connect.ust.hk> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: skf <54565339+skf-1999@users.noreply.github.com> Co-authored-by: Zheng Wengang <zwg0606@gmail.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com> Co-authored-by: WeiQing Chen <40507679+david6666666@users.noreply.github.com> Co-authored-by: SYLAR <125541396+lishunyang12@users.noreply.github.com> Co-authored-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: nainiu258 <101917677+nainiu258@users.noreply.github.com> Co-authored-by: Jason <72191212+JasonJ2021@users.noreply.github.com> Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
This commit is contained in:
62 files changed
+998
-354
No files matched your search
@@ -144,7 +144,8 @@ class OmniEngineArgs(EngineArgs):
|
||||
force_cutlass_fp8: bool | None = None
|
||||
worker_type: str | None = None
|
||||
task_type: str | None = None
|
||||
worker_cls: str = None
|
||||
worker_cls: str = None # type: ignore[assignment] # Upstream default is "auto"; omni resolves
|
||||
# in __post_init__ based on worker_type (ar/generation), so None is safe here.
|
||||
enable_sleep_mode: bool = False
|
||||
omni: bool = False
|
||||
|
||||
@@ -444,6 +445,48 @@ class OrchestratorArgs:
|
||||
# === Pre-built Objects ===
|
||||
parallel_config: Any = None
|
||||
|
||||
# === Diffusion model config ===
|
||||
num_gpus: int | None = None
|
||||
model_class_name: str | None = None
|
||||
diffusion_load_format: str | None = None
|
||||
diffusers_load_kwargs: str = "{}"
|
||||
diffusers_call_kwargs: str = "{}"
|
||||
ulysses_degree: int | None = None
|
||||
ulysses_mode: str = "strict"
|
||||
ring_degree: int | None = None
|
||||
diffusion_quantization_config: str | None = None
|
||||
use_hsdp: bool = False
|
||||
hsdp_shard_size: int = -1
|
||||
hsdp_replicate_size: int = 1
|
||||
diffusion_attention_backend: str | None = None
|
||||
diffusion_attention_config: str | None = None
|
||||
cache_backend: str = "none"
|
||||
cache_config: str | None = None
|
||||
enable_cache_dit_summary: bool = False
|
||||
step_execution: bool = False
|
||||
vae_use_slicing: bool = False
|
||||
vae_use_tiling: bool = False
|
||||
enable_multithread_weight_load: bool = True
|
||||
num_weight_load_threads: int = 4
|
||||
enable_cpu_offload: bool = False
|
||||
enable_layerwise_offload: bool = False
|
||||
boundary_ratio: float | None = None
|
||||
flow_shift: float | None = None
|
||||
diffusion_kv_cache_dtype: str | None = None
|
||||
diffusion_kv_cache_skip_steps: str | None = None
|
||||
diffusion_kv_cache_skip_layers: str | None = None
|
||||
cfg_parallel_size: int = 1
|
||||
vae_patch_parallel_size: int = 1
|
||||
default_sampling_params: str | None = None
|
||||
max_generated_image_size: int | None = None
|
||||
tts_max_instructions_length: int | None = None
|
||||
enable_diffusion_pipeline_profiler: bool = False
|
||||
enable_ar_profiler: bool = False
|
||||
auxiliary_text_encoder: str | None = None
|
||||
log_file: str | None = None
|
||||
replica_id: int | None = None
|
||||
omni_replica_address: str | None = None
|
||||
|
||||
# === Multi-stage guards ===
|
||||
# --tokenizer is captured by the orchestrator and forwarded to stages
|
||||
# only when the stage does not define tokenizer/tokenizer_subdir itself.
|
||||
@@ -459,6 +502,8 @@ SHARED_FIELDS: frozenset[str] = frozenset(
|
||||
"stage_id", # orch: route (headless); engine: identity
|
||||
"log_stats", # both want the flag
|
||||
"stage_configs_path", # orch: load legacy YAML; engine: may reference for validation
|
||||
"async_chunk", # orch: read from CLI, redistribute; engine: per-stage flag
|
||||
"tokenizer", # orch: detect model type; engine: tokenization
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -2124,7 +2124,7 @@ class AsyncOmniEngine:
|
||||
kwargs.get("diffusion_attention_config"),
|
||||
attention_backend=kwargs.get("diffusion_attention_backend"),
|
||||
)
|
||||
quantization_config = kwargs.get("quantization_config")
|
||||
quantization_config = kwargs.get("diffusion_quantization_config")
|
||||
if quantization_config is not None:
|
||||
if (
|
||||
not hasattr(cfg.engine_args, "quantization_config")
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
from vllm.logger import init_logger
|
||||
from vllm.model_executor.layers.fused_moe.routed_experts_capturer import (
|
||||
split_routed_experts,
|
||||
)
|
||||
from vllm.outputs import PoolingRequestOutput
|
||||
from vllm.sampling_params import RequestOutputKind
|
||||
from vllm.tokenizers import TokenizerLike
|
||||
@@ -172,7 +168,6 @@ class OmniRequestState(RequestState):
|
||||
finish_reason: FinishReason | None,
|
||||
stop_reason: int | str | None,
|
||||
kv_transfer_params: dict[str, Any] | None = None,
|
||||
routed_experts: np.ndarray | None = None,
|
||||
) -> OmniRequestOutput | PoolingRequestOutput | None:
|
||||
"""Create a request output from generation results.
|
||||
|
||||
@@ -199,7 +194,6 @@ class OmniRequestState(RequestState):
|
||||
finish_reason,
|
||||
stop_reason,
|
||||
kv_transfer_params,
|
||||
routed_experts,
|
||||
)
|
||||
|
||||
finished = finish_reason is not None
|
||||
@@ -234,16 +228,7 @@ class OmniRequestState(RequestState):
|
||||
|
||||
external_req_id = self.external_req_id
|
||||
|
||||
# Split routing data into prompt and generation portions, matching
|
||||
# upstream make_request_output behaviour.
|
||||
prompt_routed_experts = None
|
||||
gen_routed_experts = None
|
||||
if routed_experts is not None:
|
||||
prompt_len = len(self.prompt_token_ids) if self.prompt_token_ids else 0
|
||||
num_gen = self.detokenizer.num_output_tokens() if self.detokenizer is not None else None
|
||||
prompt_routed_experts, gen_routed_experts = split_routed_experts(routed_experts, prompt_len, num_gen)
|
||||
|
||||
output = self._new_completion_output(new_token_ids, finish_reason, stop_reason, gen_routed_experts)
|
||||
output = self._new_completion_output(new_token_ids, finish_reason, stop_reason)
|
||||
|
||||
if self.parent_req is None:
|
||||
outputs = [output]
|
||||
@@ -258,7 +243,6 @@ class OmniRequestState(RequestState):
|
||||
outputs,
|
||||
finished,
|
||||
kv_transfer_params,
|
||||
prompt_routed_experts,
|
||||
)
|
||||
|
||||
def _new_completion_output(
|
||||
@@ -266,10 +250,11 @@ class OmniRequestState(RequestState):
|
||||
token_ids: list[int],
|
||||
finish_reason: FinishReason | None,
|
||||
stop_reason: int | str | None,
|
||||
routed_experts: np.ndarray | None = None,
|
||||
) -> Any:
|
||||
# Reuse base text/logprobs logic, then annotate with pooling_result.
|
||||
base_output = super()._new_completion_output(token_ids, finish_reason, stop_reason, routed_experts)
|
||||
# Note: upstream _new_completion_output no longer accepts routed_experts
|
||||
# as a parameter; it reads from ``self.routed_experts_chunks`` internally.
|
||||
base_output = super()._new_completion_output(token_ids, finish_reason, stop_reason)
|
||||
|
||||
# Inter-stage processors need the full cumulative token sequence.
|
||||
# In DELTA mode, base_output.token_ids only has the latest step's
|
||||
|
||||
@@ -101,6 +101,11 @@ class StageEngineCoreProc(EngineCoreProc):
|
||||
set_death_signal(signal.SIGTERM)
|
||||
set_process_title(f"StageEngineCoreProc_{stage_label}_replica{omni_replica_id}_DP{dp_rank}")
|
||||
decorate_logs()
|
||||
# Workaround for flashinfer/jit-cache version mismatch in CI.
|
||||
# The parent process handles this gracefully via ring_globals.py,
|
||||
# but the subprocess hits an unprotected import in TopKTopPSampler.
|
||||
# Setting this env var allows the same graceful fallback to work.
|
||||
os.environ.setdefault("FLASHINFER_DISABLE_VERSION_CHECK", "1")
|
||||
os.environ["VLLM_OMNI_REPLICA_ID"] = str(max(int(omni_replica_id), 0))
|
||||
|
||||
engine_core = StageEngineCoreProc(
|
||||
|
||||
@@ -860,6 +860,45 @@ def build_stage0_input_processor(stage_vllm_config: Any) -> InputProcessor:
|
||||
return input_processor
|
||||
|
||||
|
||||
def _cleanup_stale_lock_if_dead(lock_file: str) -> bool:
|
||||
"""If *lock_file* exists and its recorded PID is dead, unlink the file.
|
||||
|
||||
Returns ``True`` if the stale lock was cleaned up (caller should retry),
|
||||
``False`` otherwise (lock holder appears alive, or file could not be read).
|
||||
"""
|
||||
try:
|
||||
with open(lock_file) as fh:
|
||||
content = fh.read().strip()
|
||||
if not content:
|
||||
return False
|
||||
pid = int(content)
|
||||
except (OSError, ValueError):
|
||||
return False
|
||||
|
||||
# Check whether the PID is still alive.
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except ProcessLookupError:
|
||||
# PID does not exist — stale lock.
|
||||
logger.info(
|
||||
"Removing stale device lock %s (PID %s is dead)",
|
||||
lock_file,
|
||||
pid,
|
||||
)
|
||||
try:
|
||||
os.unlink(lock_file)
|
||||
return True
|
||||
except OSError:
|
||||
logger.debug("Failed to unlink stale lock %s", lock_file)
|
||||
return False
|
||||
except PermissionError:
|
||||
# PID exists but we cannot signal it (different user) — treat as alive.
|
||||
return False
|
||||
|
||||
# PID is alive — legitimate lock holder.
|
||||
return False
|
||||
|
||||
|
||||
def acquire_device_locks(
|
||||
stage_id: int,
|
||||
engine_args_dict: dict[str, Any],
|
||||
@@ -938,6 +977,7 @@ def acquire_device_locks(
|
||||
for device_id in devices_to_lock:
|
||||
lock_file = f"/tmp/vllm_omni_device_{device_id}_init.lock"
|
||||
lock_acquired = False
|
||||
already_cleaned_stale = False # only try stale cleanup once per device
|
||||
|
||||
while not lock_acquired:
|
||||
try:
|
||||
@@ -952,6 +992,11 @@ def acquire_device_locks(
|
||||
logger.debug("Acquired exclusive lock for device %s", device_id)
|
||||
except BlockingIOError:
|
||||
os.close(lock_fd)
|
||||
# Detect and clean stale locks from dead processes.
|
||||
if not already_cleaned_stale:
|
||||
already_cleaned_stale = True
|
||||
if _cleanup_stale_lock_if_dead(lock_file):
|
||||
continue # retry flock immediately
|
||||
if time.time() - wait_start > stage_init_timeout:
|
||||
logger.warning(
|
||||
"Timeout waiting for device %s initialization lock, proceeding anyway",
|
||||
|
||||
@@ -22,6 +22,7 @@ from vllm_omni.engine.stage_client import (
|
||||
StagePoolDiffusionClient,
|
||||
StagePoolLLMClient,
|
||||
)
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams
|
||||
from vllm_omni.metrics.stats import StageRequestStats as StageRequestMetrics
|
||||
from vllm_omni.metrics.stats import StageStats
|
||||
from vllm_omni.metrics.utils import count_tokens_from_outputs
|
||||
@@ -533,6 +534,10 @@ class StagePool:
|
||||
) -> int:
|
||||
"""Submit a stage-entry request into this pool."""
|
||||
params = params_override if params_override is not None else req_state.sampling_params_list[self.stage_id]
|
||||
# Convert plain vllm SamplingParams for single-stage diffusion models
|
||||
# that receive sampling params from the user/caller directly.
|
||||
if self.stage_type == "diffusion" and not isinstance(params, OmniDiffusionSamplingParams):
|
||||
params = OmniDiffusionSamplingParams()
|
||||
submit_kwargs = dict(submit_kwargs or {})
|
||||
if self.stage_type == "diffusion":
|
||||
replica_id = await self._pick_or_select(
|
||||
@@ -593,6 +598,8 @@ class StagePool:
|
||||
) -> int:
|
||||
"""Submit a streaming update to an already admitted request."""
|
||||
params = req_state.sampling_params_list[self.stage_id]
|
||||
if self.stage_type == "diffusion" and not isinstance(params, OmniDiffusionSamplingParams):
|
||||
params = OmniDiffusionSamplingParams()
|
||||
replica_id = self.get_bound_replica_id(request_id)
|
||||
if replica_id is None or self.clients[replica_id] is None:
|
||||
replica_id = await self._pick_or_select(request_id)
|
||||
|
||||
Reference in new issue
Block a user