[Config] Read stage metadata from VllmOmniConfig (#5343)
Signed-off-by: Acerak01-fy <wfy2003324@163.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
e108cbb510
commit
4dd1b47f47
8 files changed
+256
-19
No files matched your search
@@ -1347,7 +1347,10 @@ def launch_headless_diffusion_replicas(
|
||||
stage_id,
|
||||
)
|
||||
|
||||
metadata = stage_init_utils.extract_stage_metadata(stage_cfg)
|
||||
# Headless diffusion startup and its downstream helpers still consume the
|
||||
# legacy StageConfig shape; switch this with the coordinated RFC #4021
|
||||
# stage-init cutover.
|
||||
metadata = stage_init_utils.extract_legacy_stage_metadata(stage_cfg)
|
||||
if omni_conn_cfg:
|
||||
inject_omni_kv_config(stage_cfg, omni_conn_cfg, omni_from, omni_to)
|
||||
# Headless single-stage launch must still infer cross-stage TP topology
|
||||
|
||||
@@ -25,6 +25,8 @@ from vllm.usage.usage_lib import UsageContext
|
||||
from vllm.v1.engine.input_processor import InputProcessor
|
||||
from vllm.v1.executor import Executor
|
||||
|
||||
from vllm_omni.config.omni_config import BaseVllmOmniStageConfig
|
||||
from vllm_omni.config.stage_config import StageType
|
||||
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
||||
from vllm_omni.engine.arg_utils import OmniEngineArgs
|
||||
from vllm_omni.entrypoints.stage_utils import _to_dict, set_stage_devices
|
||||
@@ -346,8 +348,12 @@ class StageMetadata:
|
||||
replica_id: int = 0
|
||||
|
||||
|
||||
def extract_stage_metadata(stage_config: Any) -> StageMetadata:
|
||||
"""Pure data extraction from a stage_config object."""
|
||||
def extract_legacy_stage_metadata(stage_config: Any) -> StageMetadata:
|
||||
"""Extract metadata through the active production legacy path.
|
||||
|
||||
Keep production callers on this path until RFC #4021 migrates the
|
||||
engine-argument and stage-init consumers together.
|
||||
"""
|
||||
stage_id: int = stage_config.stage_id
|
||||
stage_type: Literal["llm", "diffusion"] = _get_attr_or_item(stage_config, "stage_type", "llm")
|
||||
engine_args = stage_config.engine_args
|
||||
@@ -432,6 +438,68 @@ def extract_stage_metadata(stage_config: Any) -> StageMetadata:
|
||||
)
|
||||
|
||||
|
||||
def extract_stage_metadata(stage_config: Any) -> StageMetadata:
|
||||
"""Preserve the legacy one-argument API for external callers."""
|
||||
return extract_legacy_stage_metadata(stage_config)
|
||||
|
||||
|
||||
def _resolve_omni_metadata_hook(path: str | None) -> Callable | None:
|
||||
if not path:
|
||||
return None
|
||||
module_path, function_name = path.rsplit(".", 1)
|
||||
return getattr(importlib.import_module(module_path), function_name)
|
||||
|
||||
|
||||
def extract_stage_metadata_from_omni_stage_config(
|
||||
stage_config: BaseVllmOmniStageConfig,
|
||||
) -> StageMetadata:
|
||||
"""Project one typed stage config into metadata for a future cutover.
|
||||
|
||||
This projection is not used by production startup yet. Current replica
|
||||
layout, engine-argument, remote-diffusion, and platform setup paths still
|
||||
require the legacy StageConfig/OmegaConf shape.
|
||||
"""
|
||||
stage_type: Literal["llm", "diffusion"] = "diffusion" if stage_config.stage_type == StageType.DIFFUSION else "llm"
|
||||
sampling_params_cls = SamplingParams if stage_type == "llm" else OmniDiffusionSamplingParams
|
||||
sampling_params: OmniSamplingParams = sampling_params_cls(
|
||||
**(stage_config.model_config.default_sampling_params or {})
|
||||
)
|
||||
custom_process_input_func = _resolve_omni_metadata_hook(stage_config.custom_process_input_func)
|
||||
|
||||
if stage_type == "diffusion":
|
||||
return StageMetadata(
|
||||
stage_id=stage_config.stage_id,
|
||||
stage_type="diffusion",
|
||||
engine_output_type=None,
|
||||
is_comprehension=False,
|
||||
requires_multimodal_data=False,
|
||||
engine_input_source=stage_config.input_sources,
|
||||
final_output=stage_config.final_output,
|
||||
final_output_type=stage_config.final_output_type,
|
||||
default_sampling_params=sampling_params,
|
||||
custom_process_input_func=custom_process_input_func,
|
||||
model_stage=stage_config.model_stage,
|
||||
runtime_cfg=stage_config.runtime_config,
|
||||
cfg_kv_collect_func=_resolve_omni_metadata_hook(stage_config.cfg_kv_collect_func),
|
||||
)
|
||||
|
||||
return StageMetadata(
|
||||
stage_id=stage_config.stage_id,
|
||||
stage_type="llm",
|
||||
engine_output_type=stage_config.engine_output_type,
|
||||
is_comprehension=stage_config.is_comprehension,
|
||||
requires_multimodal_data=stage_config.requires_multimodal_data,
|
||||
engine_input_source=stage_config.input_sources,
|
||||
final_output=stage_config.final_output,
|
||||
final_output_type=stage_config.final_output_type,
|
||||
default_sampling_params=sampling_params,
|
||||
custom_process_input_func=custom_process_input_func,
|
||||
model_stage=stage_config.model_stage,
|
||||
runtime_cfg=stage_config.runtime_config,
|
||||
prompt_expand_func=_resolve_omni_metadata_hook(stage_config.prompt_expand_func),
|
||||
)
|
||||
|
||||
|
||||
def prepare_engine_environment() -> None:
|
||||
"""One-time global setup: load plugins, set multiprocessing spawn method."""
|
||||
from vllm_omni.plugins import load_omni_general_plugins
|
||||
|
||||
@@ -51,7 +51,7 @@ from vllm_omni.engine.stage_init_utils import (
|
||||
build_llm_stage_output_processor,
|
||||
build_vllm_config,
|
||||
compute_replica_layout,
|
||||
extract_stage_metadata,
|
||||
extract_legacy_stage_metadata,
|
||||
get_stage_connector_spec,
|
||||
inject_kv_stage_info,
|
||||
inject_omni_kv_connector_config,
|
||||
@@ -339,8 +339,12 @@ class StageRuntime:
|
||||
"""Build startup plans for every logical stage and replica."""
|
||||
stage_plans: list[LogicalStageInitPlan] = []
|
||||
|
||||
# RFC #4021 transition boundary: stage planning still relies on legacy
|
||||
# StageConfig.runtime and StageConfig.engine_args for replica and engine
|
||||
# setup. Keep metadata extraction on the legacy path until the
|
||||
# coordinated stage-init cutover.
|
||||
for stage_idx, stage_cfg in enumerate(self._stage_configs):
|
||||
base_metadata = extract_stage_metadata(stage_cfg)
|
||||
base_metadata = extract_legacy_stage_metadata(stage_cfg)
|
||||
stage_id = int(base_metadata.stage_id)
|
||||
if stage_id != stage_idx:
|
||||
raise ValueError(
|
||||
@@ -392,7 +396,7 @@ class StageRuntime:
|
||||
if stage_idx in replica_devices_map:
|
||||
replica_cfg.runtime.devices = replica_devices_map[stage_idx][replica_id]
|
||||
|
||||
replica_metadata = extract_stage_metadata(replica_cfg)
|
||||
replica_metadata = extract_legacy_stage_metadata(replica_cfg)
|
||||
replica_metadata.replica_id = replica_id
|
||||
if launch_mode == "remote" and replica_metadata.stage_type != "diffusion":
|
||||
replica_metadata.runtime_cfg = None
|
||||
@@ -865,8 +869,10 @@ class DistStageRuntime(StageRuntime):
|
||||
if registered_stage_cfg is None:
|
||||
raise ValueError(f"Remote stage {plan.metadata.stage_id} registered without stage config")
|
||||
|
||||
# Remote diffusion registration still transports the legacy mapping
|
||||
# shape. Reconstruct and project that shape until its RFC #4021 cutover.
|
||||
metadata = (
|
||||
extract_stage_metadata(OmegaConf.create(registered_stage_cfg))
|
||||
extract_legacy_stage_metadata(OmegaConf.create(registered_stage_cfg))
|
||||
if plan.metadata.stage_type == "diffusion"
|
||||
else copy.deepcopy(plan.metadata)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user