[Core] Retain structured configs through runtime startup (#6849)
Signed-off-by: maithilijoshi20 <97733343+maithilijoshi20@users.noreply.github.com>
This commit is contained in:
1 parent
becfefd440
commit
f1a6e7ce2a
49 files changed
+1856
-331
No files matched your search
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Apply declarative parallel strategies onto merged stage configs.
|
||||
|
||||
This is the *override-after-merge* seam. ``merge_pipeline_deploy`` first fuses
|
||||
@@ -198,10 +198,41 @@ def _check_devices(runtime: dict[str, Any], cfg: OmniParallelConfig, *, role: Ro
|
||||
|
||||
|
||||
def _apply_to_stage(stage: Any, cfg: OmniParallelConfig, *, role: RoleKey) -> None:
|
||||
declared = set(cfg.l1_owners.keys())
|
||||
if hasattr(stage, "parallel_config") and hasattr(stage, "runtime_config"):
|
||||
parallel = stage.parallel_config
|
||||
for kind, field_name in _ENGINE_FIELD_BY_KIND.items():
|
||||
if kind in declared:
|
||||
existing = getattr(parallel, field_name, None)
|
||||
value = getattr(cfg, field_name)
|
||||
if existing not in (None, 1, value):
|
||||
_fail(
|
||||
f"role {role!r}: strategy derives {field_name}={value} "
|
||||
f"but structured config already set {existing}"
|
||||
)
|
||||
setattr(parallel, field_name, value)
|
||||
if "ep" in declared and cfg.enable_expert_parallel:
|
||||
setattr(parallel, "enable_expert_parallel", True)
|
||||
if "stage_replica" in declared:
|
||||
existing = stage.runtime_config.num_replicas
|
||||
if existing not in (None, 1, cfg.stage_replica_size):
|
||||
_fail(
|
||||
f"role {role!r}: strategy derives "
|
||||
f"num_replicas={cfg.stage_replica_size} but structured config already set {existing}"
|
||||
)
|
||||
stage.runtime_config.num_replicas = cfg.stage_replica_size
|
||||
check_device_layout(
|
||||
stage.runtime_config.devices,
|
||||
tensor_parallel_size=cfg.tensor_parallel_size,
|
||||
data_parallel_size=cfg.data_parallel_size,
|
||||
pipeline_parallel_size=cfg.pipeline_parallel_size,
|
||||
num_replicas=int(stage.runtime_config.num_replicas or 1),
|
||||
role=role,
|
||||
)
|
||||
return
|
||||
|
||||
engine_args = stage.yaml_engine_args
|
||||
runtime = stage.yaml_runtime
|
||||
|
||||
declared = set(cfg.l1_owners.keys())
|
||||
for kind, field_name in _ENGINE_FIELD_BY_KIND.items():
|
||||
if kind in declared:
|
||||
_set_explicit(engine_args, field_name, getattr(cfg, field_name), role=role)
|
||||
@@ -209,7 +240,6 @@ def _apply_to_stage(stage: Any, cfg: OmniParallelConfig, *, role: RoleKey) -> No
|
||||
_set_explicit(engine_args, "enable_expert_parallel", True, role=role)
|
||||
if "stage_replica" in declared:
|
||||
_set_num_replicas(runtime, cfg.stage_replica_size, role=role)
|
||||
|
||||
_check_devices(runtime, cfg, role=role)
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ from vllm_omni.config.stage_config import (
|
||||
DeployConfig,
|
||||
PipelineConfig,
|
||||
StageConfig,
|
||||
StageDeployConfig,
|
||||
StageExecutionType,
|
||||
StagePipelineConfig,
|
||||
StageType,
|
||||
build_stage_runtime_overrides,
|
||||
load_deploy_config,
|
||||
@@ -373,6 +376,7 @@ class StageConfigFactory:
|
||||
trust_remote_code: bool | None,
|
||||
cli_overrides: dict[str, Any],
|
||||
deploy_config_path: str | None,
|
||||
strategy_specs: Mapping[Any, Any] | None = None,
|
||||
) -> VllmOmniConfig | None:
|
||||
"""Build the structured Omni config for a model/deploy pair."""
|
||||
user_deploy_config = cls._load_user_deploy_config(deploy_config_path)
|
||||
@@ -387,6 +391,20 @@ class StageConfigFactory:
|
||||
if pipeline_cfg is None:
|
||||
return None
|
||||
|
||||
# Keep the typed representation's topology in lockstep with the
|
||||
# compatibility launch representation. The aligner is a real extra
|
||||
# stage, not an engine-only setting, so it must be injected before
|
||||
# either representation is built.
|
||||
if user_deploy_config is None:
|
||||
if pipeline_cfg.default_deploy_config_name is not None:
|
||||
default_deploy_path = _DEPLOY_DIR / pipeline_cfg.default_deploy_config_name
|
||||
user_deploy_config = load_deploy_config(default_deploy_path)
|
||||
deploy_config_path = str(default_deploy_path)
|
||||
else:
|
||||
user_deploy_config = DeployConfig()
|
||||
from vllm_omni.utils.forced_aligner import inject_forced_aligner_stage
|
||||
|
||||
pipeline_cfg, user_deploy_config = inject_forced_aligner_stage(pipeline_cfg, user_deploy_config, cli_overrides)
|
||||
registry_cli_overrides = with_trust_remote_code_override(
|
||||
{**cli_overrides, "model": model},
|
||||
trust_remote_code,
|
||||
@@ -396,6 +414,7 @@ class StageConfigFactory:
|
||||
user_deploy_config=user_deploy_config,
|
||||
deploy_config_path=deploy_config_path,
|
||||
cli_overrides=registry_cli_overrides,
|
||||
strategy_specs=strategy_specs,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -621,13 +640,11 @@ class StageConfigFactory:
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def create_default_diffusion(cls, kwargs: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
"""Build the temporary runtime ABI for a generic diffusion stage.
|
||||
|
||||
The terminal diffusion config owns engine defaults and normalization;
|
||||
this compatibility builder only adds Omni stage topology, request
|
||||
defaults, and device placement.
|
||||
"""
|
||||
def _normalize_default_diffusion(
|
||||
cls,
|
||||
kwargs: dict[str, Any],
|
||||
) -> tuple[dict[str, Any], DiffusionParallelConfig, dict[str, Any], str]:
|
||||
"""Normalize inputs shared by typed and compatibility diffusion builders."""
|
||||
raw_sampling_params = kwargs.get("default_sampling_params")
|
||||
if isinstance(raw_sampling_params, str):
|
||||
try:
|
||||
@@ -643,8 +660,6 @@ class StageConfigFactory:
|
||||
if kwargs.get("num_gpus") is not None:
|
||||
parallel_config.resolve_data_parallel_size(int(kwargs["num_gpus"]))
|
||||
engine_args = OmniDiffusionConfig.normalize_init_kwargs(kwargs)
|
||||
engine_args["parallel_config"] = asdict(parallel_config)
|
||||
engine_args["model_stage"] = "diffusion"
|
||||
|
||||
extras = dict(engine_args.get("extras") or {})
|
||||
for key, default in (
|
||||
@@ -665,6 +680,21 @@ class StageConfigFactory:
|
||||
final_output_type,
|
||||
model_class_name,
|
||||
)
|
||||
return engine_args, parallel_config, default_sampling_params, final_output_type
|
||||
|
||||
@classmethod
|
||||
def create_default_diffusion(cls, kwargs: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
"""Build the temporary runtime ABI for a generic diffusion stage.
|
||||
|
||||
The terminal diffusion config owns engine defaults and normalization;
|
||||
this compatibility builder only adds Omni stage topology, request
|
||||
defaults, and device placement.
|
||||
"""
|
||||
engine_args, parallel_config, default_sampling_params, final_output_type = cls._normalize_default_diffusion(
|
||||
kwargs
|
||||
)
|
||||
engine_args["parallel_config"] = asdict(parallel_config)
|
||||
engine_args["model_stage"] = "diffusion"
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -681,6 +711,50 @@ class StageConfigFactory:
|
||||
}
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def create_typed_default_diffusion(
|
||||
cls,
|
||||
model: str,
|
||||
kwargs: dict[str, Any],
|
||||
) -> VllmOmniConfig:
|
||||
"""Build generic diffusion directly into the structured runtime config."""
|
||||
engine_overrides, parallel_config, default_sampling_params, final_output_type = (
|
||||
cls._normalize_default_diffusion(kwargs)
|
||||
)
|
||||
engine_overrides.update(asdict(parallel_config))
|
||||
model_class_name = engine_overrides.get("model_class_name")
|
||||
pipeline = PipelineConfig(
|
||||
model_type="generic_diffusion",
|
||||
model_arch=str(model_class_name or ""),
|
||||
stages=(
|
||||
StagePipelineConfig(
|
||||
stage_id=0,
|
||||
model_stage="diffusion",
|
||||
execution_type=StageExecutionType.DIFFUSION,
|
||||
final_output=True,
|
||||
final_output_type=final_output_type,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
# These values have already been normalized for this diffusion stage.
|
||||
# Scope them explicitly so diffusion-only fields such as engine_backend
|
||||
# and extras are not filtered by the global LLM CLI argument surface.
|
||||
stage_overrides = {
|
||||
f"stage_0_{key}": value for key, value in engine_overrides.items() if key not in {"model", "stage_id"}
|
||||
}
|
||||
stage_overrides["stage_0_devices"] = (
|
||||
kwargs.get("stage_0_devices")
|
||||
or kwargs.get("devices")
|
||||
or ",".join(str(i) for i in range(parallel_config.world_size))
|
||||
)
|
||||
# Caller defaults belong to deployment, not immutable pipeline constraints:
|
||||
# explicit request sampling parameters must still be able to override them.
|
||||
deploy = DeployConfig(stages=[StageDeployConfig(stage_id=0, default_sampling_params=default_sampling_params)])
|
||||
return VllmOmniConfig.from_pipeline_config(
|
||||
pipeline, user_deploy_config=deploy, cli_overrides={"model": model, **stage_overrides}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _merge_cli_overrides(
|
||||
cls,
|
||||
|
||||
@@ -29,7 +29,9 @@ from vllm.config import ProfilerConfig as VllmProfilerConfig
|
||||
from vllm.config import SchedulerConfig as VllmSchedulerConfig
|
||||
from vllm.config.utils import config
|
||||
from vllm.engine.arg_utils import EngineArgs as VllmEngineArgs
|
||||
from vllm.logger import init_logger
|
||||
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
|
||||
from vllm.pooling_params import PoolingParams
|
||||
|
||||
from vllm_omni.config.stage_config import (
|
||||
_DEPLOY_DIR,
|
||||
@@ -42,11 +44,13 @@ from vllm_omni.config.stage_config import (
|
||||
StagePipelineConfig,
|
||||
StageType,
|
||||
_apply_platform_overrides,
|
||||
_get_recursively_merged_dict,
|
||||
_resolve_scheduler,
|
||||
_scheduler_path,
|
||||
_select_processor_funcs,
|
||||
build_stage_runtime_overrides,
|
||||
load_deploy_config,
|
||||
merge_pipeline_deploy,
|
||||
merge_sampling_constraints,
|
||||
normalize_pipeline_cli_overrides,
|
||||
reconcile_diffusion_attention_overrides,
|
||||
@@ -55,6 +59,8 @@ from vllm_omni.config.stage_config import (
|
||||
)
|
||||
from vllm_omni.diffusion.diffusion_kv.config import DiffusionKVCacheMode
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
_EXECUTION_TYPE_TO_STAGE_WORKER: dict[StageExecutionType, tuple[StageType, str | None]] = {
|
||||
StageExecutionType.LLM_AR: (StageType.LLM, "ar"),
|
||||
StageExecutionType.LLM_GENERATION: (StageType.LLM, "generation"),
|
||||
@@ -186,6 +192,11 @@ class _ModelEngineOverrides(TypedDict, total=False):
|
||||
enable_prompt_embeds: bool
|
||||
|
||||
|
||||
class _PoolingEngineOverrides(TypedDict, total=False):
|
||||
runner: str
|
||||
pooling_output_decoder: str
|
||||
|
||||
|
||||
class _LoadEngineOverrides(TypedDict, total=False):
|
||||
tokenizer: str
|
||||
download_dir: str
|
||||
@@ -261,6 +272,7 @@ class _StageEngineValues:
|
||||
quantization: _QuantizationEngineOverrides
|
||||
model: _ModelEngineOverrides
|
||||
load: _LoadEngineOverrides
|
||||
pooling: _PoolingEngineOverrides
|
||||
cache: _CacheEngineOverrides
|
||||
scheduler: _SchedulerEngineOverrides
|
||||
connector: _ConnectorEngineOverrides
|
||||
@@ -476,6 +488,15 @@ class OmniStageModelConfig(_TrackExplicitConfigFields):
|
||||
enable_prompt_embeds: bool | None = None
|
||||
|
||||
|
||||
@config(config=ConfigDict(arbitrary_types_allowed=True))
|
||||
class OmniStagePoolingConfig:
|
||||
"""Typed inputs owned by vLLM pooling stages."""
|
||||
|
||||
runner: str | None = None
|
||||
pooling_output_decoder: str | None = None
|
||||
default_pooling_params: PoolingParams | None = None
|
||||
|
||||
|
||||
@_enforce_keyword_only_init
|
||||
@config(kw_only=True)
|
||||
class OmniStageLoadConfig(_TrackExplicitConfigFields, VllmLoadConfig):
|
||||
@@ -833,12 +854,12 @@ class _DiffusionConfigProjection:
|
||||
from vllm_omni.diffusion.data import normalize_omni_diffusion_kwargs
|
||||
from vllm_omni.diffusion.offloader.config import parse_diffusion_offload_config
|
||||
|
||||
normalized_kwargs = normalize_omni_diffusion_kwargs(kwargs)
|
||||
config_kwargs = normalize_omni_diffusion_kwargs(kwargs)
|
||||
# Validate before stage construction while retaining the raw mapping
|
||||
# needed by dataclass/config serialization across process boundaries.
|
||||
parse_diffusion_offload_config(normalized_kwargs.get("diffusion_offload_config"))
|
||||
parse_diffusion_offload_config(config_kwargs.get("diffusion_offload_config"))
|
||||
valid_fields = {f.name for f in fields(cast(Any, cls))}
|
||||
return cls(**{k: v for k, v in normalized_kwargs.items() if k in valid_fields})
|
||||
return cls(**{k: v for k, v in config_kwargs.items() if k in valid_fields})
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
# Keep diffusion imports lazy so importing vllm_omni.config does not
|
||||
@@ -1145,6 +1166,7 @@ _MODEL_ENGINE_FIELDS = frozenset(_ModelEngineOverrides.__annotations__)
|
||||
_LOAD_ENGINE_FIELDS = frozenset(_LoadEngineOverrides.__annotations__)
|
||||
_CACHE_ENGINE_FIELDS = frozenset(_CacheEngineOverrides.__annotations__)
|
||||
_SCHEDULER_ENGINE_FIELDS = frozenset(_SchedulerEngineOverrides.__annotations__)
|
||||
_POOLING_ENGINE_FIELDS = frozenset(_PoolingEngineOverrides.__annotations__)
|
||||
_CONNECTOR_ENGINE_FIELDS = frozenset(_ConnectorEngineOverrides.__annotations__)
|
||||
_RUNTIME_ENGINE_FIELDS = frozenset(_RuntimeEngineOverrides.__annotations__)
|
||||
_DIRECT_VLLM_CONFIG_ENGINE_FIELDS = frozenset({"compilation_config", "profiler_config"})
|
||||
@@ -1175,6 +1197,7 @@ _LLM_STAGE_ENGINE_FIELDS = (
|
||||
| _LLM_CACHE_ENGINE_FIELDS
|
||||
| _LLM_SCHEDULER_ENGINE_FIELDS
|
||||
| _LLM_PARALLEL_CONFIG_ENGINE_FIELDS
|
||||
| _POOLING_ENGINE_FIELDS
|
||||
| {"parallel_config"}
|
||||
)
|
||||
_DIFFUSION_OWNED_STAGE_ENGINE_FIELDS = (
|
||||
@@ -1308,7 +1331,12 @@ def _stage_engine_values(
|
||||
if topology.execution_type == StageExecutionType.DIFFUSION:
|
||||
# Mirror StageConfig.to_omegaconf so both projections resolve alike.
|
||||
reconcile_diffusion_attention_overrides(engine, stage_cli_overrides)
|
||||
engine.update(_copy_value(stage_cli_overrides))
|
||||
for key, value in stage_cli_overrides.items():
|
||||
existing = engine.get(key)
|
||||
if key != "omni_kv_config" and isinstance(existing, dict) and isinstance(value, Mapping):
|
||||
engine[key] = _get_recursively_merged_dict(existing, dict(value))
|
||||
else:
|
||||
engine[key] = _copy_value(value)
|
||||
_validate_stage_engine_override_ownership(
|
||||
topology.stage_id,
|
||||
topology.execution_type,
|
||||
@@ -1334,6 +1362,10 @@ def _stage_engine_values(
|
||||
),
|
||||
model=cast(_ModelEngineOverrides, _select_engine_overrides(engine, _MODEL_ENGINE_FIELDS)),
|
||||
load=cast(_LoadEngineOverrides, _select_engine_overrides(engine, load_engine_fields)),
|
||||
pooling=cast(
|
||||
_PoolingEngineOverrides,
|
||||
_select_engine_overrides(engine, _POOLING_ENGINE_FIELDS),
|
||||
),
|
||||
cache=cast(_CacheEngineOverrides, _select_engine_overrides(engine, cache_engine_fields)),
|
||||
scheduler=cast(
|
||||
_SchedulerEngineOverrides,
|
||||
@@ -1406,6 +1438,7 @@ class BaseVllmOmniStageConfig:
|
||||
cache_config: OmniStageCacheConfig = field(default_factory=OmniStageCacheConfig)
|
||||
scheduler_config: OmniStageSchedulerConfig = field(default_factory=OmniStageSchedulerConfig)
|
||||
connector_config: OmniStageConnectorConfig = field(default_factory=OmniStageConnectorConfig)
|
||||
pooling_config: OmniStagePoolingConfig = field(default_factory=OmniStagePoolingConfig)
|
||||
runtime_config: OmniStageRuntimeConfig = field(default_factory=OmniStageRuntimeConfig)
|
||||
parallel_config: OmniStageParallelConfig = field(default_factory=OmniStageParallelConfig)
|
||||
compilation_config: VllmCompilationConfig | None = None
|
||||
@@ -1490,6 +1523,10 @@ class BaseVllmOmniStageConfig:
|
||||
def prompt_transform_func(self) -> str | None:
|
||||
return self.stage_pipeline_config.prompt_transform_func
|
||||
|
||||
@property
|
||||
def sampling_constraints(self) -> dict[str, Any]:
|
||||
return dict(self.stage_pipeline_config.sampling_constraints)
|
||||
|
||||
@property
|
||||
def cfg_kv_collect_func(self) -> str | None:
|
||||
return self.stage_pipeline_config.cfg_kv_collect_func
|
||||
@@ -1543,6 +1580,7 @@ def _build_common_stage_config_kwargs(
|
||||
model=model,
|
||||
),
|
||||
"load_config": _build_load_config(topology, engine.load),
|
||||
"pooling_config": _build_pooling_config(stage_deploy, engine.pooling),
|
||||
"cache_config": _build_cache_config(
|
||||
deploy,
|
||||
engine.cache,
|
||||
@@ -1756,6 +1794,20 @@ def _build_model_config(
|
||||
)
|
||||
|
||||
|
||||
def _build_pooling_config(
|
||||
stage_deploy: StageDeployConfig | None,
|
||||
engine: _PoolingEngineOverrides,
|
||||
) -> OmniStagePoolingConfig:
|
||||
default_pooling_params = None
|
||||
if stage_deploy is not None and stage_deploy.default_pooling_params:
|
||||
default_pooling_params = PoolingParams(**dict(stage_deploy.default_pooling_params))
|
||||
return cast(Any, OmniStagePoolingConfig)(
|
||||
runner=_copy_value(engine.get("runner")),
|
||||
pooling_output_decoder=_copy_value(engine.get("pooling_output_decoder")),
|
||||
default_pooling_params=default_pooling_params,
|
||||
)
|
||||
|
||||
|
||||
def _build_load_config(
|
||||
topology: StagePipelineConfig,
|
||||
engine: _LoadEngineOverrides,
|
||||
@@ -1934,6 +1986,10 @@ class VllmOmniConfig:
|
||||
pipeline_config: PipelineConfig
|
||||
stage_configs: tuple[StageConfigType, ...]
|
||||
orchestrator_config: VllmOmniOrchestratorConfig = field(default_factory=VllmOmniOrchestratorConfig)
|
||||
# Keep strategy provenance separate from the effective orchestrator value:
|
||||
# an explicit CLI policy may be present even when the strategy declares no
|
||||
# stage-replica axis.
|
||||
strategy_omni_lb_policy: str | None = None
|
||||
|
||||
def stage_by_id(self, stage_id: int) -> StageConfigType:
|
||||
for stage in self.stage_configs:
|
||||
@@ -1949,6 +2005,7 @@ class VllmOmniConfig:
|
||||
user_deploy_config: DeployConfig | None = None,
|
||||
deploy_config_path: str | None = None,
|
||||
cli_overrides: dict[str, Any] | None = None,
|
||||
strategy_specs: Mapping[Any, Any] | None = None,
|
||||
) -> VllmOmniConfig:
|
||||
"""Create a structured config from a resolved pipeline and deploy YAML."""
|
||||
if cli_overrides is None:
|
||||
@@ -1973,6 +2030,62 @@ class VllmOmniConfig:
|
||||
deploy.async_chunk = False
|
||||
_validate_async_chunk_support(pipeline_cfg, deploy)
|
||||
validate_stage_async_chunk_edges(pipeline_cfg, deploy)
|
||||
|
||||
strategy_result = None
|
||||
if strategy_specs:
|
||||
from vllm_omni.config.composable_parallel import apply_strategy_specs
|
||||
|
||||
strategy_stages = merge_pipeline_deploy(pipeline_cfg, copy.deepcopy(deploy), {})
|
||||
strategy_result = apply_strategy_specs(strategy_stages, strategy_specs)
|
||||
strategy_overrides: dict[str, Any] = {}
|
||||
axis_fields = {
|
||||
"tp": "tensor_parallel_size",
|
||||
"dp": "data_parallel_size",
|
||||
"pp": "pipeline_parallel_size",
|
||||
}
|
||||
for stage_id, parallel in strategy_result.per_stage_config.items():
|
||||
declared = set(parallel.l1_owners)
|
||||
explicit = build_stage_runtime_overrides(stage_id, cli_overrides)
|
||||
for axis, field_name in axis_fields.items():
|
||||
if axis not in declared:
|
||||
continue
|
||||
derived = getattr(parallel, field_name)
|
||||
value = explicit.get(field_name)
|
||||
if value is None:
|
||||
value = derived
|
||||
elif value != derived:
|
||||
logger.warning(
|
||||
"[composable_parallel] stage %s: CLI %s=%s overrides the "
|
||||
"strategy-derived %s=%s. The CLI value wins; remove one to avoid ambiguity.",
|
||||
stage_id,
|
||||
field_name,
|
||||
value,
|
||||
field_name,
|
||||
derived,
|
||||
)
|
||||
strategy_overrides[f"stage_{stage_id}_{field_name}"] = value
|
||||
if "ep" in declared and parallel.enable_expert_parallel:
|
||||
strategy_overrides[f"stage_{stage_id}_enable_expert_parallel"] = bool(
|
||||
explicit.get("enable_expert_parallel", True)
|
||||
)
|
||||
if "stage_replica" in declared:
|
||||
derived = parallel.stage_replica_size
|
||||
value = explicit.get("num_replicas")
|
||||
if value is None:
|
||||
value = derived
|
||||
elif value != derived:
|
||||
logger.warning(
|
||||
"[composable_parallel] stage %s: CLI num_replicas=%s overrides the "
|
||||
"strategy-derived num_replicas=%s. The CLI value wins; remove one to avoid ambiguity.",
|
||||
stage_id,
|
||||
value,
|
||||
derived,
|
||||
)
|
||||
strategy_overrides[f"stage_{stage_id}_num_replicas"] = value
|
||||
cli_overrides = {**strategy_overrides, **cli_overrides}
|
||||
if strategy_result.omni_lb_policy is not None and cli_overrides.get("omni_lb_policy") is None:
|
||||
cli_overrides["omni_lb_policy"] = strategy_result.omni_lb_policy
|
||||
|
||||
deploy_by_id = {stage.stage_id: stage for stage in deploy.stages}
|
||||
model = cli_overrides.get("model")
|
||||
|
||||
@@ -1995,6 +2108,20 @@ class VllmOmniConfig:
|
||||
)
|
||||
for topology in pipeline_cfg.stages
|
||||
)
|
||||
if strategy_result is not None:
|
||||
from vllm_omni.config.composable_parallel import check_device_layout
|
||||
|
||||
by_id = {stage.stage_id: stage for stage in stage_configs}
|
||||
for stage_id in strategy_result.per_stage_config:
|
||||
stage = by_id[stage_id]
|
||||
check_device_layout(
|
||||
stage.runtime_config.devices,
|
||||
tensor_parallel_size=stage.parallel_config.tensor_parallel_size,
|
||||
data_parallel_size=stage.parallel_config.data_parallel_size,
|
||||
pipeline_parallel_size=stage.parallel_config.pipeline_parallel_size,
|
||||
num_replicas=stage.runtime_config.num_replicas,
|
||||
role=stage.model_stage,
|
||||
)
|
||||
|
||||
orchestrator_config = cast(Any, VllmOmniOrchestratorConfig)(
|
||||
deploy_config_path=loaded_deploy_config_path,
|
||||
@@ -2004,6 +2131,7 @@ class VllmOmniConfig:
|
||||
pipeline_config=pipeline_cfg,
|
||||
stage_configs=stage_configs,
|
||||
orchestrator_config=orchestrator_config,
|
||||
strategy_omni_lb_policy=(strategy_result.omni_lb_policy if strategy_result is not None else None),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ from vllm_omni.config.config_factory import StageConfigFactory, with_trust_remot
|
||||
from vllm_omni.config.endpoint_policy import EndpointRestriction
|
||||
from vllm_omni.config.omni_config import VllmOmniConfig
|
||||
from vllm_omni.config.stage_config import PipelineConfig
|
||||
from vllm_omni.config.yaml_util import create_config
|
||||
from vllm_omni.diffusion.data import resolve_model_class_name
|
||||
from vllm_omni.diffusion.registry import DiffusionModelRegistry
|
||||
from vllm_omni.diffusion.utils.hf_utils import is_diffusion_model
|
||||
@@ -24,19 +23,10 @@ logger = init_logger(__name__)
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class OmniConfigResolution:
|
||||
"""Migration envelope returned by the production config resolver.
|
||||
|
||||
``stage_configs`` intentionally carries the current OmegaConf-compatible
|
||||
runtime ABI only until stage startup consumes ``VllmOmniConfig`` directly.
|
||||
``pipeline_config`` is the effective topology after runtime stage injection,
|
||||
so both fields always describe the same set of stages.
|
||||
It is not a stable authoring or extension API; new production callers
|
||||
should resolve through :func:`resolve_omni_config` and must not construct or
|
||||
merge this compatibility shape themselves.
|
||||
"""
|
||||
"""Canonical typed result returned by the production config resolver."""
|
||||
|
||||
config_path: str | None
|
||||
stage_configs: tuple[Any, ...] # Temporary StageConfig/OmegaConf bridge.
|
||||
stage_configs: tuple[Any, ...]
|
||||
pipeline_config: PipelineConfig | None = None
|
||||
omni_lb_policy: str | None = None
|
||||
|
||||
@@ -176,27 +166,13 @@ def _load_strategy_specs(strategy_config_path: str | None) -> Mapping[Any, Any]
|
||||
|
||||
def _build_registered_resolution(
|
||||
structured_config: VllmOmniConfig,
|
||||
*,
|
||||
cli_overrides: dict[str, Any],
|
||||
strategy_config_path: str | None,
|
||||
) -> OmniConfigResolution:
|
||||
"""Build the temporary runtime view for an already-resolved pipeline."""
|
||||
# Runtime consumers have not yet moved to typed per-stage configs. Use the
|
||||
# factory-owned compatibility bridge instead of reimplementing legacy YAML
|
||||
# discovery and merging in this resolver.
|
||||
effective_deploy_path = structured_config.orchestrator_config.deploy_config_path
|
||||
legacy_resolution = StageConfigFactory._resolve_legacy_from_registry(
|
||||
structured_config.pipeline_config,
|
||||
cli_overrides,
|
||||
effective_deploy_path,
|
||||
strategy_specs=_load_strategy_specs(strategy_config_path),
|
||||
)
|
||||
|
||||
"""Return the canonical structured runtime view for a resolved pipeline."""
|
||||
return OmniConfigResolution(
|
||||
config_path=effective_deploy_path,
|
||||
stage_configs=tuple(stage.to_omegaconf() for stage in legacy_resolution.stage_configs),
|
||||
pipeline_config=legacy_resolution.pipeline_config,
|
||||
omni_lb_policy=legacy_resolution.omni_lb_policy,
|
||||
config_path=structured_config.orchestrator_config.deploy_config_path,
|
||||
stage_configs=tuple(structured_config.stage_configs),
|
||||
pipeline_config=structured_config.pipeline_config,
|
||||
omni_lb_policy=getattr(structured_config, "strategy_omni_lb_policy", None),
|
||||
)
|
||||
|
||||
|
||||
@@ -231,18 +207,16 @@ def resolve_omni_config(
|
||||
registry_overrides = dict(normalized_overrides)
|
||||
_flatten_stage_overrides(registry_overrides, stage_overrides)
|
||||
|
||||
strategy_specs = _load_strategy_specs(strategy_config_path)
|
||||
structured_config = StageConfigFactory.create_from_model(
|
||||
model,
|
||||
trust_remote_code=trust_remote_code,
|
||||
cli_overrides=registry_overrides,
|
||||
deploy_config_path=deploy_config_path,
|
||||
strategy_specs=strategy_specs,
|
||||
)
|
||||
if structured_config is not None:
|
||||
return _build_registered_resolution(
|
||||
structured_config,
|
||||
cli_overrides=registry_overrides,
|
||||
strategy_config_path=strategy_config_path,
|
||||
)
|
||||
return _build_registered_resolution(structured_config)
|
||||
|
||||
_apply_generic_stage_overrides(normalized_overrides, stage_overrides)
|
||||
supported, model_class_name = _resolve_generic_diffusion_model_class(model, normalized_overrides)
|
||||
@@ -252,11 +226,12 @@ def resolve_omni_config(
|
||||
)
|
||||
if model_class_name is not None:
|
||||
normalized_overrides.setdefault("model_class_name", model_class_name)
|
||||
default_stages = StageConfigFactory.create_default_diffusion(normalized_overrides)
|
||||
default_config = StageConfigFactory.create_typed_default_diffusion(model, normalized_overrides)
|
||||
|
||||
return OmniConfigResolution(
|
||||
config_path=deploy_config_path,
|
||||
stage_configs=tuple(create_config(_convert_dataclasses_to_dict(default_stages))),
|
||||
stage_configs=tuple(default_config.stage_configs),
|
||||
pipeline_config=default_config.pipeline_config,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -272,7 +272,14 @@ class OmniEngineBase:
|
||||
|
||||
self.num_stages = len(self.stage_configs)
|
||||
self.async_chunk = any(
|
||||
bool(getattr(getattr(stage, "engine_args", None), "async_chunk", False)) for stage in self.stage_configs
|
||||
bool(
|
||||
getattr(
|
||||
getattr(stage, "connector_config", None),
|
||||
"async_chunk",
|
||||
getattr(getattr(stage, "engine_args", None), "async_chunk", False),
|
||||
)
|
||||
)
|
||||
for stage in self.stage_configs
|
||||
)
|
||||
self.stage_pools: list[StagePool] = []
|
||||
self.stage_clients: list[StageClient] = [] # logical-stage view for external readers
|
||||
|
||||
@@ -287,8 +287,13 @@ def check_admission(
|
||||
|
||||
|
||||
def _diffusion_utilization(replica: Any) -> float | None:
|
||||
"""Best-effort gpu_memory_utilization for a diffusion replica from raw args."""
|
||||
"""Resolve a diffusion replica's memory budget from typed or legacy config."""
|
||||
stage_cfg = getattr(replica, "stage_cfg", None)
|
||||
cache_config = getattr(stage_cfg, "cache_config", None)
|
||||
util = getattr(cache_config, "gpu_memory_utilization", None)
|
||||
if util is not None:
|
||||
return float(util)
|
||||
|
||||
engine_args = getattr(stage_cfg, "engine_args", None)
|
||||
if isinstance(engine_args, dict):
|
||||
util = engine_args.get("gpu_memory_utilization")
|
||||
|
||||
@@ -17,6 +17,7 @@ from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import msgspec
|
||||
import torch
|
||||
import zmq
|
||||
from omegaconf import OmegaConf
|
||||
from vllm.config import VllmConfig
|
||||
@@ -33,6 +34,7 @@ from vllm.v1.engine.utils import (
|
||||
)
|
||||
from vllm.v1.executor import Executor
|
||||
|
||||
from vllm_omni.config.omni_config import BaseVllmOmniStageConfig
|
||||
from vllm_omni.distributed.omni_connectors.utils import initialization
|
||||
from vllm_omni.engine import stage_init_utils
|
||||
from vllm_omni.engine.stage_init_utils import (
|
||||
@@ -67,11 +69,13 @@ def _serialize_stage_config(stage_config: Any) -> Any:
|
||||
"""Convert a stage config to msgpack-friendly builtins."""
|
||||
if stage_config is None or isinstance(stage_config, (str, bytes, int, float, bool)):
|
||||
return stage_config
|
||||
if isinstance(stage_config, torch.dtype):
|
||||
return str(stage_config).removeprefix("torch.")
|
||||
|
||||
if OmegaConf.is_config(stage_config):
|
||||
return _serialize_stage_config(OmegaConf.to_container(stage_config, resolve=True))
|
||||
|
||||
if dataclasses.is_dataclass(stage_config):
|
||||
if dataclasses.is_dataclass(stage_config) and not isinstance(stage_config, type):
|
||||
return _serialize_stage_config(dataclasses.asdict(stage_config))
|
||||
|
||||
if isinstance(stage_config, dict):
|
||||
@@ -1403,7 +1407,7 @@ def get_headless_replica_devices(
|
||||
omni_dp_size_local: int,
|
||||
) -> list[str | None]:
|
||||
"""Return per-replica device slices for a headless stage."""
|
||||
runtime_cfg = getattr(stage_cfg, "runtime", None)
|
||||
runtime_cfg = getattr(stage_cfg, "runtime_config", getattr(stage_cfg, "runtime", None))
|
||||
devices_str: str | None = None
|
||||
if runtime_cfg is not None:
|
||||
devices_str = (
|
||||
@@ -1509,10 +1513,11 @@ def launch_headless_diffusion_replicas(
|
||||
stage_id,
|
||||
)
|
||||
|
||||
# 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)
|
||||
metadata = (
|
||||
stage_init_utils.extract_stage_metadata_from_omni_stage_config(stage_cfg)
|
||||
if isinstance(stage_cfg, BaseVllmOmniStageConfig)
|
||||
else 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
|
||||
|
||||
@@ -402,6 +402,11 @@ def _tp_size_for_stage(stage_configs: Sequence[Any], stage_id: Any) -> int | Non
|
||||
for stage_cfg in stage_configs:
|
||||
if str(getattr(stage_cfg, "stage_id", None)) not in id_strs:
|
||||
continue
|
||||
if isinstance(stage_cfg, BaseVllmOmniStageConfig):
|
||||
try:
|
||||
return max(1, int(stage_cfg.parallel_config.tensor_parallel_size))
|
||||
except (TypeError, ValueError):
|
||||
return 1
|
||||
engine_args = getattr(stage_cfg, "engine_args", None)
|
||||
if engine_args is None:
|
||||
return 1
|
||||
@@ -489,11 +494,15 @@ def inject_kv_stage_info(stage_cfg: Any, stage_id: int, stage_configs: Sequence[
|
||||
rank mappings automatically.
|
||||
"""
|
||||
try:
|
||||
engine_args = stage_cfg.engine_args
|
||||
if hasattr(engine_args, "get"):
|
||||
omni_kv = engine_args.get("omni_kv_config", None)
|
||||
connector_config = getattr(stage_cfg, "connector_config", None)
|
||||
if connector_config is not None:
|
||||
omni_kv = connector_config.omni_kv_config
|
||||
else:
|
||||
omni_kv = getattr(engine_args, "omni_kv_config", None)
|
||||
engine_args = stage_cfg.engine_args
|
||||
if hasattr(engine_args, "get"):
|
||||
omni_kv = engine_args.get("omni_kv_config", None)
|
||||
else:
|
||||
omni_kv = getattr(engine_args, "omni_kv_config", None)
|
||||
|
||||
if omni_kv is None:
|
||||
return
|
||||
@@ -504,7 +513,11 @@ def inject_kv_stage_info(stage_cfg: Any, stage_id: int, stage_configs: Sequence[
|
||||
if "stage_id" not in omni_kv:
|
||||
omni_kv["stage_id"] = stage_id
|
||||
|
||||
engine_input_source = getattr(stage_cfg, "engine_input_source", None)
|
||||
engine_input_source = (
|
||||
getattr(stage_cfg, "input_sources", None)
|
||||
if connector_config is not None
|
||||
else getattr(stage_cfg, "engine_input_source", None)
|
||||
)
|
||||
if engine_input_source is not None:
|
||||
if hasattr(omni_kv, "setdefault"):
|
||||
omni_kv.setdefault("engine_input_source", list(engine_input_source))
|
||||
@@ -703,17 +716,16 @@ def _resolve_omni_metadata_hook(path: str | None) -> Callable | None:
|
||||
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.
|
||||
"""
|
||||
"""Project one typed stage config into production runtime metadata."""
|
||||
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 {})
|
||||
)
|
||||
pooling_config = stage_config.pooling_config
|
||||
if stage_type == "llm" and (pooling_config.runner or "").lower() == "pooling":
|
||||
sampling_params: OmniSamplingParams | PoolingParams = (
|
||||
copy.deepcopy(pooling_config.default_pooling_params) or PoolingParams()
|
||||
)
|
||||
else:
|
||||
sampling_params_cls = SamplingParams if stage_type == "llm" else OmniDiffusionSamplingParams
|
||||
sampling_params = 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":
|
||||
@@ -878,7 +890,9 @@ def _get_local_llm_parallel_sizes(
|
||||
unset.
|
||||
"""
|
||||
if engine_args is None:
|
||||
engine_args = getattr(stage_cfg, "engine_args", {})
|
||||
engine_args = getattr(stage_cfg, "parallel_config", None)
|
||||
if engine_args is None:
|
||||
engine_args = getattr(stage_cfg, "engine_args", {})
|
||||
tp_size = int(_get_attr_or_item(engine_args, "tensor_parallel_size", 1) or 1)
|
||||
pp_size = int(_get_attr_or_item(engine_args, "pipeline_parallel_size", 1) or 1)
|
||||
local_dp_size = _get_attr_or_item(engine_args, "data_parallel_size_local", None)
|
||||
@@ -889,9 +903,12 @@ def _get_local_llm_parallel_sizes(
|
||||
|
||||
def get_stage_devices_per_replica(stage_cfg: Any, engine_args: Any | None = None) -> int:
|
||||
"""Return the number of devices consumed by one replica of *stage_cfg*."""
|
||||
if engine_args is None:
|
||||
engine_args = getattr(stage_cfg, "engine_args", {})
|
||||
if getattr(stage_cfg, "stage_type", "llm") == "diffusion":
|
||||
typed_parallel_config = getattr(stage_cfg, "parallel_config", None)
|
||||
if typed_parallel_config is not None:
|
||||
return max(1, int(typed_parallel_config.world_size))
|
||||
if engine_args is None:
|
||||
engine_args = getattr(stage_cfg, "engine_args", {})
|
||||
parallel_config = _get_attr_or_item(engine_args, "parallel_config")
|
||||
if parallel_config is None:
|
||||
return 1
|
||||
@@ -933,7 +950,7 @@ def compute_replica_layout(
|
||||
"""
|
||||
replicas_per_stage: list[int] = []
|
||||
for stage_cfg in stage_configs:
|
||||
runtime_cfg = getattr(stage_cfg, "runtime", {})
|
||||
runtime_cfg = getattr(stage_cfg, "runtime_config", getattr(stage_cfg, "runtime", {}))
|
||||
num_replicas = int(
|
||||
runtime_cfg.get("num_replicas", 1)
|
||||
if hasattr(runtime_cfg, "get")
|
||||
@@ -948,7 +965,7 @@ def compute_replica_layout(
|
||||
num_replicas = replicas_per_stage[stage_id]
|
||||
if num_replicas <= 1:
|
||||
continue
|
||||
runtime_cfg = getattr(stage_cfg, "runtime", {})
|
||||
runtime_cfg = getattr(stage_cfg, "runtime_config", getattr(stage_cfg, "runtime", {}))
|
||||
devices_str = (
|
||||
runtime_cfg.get("devices") if hasattr(runtime_cfg, "get") else getattr(runtime_cfg, "devices", None)
|
||||
)
|
||||
@@ -1086,15 +1103,31 @@ def _project_omni_stage_engine_args(
|
||||
diffusion_stage = cast(VllmOmniDiffusionStageConfig, stage_config)
|
||||
engine_args.update(_project_omni_config_fields(diffusion_stage.diffusion_config))
|
||||
|
||||
model_excluded_fields = {
|
||||
"default_sampling_params",
|
||||
"has_sampling_extra_args",
|
||||
}
|
||||
runtime_excluded_fields = {"devices", "num_replicas", "env", "num_gpus"}
|
||||
if not is_diffusion:
|
||||
# These values configure OmniDiffusionConfig or its worker process;
|
||||
# OmniEngineArgs has no matching fields for LLM stages.
|
||||
model_excluded_fields.update(
|
||||
{
|
||||
"disable_autocast",
|
||||
"enable_multithread_weight_load",
|
||||
"num_weight_load_threads",
|
||||
}
|
||||
)
|
||||
runtime_excluded_fields.add("log_level")
|
||||
|
||||
for config, excluded_fields in (
|
||||
(
|
||||
stage_config.model_config,
|
||||
frozenset({"default_sampling_params", "has_sampling_extra_args"}),
|
||||
frozenset(model_excluded_fields),
|
||||
),
|
||||
(
|
||||
stage_config.runtime_config,
|
||||
frozenset({"devices", "num_replicas", "env", "num_gpus"})
|
||||
| (frozenset({"additional_config"}) if is_diffusion else frozenset()),
|
||||
frozenset(runtime_excluded_fields) | (frozenset({"additional_config"}) if is_diffusion else frozenset()),
|
||||
),
|
||||
):
|
||||
engine_args.update(
|
||||
@@ -1103,6 +1136,11 @@ def _project_omni_stage_engine_args(
|
||||
exclude=excluded_fields,
|
||||
)
|
||||
)
|
||||
pooling_config = stage_config.pooling_config
|
||||
if pooling_config.runner is not None:
|
||||
engine_args["runner"] = pooling_config.runner
|
||||
if pooling_config.pooling_output_decoder is not None:
|
||||
engine_args["pooling_output_decoder"] = pooling_config.pooling_output_decoder
|
||||
|
||||
if is_diffusion:
|
||||
for config, field_map in (
|
||||
@@ -1330,11 +1368,9 @@ def build_engine_args_dict(
|
||||
stage_connector_spec: dict[str, Any] | None = None,
|
||||
cli_tokenizer: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Build engine arguments through the stable production entry point.
|
||||
"""Preserve the legacy engine-argument API for compatibility callers.
|
||||
|
||||
Production inputs still use the legacy stage representation. Keep that
|
||||
compatibility choice behind this function so callers do not bind directly
|
||||
to a representation-specific implementation.
|
||||
Typed runtime stages use ``build_engine_args_dict_from_omni_stage_config``.
|
||||
"""
|
||||
return build_legacy_engine_args_dict(
|
||||
stage_config,
|
||||
@@ -1350,13 +1386,7 @@ def build_engine_args_dict_from_omni_stage_config(
|
||||
stage_connector_spec: dict[str, Any] | None = None,
|
||||
cli_tokenizer: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""Project one typed stage config into backend engine arguments.
|
||||
|
||||
This projection is prepared for the RFC #4021 stage-init cutover. Current
|
||||
production startup reaches the legacy implementation through
|
||||
``build_engine_args_dict`` while strategy and startup-plan inputs still
|
||||
use the legacy representation.
|
||||
"""
|
||||
"""Project one typed production stage config into backend engine arguments."""
|
||||
engine_args_dict = _project_omni_stage_engine_args(stage_config)
|
||||
_apply_rocm_attention_backend(engine_args_dict, stage_config.stage_type)
|
||||
return _finalize_engine_args_dict(
|
||||
@@ -1391,7 +1421,7 @@ def _check_stage_device_layout(stage_config: Any, engine_args_dict: dict[str, An
|
||||
"""
|
||||
from vllm_omni.config.composable_parallel import StrategyApplyError, check_device_layout
|
||||
|
||||
runtime = getattr(stage_config, "runtime", None)
|
||||
runtime = getattr(stage_config, "runtime_config", getattr(stage_config, "runtime", None))
|
||||
devices = _get_attr_or_item(runtime, "devices", None) if runtime is not None else None
|
||||
if devices is None:
|
||||
# No explicit placement -> vLLM assigns devices itself; nothing to check.
|
||||
@@ -1452,10 +1482,12 @@ def build_vllm_config(
|
||||
(vllm_config, executor_class)
|
||||
"""
|
||||
if engine_args_dict is None:
|
||||
engine_args_dict = build_engine_args_dict(
|
||||
stage_config,
|
||||
model,
|
||||
stage_connector_spec=stage_connector_spec,
|
||||
engine_args_dict = (
|
||||
build_engine_args_dict_from_omni_stage_config(
|
||||
stage_config, model, stage_connector_spec=stage_connector_spec
|
||||
)
|
||||
if isinstance(stage_config, BaseVllmOmniStageConfig)
|
||||
else build_engine_args_dict(stage_config, model, stage_connector_spec=stage_connector_spec)
|
||||
)
|
||||
|
||||
filtered_engine_args_dict = filter_dataclass_kwargs(OmniEngineArgs, engine_args_dict)
|
||||
@@ -1927,7 +1959,11 @@ def build_diffusion_config(
|
||||
) -> Any:
|
||||
"""Build diffusion config for a stage."""
|
||||
|
||||
engine_args_dict = build_engine_args_dict(stage_cfg, model)
|
||||
engine_args_dict = (
|
||||
build_engine_args_dict_from_omni_stage_config(stage_cfg, model)
|
||||
if isinstance(stage_cfg, BaseVllmOmniStageConfig)
|
||||
else build_engine_args_dict(stage_cfg, model)
|
||||
)
|
||||
od_config = OmniDiffusionConfig.from_kwargs(**engine_args_dict)
|
||||
|
||||
num_devices_per_stage = od_config.parallel_config.world_size
|
||||
|
||||
@@ -16,9 +16,9 @@ from dataclasses import dataclass
|
||||
from typing import Any, cast
|
||||
|
||||
import janus
|
||||
from omegaconf import OmegaConf
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.config.omni_config import BaseVllmOmniStageConfig
|
||||
from vllm_omni.distributed.omni_connectors.utils.initialization import (
|
||||
resolve_omni_kv_config_for_stage,
|
||||
)
|
||||
@@ -49,11 +49,13 @@ from vllm_omni.engine.stage_init_utils import (
|
||||
_inject_inferred_kv_tp_topology,
|
||||
acquire_device_locks,
|
||||
build_engine_args_dict,
|
||||
build_engine_args_dict_from_omni_stage_config,
|
||||
build_llm_stage_output_processor,
|
||||
build_vllm_config,
|
||||
compute_replica_layout,
|
||||
device_overlap_group_keys,
|
||||
extract_legacy_stage_metadata,
|
||||
extract_stage_metadata_from_omni_stage_config,
|
||||
get_stage_connector_spec,
|
||||
inject_kv_stage_info,
|
||||
inject_omni_kv_connector_config,
|
||||
@@ -345,12 +347,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_legacy_stage_metadata(stage_cfg)
|
||||
base_metadata = (
|
||||
extract_stage_metadata_from_omni_stage_config(stage_cfg)
|
||||
if isinstance(stage_cfg, BaseVllmOmniStageConfig)
|
||||
else extract_legacy_stage_metadata(stage_cfg)
|
||||
)
|
||||
stage_id = int(base_metadata.stage_id)
|
||||
if stage_id != stage_idx:
|
||||
raise ValueError(
|
||||
@@ -374,14 +376,20 @@ class StageRuntime:
|
||||
executor_class = None
|
||||
engine_args_dict = None
|
||||
if base_metadata.stage_type != "diffusion":
|
||||
# The stable adapter entry point still receives the same
|
||||
# legacy stage object as replica planning. Its implementation
|
||||
# switches only at the coordinated RFC #4021 cutover.
|
||||
engine_args_dict = build_engine_args_dict(
|
||||
stage_cfg,
|
||||
self._model,
|
||||
stage_connector_spec=stage_connector_spec,
|
||||
cli_tokenizer=self._tokenizer,
|
||||
engine_args_dict = (
|
||||
build_engine_args_dict_from_omni_stage_config(
|
||||
stage_cfg,
|
||||
self._model,
|
||||
stage_connector_spec=stage_connector_spec,
|
||||
cli_tokenizer=self._tokenizer,
|
||||
)
|
||||
if isinstance(stage_cfg, BaseVllmOmniStageConfig)
|
||||
else build_engine_args_dict(
|
||||
stage_cfg,
|
||||
self._model,
|
||||
stage_connector_spec=stage_connector_spec,
|
||||
cli_tokenizer=self._tokenizer,
|
||||
)
|
||||
)
|
||||
inject_omni_kv_connector_config(
|
||||
engine_args_dict,
|
||||
@@ -401,11 +409,20 @@ class StageRuntime:
|
||||
)
|
||||
|
||||
for replica_id in range(num_replicas):
|
||||
replica_cfg = copy.deepcopy(stage_cfg) if replica_id > 0 else stage_cfg
|
||||
# Keep the logical stage's device pool intact; each replica owns
|
||||
# the same config throughout planning, metadata and launch.
|
||||
replica_cfg = copy.deepcopy(stage_cfg) if num_replicas > 1 else stage_cfg
|
||||
if stage_idx in replica_devices_map:
|
||||
replica_cfg.runtime.devices = replica_devices_map[stage_idx][replica_id]
|
||||
devices = replica_devices_map[stage_idx][replica_id]
|
||||
runtime_cfg = getattr(replica_cfg, "runtime_config", getattr(replica_cfg, "runtime", None))
|
||||
if runtime_cfg is not None:
|
||||
runtime_cfg.devices = devices
|
||||
|
||||
replica_metadata = extract_legacy_stage_metadata(replica_cfg)
|
||||
replica_metadata = (
|
||||
extract_stage_metadata_from_omni_stage_config(replica_cfg)
|
||||
if isinstance(replica_cfg, BaseVllmOmniStageConfig)
|
||||
else 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
|
||||
@@ -859,17 +876,25 @@ class StageRuntime:
|
||||
raise RuntimeError("Omni KV connector requires source and destination stages")
|
||||
inject_omni_kv_config(plan.stage_cfg, omni_conn_cfg, omni_from, omni_to)
|
||||
inject_kv_stage_info(plan.stage_cfg, plan.metadata.stage_id, self._stage_configs)
|
||||
engine_args = getattr(plan.stage_cfg, "engine_args", {})
|
||||
inline_diffusion = (
|
||||
engine_args.get("inline_diffusion", False)
|
||||
if hasattr(engine_args, "get")
|
||||
else getattr(engine_args, "inline_diffusion", False)
|
||||
)
|
||||
custom_pipeline_args = (
|
||||
engine_args.get("custom_pipeline_args")
|
||||
if hasattr(engine_args, "get")
|
||||
else getattr(engine_args, "custom_pipeline_args", None)
|
||||
)
|
||||
if isinstance(plan.stage_cfg, BaseVllmOmniStageConfig):
|
||||
inline_diffusion = plan.stage_cfg.stage_pipeline_config.inline_diffusion
|
||||
custom_pipeline_args = getattr(
|
||||
getattr(plan.stage_cfg, "diffusion_config", None),
|
||||
"custom_pipeline_args",
|
||||
None,
|
||||
)
|
||||
else:
|
||||
engine_args = getattr(plan.stage_cfg, "engine_args", {})
|
||||
inline_diffusion = (
|
||||
engine_args.get("inline_diffusion", False)
|
||||
if hasattr(engine_args, "get")
|
||||
else getattr(engine_args, "inline_diffusion", False)
|
||||
)
|
||||
custom_pipeline_args = (
|
||||
engine_args.get("custom_pipeline_args")
|
||||
if hasattr(engine_args, "get")
|
||||
else getattr(engine_args, "custom_pipeline_args", None)
|
||||
)
|
||||
client, resources = launch_diffusion_stage_replica(
|
||||
model=self._model,
|
||||
stage_config=plan.stage_cfg,
|
||||
@@ -1028,7 +1053,7 @@ class DistStageRuntime(StageRuntime):
|
||||
|
||||
for idx, stage_cfg in enumerate(self._stage_configs):
|
||||
stage_id = int(getattr(stage_cfg, "stage_id", idx))
|
||||
runtime_cfg = getattr(stage_cfg, "runtime", None)
|
||||
runtime_cfg = getattr(stage_cfg, "runtime_config", getattr(stage_cfg, "runtime", None))
|
||||
if runtime_cfg is None:
|
||||
continue
|
||||
if stage_id == target_stage_id:
|
||||
@@ -1100,13 +1125,9 @@ 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_legacy_stage_metadata(OmegaConf.create(registered_stage_cfg))
|
||||
if plan.metadata.stage_type == "diffusion"
|
||||
else copy.deepcopy(plan.metadata)
|
||||
)
|
||||
# Registration is transport-only: the head-side typed plan remains
|
||||
# authoritative for metadata and topology.
|
||||
metadata = extract_stage_metadata_from_omni_stage_config(plan.stage_cfg)
|
||||
metadata.replica_id = plan.replica_id
|
||||
ctx = StageRemoteFactoryContext(
|
||||
stage_id=plan.metadata.stage_id,
|
||||
|
||||
@@ -1048,6 +1048,7 @@ def run_headless(args: TrackingNamespace) -> None:
|
||||
)
|
||||
from vllm_omni.engine.stage_init_utils import (
|
||||
build_engine_args_dict,
|
||||
build_engine_args_dict_from_omni_stage_config,
|
||||
build_vllm_config,
|
||||
get_stage_connector_spec,
|
||||
inject_omni_kv_connector_config,
|
||||
@@ -1141,21 +1142,21 @@ def run_headless(args: TrackingNamespace) -> None:
|
||||
stage_connector_spec = get_stage_connector_spec(
|
||||
omni_transfer_config=omni_transfer_config,
|
||||
stage_id=stage_id,
|
||||
async_chunk=bool(stage_cfg.engine_args.get("async_chunk", False)),
|
||||
async_chunk=bool(
|
||||
getattr(getattr(stage_cfg, "connector_config", None), "async_chunk", None)
|
||||
if hasattr(stage_cfg, "connector_config")
|
||||
else stage_cfg.engine_args.get("async_chunk", False)
|
||||
),
|
||||
)
|
||||
|
||||
# ``runtime_cfg`` is mostly inherited from the parent's
|
||||
# CUDA_VISIBLE_DEVICES; when ``--omni-dp-size-local > 1`` we additionally
|
||||
# bracket each replica's spawn below with setup_stage_devices so they
|
||||
# don't all stack on cuda:0 (see ``per_replica_devices`` above).
|
||||
# Headless startup still supplies the legacy OmegaConf stage shape through
|
||||
# the stable adapter entry point. The implementation switches only when
|
||||
# RFC #4021 threads structured stage configs through the launch plan.
|
||||
engine_args_dict = build_engine_args_dict(
|
||||
stage_cfg,
|
||||
model,
|
||||
stage_connector_spec=stage_connector_spec,
|
||||
cli_tokenizer=getattr(args, "tokenizer", None),
|
||||
engine_args_dict = (
|
||||
build_engine_args_dict_from_omni_stage_config(
|
||||
stage_cfg, model, stage_connector_spec=stage_connector_spec, cli_tokenizer=getattr(args, "tokenizer", None)
|
||||
)
|
||||
if hasattr(stage_cfg, "connector_config")
|
||||
else build_engine_args_dict(
|
||||
stage_cfg, model, stage_connector_spec=stage_connector_spec, cli_tokenizer=getattr(args, "tokenizer", None)
|
||||
)
|
||||
)
|
||||
|
||||
inject_omni_kv_connector_config(engine_args_dict, omni_kv_connector, stage_id)
|
||||
|
||||
@@ -248,10 +248,27 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
return obj.get(key, default)
|
||||
return getattr(obj, key, default)
|
||||
|
||||
@classmethod
|
||||
def _stage_model_metadata(cls, stage: Any) -> tuple[str | None, str | None]:
|
||||
"""Return ``(model_arch, model_stage)`` for typed or legacy stages."""
|
||||
model_config = cls._stage_get(stage, "model_config")
|
||||
model_arch = cls._stage_get(model_config, "model_arch")
|
||||
model_stage = cls._stage_get(stage, "model_stage")
|
||||
|
||||
topology = cls._stage_get(stage, "stage_pipeline_config")
|
||||
if model_stage is None:
|
||||
model_stage = cls._stage_get(topology, "model_stage")
|
||||
|
||||
engine_args = cls._stage_get(stage, "engine_args")
|
||||
if model_arch is None:
|
||||
model_arch = cls._stage_get(engine_args, "model_arch")
|
||||
if model_stage is None:
|
||||
model_stage = cls._stage_get(engine_args, "model_stage")
|
||||
return model_arch, model_stage
|
||||
|
||||
def _has_minicpmo45_stage(self) -> bool:
|
||||
for stage in getattr(self.engine_client, "stage_configs", []) or []:
|
||||
engine_args = self._stage_get(stage, "engine_args")
|
||||
model_arch = self._stage_get(engine_args, "model_arch")
|
||||
model_arch, _ = self._stage_model_metadata(stage)
|
||||
if model_arch == "MiniCPMO45OmniForConditionalGeneration":
|
||||
return True
|
||||
return False
|
||||
@@ -324,11 +341,10 @@ class OmniOpenAIServingChat(OpenAIServingChat, AudioMixin):
|
||||
if not hasattr(sp, "output_kind"):
|
||||
continue
|
||||
|
||||
engine_args = self._stage_get(stage, "engine_args")
|
||||
if self._stage_get(engine_args, "model_arch") != "MiniCPMO45OmniForConditionalGeneration":
|
||||
model_arch, model_stage = self._stage_model_metadata(stage)
|
||||
if model_arch != "MiniCPMO45OmniForConditionalGeneration":
|
||||
continue
|
||||
|
||||
model_stage = self._stage_get(engine_args, "model_stage")
|
||||
if model_stage == "llm":
|
||||
sp.output_kind = RequestOutputKind.FINAL_ONLY
|
||||
elif model_stage == "tts":
|
||||
|
||||
@@ -36,6 +36,7 @@ from vllm.sampling_params import RequestOutputKind, SamplingParams
|
||||
from vllm.utils import random_uuid
|
||||
from vllm.v1.engine.exceptions import EngineDeadError, EngineGenerateError
|
||||
|
||||
from vllm_omni.config.stage_config import StagePipelineConfig
|
||||
from vllm_omni.entrypoints.openai.audio_utils_mixin import AudioMixin, StreamingAudioResampler
|
||||
from vllm_omni.entrypoints.openai.protocol.audio import (
|
||||
AudioResponse,
|
||||
@@ -76,6 +77,24 @@ _SPEECH_USAGE_TOTAL_TOKENS_HEADER = "X-VLLM-OMNI-TOTAL-TOKENS"
|
||||
_SPEECH_USAGE_INPUT_TEXT_TOKENS_HEADER = "X-VLLM-OMNI-INPUT-TEXT-TOKENS"
|
||||
_SPEECH_USAGE_INPUT_AUDIO_TOKENS_HEADER = "X-VLLM-OMNI-INPUT-AUDIO-TOKENS"
|
||||
|
||||
|
||||
def _stage_speech_metadata(stage: Any) -> tuple[str | None, str | None, str | None]:
|
||||
"""Return speech routing metadata from typed or legacy stage configs."""
|
||||
topology = getattr(stage, "stage_pipeline_config", None)
|
||||
if isinstance(topology, StagePipelineConfig):
|
||||
return (
|
||||
getattr(topology, "model_stage", None),
|
||||
getattr(getattr(stage, "model_config", None), "model_arch", None),
|
||||
getattr(stage, "worker_type", None),
|
||||
)
|
||||
engine_args = getattr(stage, "engine_args", None)
|
||||
return (
|
||||
getattr(engine_args, "model_stage", None),
|
||||
getattr(engine_args, "model_arch", None),
|
||||
getattr(engine_args, "worker_type", None),
|
||||
)
|
||||
|
||||
|
||||
# TTS Configuration
|
||||
#
|
||||
# The stage-key -> model-type mapping is NOT declared here: it is derived from
|
||||
@@ -472,12 +491,13 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
"""Find and return the TTS stage config, or None if not found."""
|
||||
tts_stage_keys = all_tts_stage_keys()
|
||||
entry_stage_archs = tts_entry_stage_archs()
|
||||
all_stages = frozenset(stage.engine_args.model_stage for stage in self.engine_client.stage_configs)
|
||||
all_stages = frozenset(
|
||||
model_stage
|
||||
for stage in self.engine_client.stage_configs
|
||||
if (model_stage := _stage_speech_metadata(stage)[0]) is not None
|
||||
)
|
||||
for stage in self.engine_client.stage_configs:
|
||||
engine_args = stage.engine_args
|
||||
model_stage = engine_args.model_stage
|
||||
model_arch = getattr(engine_args, "model_arch", None)
|
||||
worker_type = getattr(engine_args, "worker_type", None)
|
||||
model_stage, model_arch, worker_type = _stage_speech_metadata(stage)
|
||||
if model_stage in tts_stage_keys:
|
||||
# Owning the stage key is not always enough: a model may be
|
||||
# speech-capable only in some deployment topologies. Ask the
|
||||
@@ -501,10 +521,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
"""
|
||||
if self._tts_stage is None:
|
||||
return None
|
||||
return detect_tts_model_type(
|
||||
getattr(self._tts_stage.engine_args, "model_stage", None),
|
||||
getattr(self._tts_stage.engine_args, "model_arch", None),
|
||||
)
|
||||
return detect_tts_model_type(*_stage_speech_metadata(self._tts_stage)[:2])
|
||||
|
||||
def _compute_max_instructions_length(self) -> int:
|
||||
"""Compute max instructions length with precedence: CLI > stage config > default.
|
||||
@@ -518,7 +535,12 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
|
||||
# 2. Try to get from TTS stage config
|
||||
if self._tts_stage is not None:
|
||||
tts_args = getattr(self._tts_stage, "tts_args", {})
|
||||
topology = getattr(self._tts_stage, "stage_pipeline_config", None)
|
||||
tts_args = (
|
||||
getattr(topology, "extras", {}).get("tts_args", {})
|
||||
if isinstance(topology, StagePipelineConfig)
|
||||
else getattr(self._tts_stage, "tts_args", {})
|
||||
)
|
||||
if "max_instructions_length" in tts_args:
|
||||
return tts_args["max_instructions_length"]
|
||||
|
||||
@@ -1896,9 +1918,7 @@ class OmniOpenAIServingSpeech(OpenAIServing, AudioMixin):
|
||||
# chat-template markers (im_start_token_id 151644). A raw-text
|
||||
# prompt produces a 1-token placeholder that crashes the talker's
|
||||
# prefill/decode handoff. Reject early with an actionable message.
|
||||
stage_names = {
|
||||
getattr(getattr(s, "engine_args", None), "model_stage", None) for s in self.engine_client.stage_configs
|
||||
}
|
||||
stage_names = {_stage_speech_metadata(s)[0] for s in self.engine_client.stage_configs}
|
||||
if "talker" in stage_names:
|
||||
raise ValueError(
|
||||
"The /v1/audio/speech endpoint is only supported for "
|
||||
|
||||
@@ -53,6 +53,30 @@ logger = init_logger(__name__)
|
||||
|
||||
_VIDEO_RESPONSE_FRAME_CONVERSION_WORKERS = 8
|
||||
|
||||
|
||||
def _config_value(config: Any, key: str, default: Any = None) -> Any:
|
||||
if isinstance(config, Mapping):
|
||||
return config.get(key, default)
|
||||
return getattr(config, key, default)
|
||||
|
||||
|
||||
def _stage_diffusion_model_class_name(stage_config: Any) -> str | None:
|
||||
"""Resolve a stage's diffusion class across typed and legacy shapes."""
|
||||
diffusion_config = _config_value(stage_config, "diffusion_config")
|
||||
model_class_name = _config_value(diffusion_config, "model_class_name")
|
||||
if model_class_name:
|
||||
return str(model_class_name)
|
||||
|
||||
model_config = _config_value(stage_config, "model_config")
|
||||
model_arch = _config_value(model_config, "model_arch") or _config_value(stage_config, "model_arch")
|
||||
if model_arch:
|
||||
return str(model_arch)
|
||||
|
||||
engine_args = _config_value(stage_config, "engine_args", {})
|
||||
model_class_name = _config_value(engine_args, "model_class_name")
|
||||
return str(model_class_name) if model_class_name else None
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
||||
|
||||
@@ -195,18 +219,7 @@ class OmniOpenAIServingVideo:
|
||||
model_class_name = getattr(od_config, "model_class_name", None)
|
||||
model_archs = [model_class_name]
|
||||
for stage_config in self.stage_configs or ():
|
||||
stage_get = (
|
||||
stage_config.get if isinstance(stage_config, Mapping) else lambda key: getattr(stage_config, key, None)
|
||||
)
|
||||
engine_args = stage_get("engine_args") or {}
|
||||
model_archs.extend(
|
||||
(
|
||||
stage_get("model_arch"),
|
||||
engine_args.get("model_class_name")
|
||||
if isinstance(engine_args, Mapping)
|
||||
else getattr(engine_args, "model_class_name", None),
|
||||
)
|
||||
)
|
||||
model_archs.append(_stage_diffusion_model_class_name(stage_config))
|
||||
metadata_capability = any(
|
||||
get_diffusion_model_metadata(model_arch).supports_mixed_reference_inputs for model_arch in model_archs
|
||||
)
|
||||
@@ -223,18 +236,7 @@ class OmniOpenAIServingVideo:
|
||||
od_config = self._resolve_diffusion_od_config()
|
||||
model_archs = [None if od_config is None else getattr(od_config, "model_class_name", None)]
|
||||
for stage_config in self.stage_configs or ():
|
||||
stage_get = (
|
||||
stage_config.get if isinstance(stage_config, Mapping) else lambda key: getattr(stage_config, key, None)
|
||||
)
|
||||
engine_args = stage_get("engine_args") or {}
|
||||
model_archs.extend(
|
||||
(
|
||||
stage_get("model_arch"),
|
||||
engine_args.get("model_class_name")
|
||||
if isinstance(engine_args, Mapping)
|
||||
else getattr(engine_args, "model_class_name", None),
|
||||
)
|
||||
)
|
||||
model_archs.append(_stage_diffusion_model_class_name(stage_config))
|
||||
|
||||
supported: set[str] = set()
|
||||
for model_arch in model_archs:
|
||||
|
||||
@@ -42,7 +42,11 @@ class AudexAdapter(ARTTSAdapter):
|
||||
|
||||
from vllm_omni.model_executor.models.audex.checkpoint import ensure_audex_snapshot
|
||||
|
||||
stage = getattr(getattr(self.ctx.server._tts_stage, "engine_args", None), "model_stage", None)
|
||||
stage_config = self.ctx.server._tts_stage
|
||||
topology = getattr(stage_config, "stage_pipeline_config", None)
|
||||
stage = getattr(topology, "model_stage", None)
|
||||
if stage is None:
|
||||
stage = getattr(getattr(stage_config, "engine_args", None), "model_stage", None)
|
||||
profile, folder = (
|
||||
("full", "checkpoint_folder_full") if stage == "audex_omni" else ("tts", "checkpoint_folder_audiogen")
|
||||
)
|
||||
|
||||
@@ -39,6 +39,21 @@ DEFAULT_TTS_LANGUAGES = frozenset(
|
||||
)
|
||||
|
||||
|
||||
def resolve_stage_model_path(engine_client: Any) -> str | None:
|
||||
"""Prefer typed stage model overrides, then legacy and served-model values."""
|
||||
stages = getattr(engine_client, "stage_configs", ()) or ()
|
||||
for stage in stages:
|
||||
model_path = getattr(getattr(stage, "model_config", None), "model", None)
|
||||
if model_path:
|
||||
return str(model_path)
|
||||
for stage in stages:
|
||||
model_path = getattr(getattr(stage, "engine_args", None), "model", None)
|
||||
if model_path:
|
||||
return str(model_path)
|
||||
model_path = getattr(engine_client, "model", None)
|
||||
return str(model_path) if model_path else None
|
||||
|
||||
|
||||
def conditioning_cache_salt(request: "OpenAICreateSpeechRequest", tts_params: dict | None = None) -> str:
|
||||
"""Stable hash of the real Stage 0 conditioning for the prefix cache.
|
||||
|
||||
|
||||
@@ -9,7 +9,12 @@ import numpy as np
|
||||
from vllm.inputs import tokens_input
|
||||
|
||||
from vllm_omni.entrypoints.openai.tts_adapters import register_tts_adapter
|
||||
from vllm_omni.entrypoints.openai.tts_adapters.base import ARTTSAdapter, PreparedRequest, apply_max_new_tokens
|
||||
from vllm_omni.entrypoints.openai.tts_adapters.base import (
|
||||
ARTTSAdapter,
|
||||
PreparedRequest,
|
||||
apply_max_new_tokens,
|
||||
resolve_stage_model_path,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm_omni.entrypoints.openai.protocol.audio import OpenAICreateSpeechRequest
|
||||
@@ -81,17 +86,7 @@ class HiggsAudioV2Adapter(ARTTSAdapter):
|
||||
|
||||
from transformers import AutoProcessor
|
||||
|
||||
model_path = None
|
||||
for stage in self.engine_client.stage_configs:
|
||||
model_path = getattr(getattr(stage, "engine_args", None), "model", None)
|
||||
if model_path:
|
||||
break
|
||||
if model_path is None:
|
||||
# Fallback: the orchestrator stores the served model id on the engine
|
||||
# itself (set by AsyncOmniEngine.__init__). Stage-level engine_args
|
||||
# may not surface ``model`` when the deploy yaml doesn't set it per
|
||||
# stage (the CLI-passed model id is the single source of truth).
|
||||
model_path = getattr(self.engine_client, "model", None)
|
||||
model_path = resolve_stage_model_path(self.engine_client)
|
||||
if model_path is None:
|
||||
raise RuntimeError("higgs_audio_v2 serving could not resolve the model path from the engine stage configs")
|
||||
processor = AutoProcessor.from_pretrained(model_path)
|
||||
|
||||
@@ -16,6 +16,7 @@ from vllm_omni.entrypoints.openai.tts_adapters.base import (
|
||||
PreparedRequest,
|
||||
apply_max_new_tokens,
|
||||
conditioning_cache_salt,
|
||||
resolve_stage_model_path,
|
||||
)
|
||||
|
||||
_REF_CODE_CACHE_MAX_ENTRIES = 256
|
||||
@@ -170,13 +171,7 @@ class HiggsAudioV3Adapter(ARTTSAdapter):
|
||||
HiggsAudioV3TokenizerAdapter,
|
||||
)
|
||||
|
||||
model_path = None
|
||||
for stage in self.engine_client.stage_configs:
|
||||
model_path = getattr(getattr(stage, "engine_args", None), "model", None)
|
||||
if model_path:
|
||||
break
|
||||
if model_path is None:
|
||||
model_path = getattr(self.engine_client, "model", None)
|
||||
model_path = resolve_stage_model_path(self.engine_client)
|
||||
if model_path is None:
|
||||
raise RuntimeError("higgs_audio_v3 serving could not resolve model path")
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
||||
|
||||
@@ -58,6 +58,7 @@ from vllm_omni.entrypoints.openai.serving_video import (
|
||||
ReferenceAudio,
|
||||
ReferenceImage,
|
||||
ReferenceVideo,
|
||||
_stage_diffusion_model_class_name,
|
||||
)
|
||||
from vllm_omni.entrypoints.openai.storage import STORAGE_MANAGER
|
||||
from vllm_omni.entrypoints.openai.stores import VIDEO_STORE
|
||||
@@ -136,10 +137,6 @@ def _config_get(config: Any, key: str, default: Any = None) -> Any:
|
||||
return getattr(config, key, default)
|
||||
|
||||
|
||||
def _stage_engine_args(stage_cfg: Any) -> Any:
|
||||
return _config_get(stage_cfg, "engine_args", {}) or {}
|
||||
|
||||
|
||||
def _diffusion_model_classes(stage_configs: list[Any] | None) -> list[type]:
|
||||
if not stage_configs:
|
||||
return []
|
||||
@@ -150,7 +147,7 @@ def _diffusion_model_classes(stage_configs: list[Any] | None) -> list[type]:
|
||||
for stage_cfg in stage_configs:
|
||||
if get_stage_type(stage_cfg) != "diffusion":
|
||||
continue
|
||||
model_class_name = _config_get(_stage_engine_args(stage_cfg), "model_class_name")
|
||||
model_class_name = _stage_diffusion_model_class_name(stage_cfg)
|
||||
if not model_class_name:
|
||||
continue
|
||||
model_cls = DiffusionModelRegistry._try_load_model_cls(model_class_name)
|
||||
|
||||
@@ -103,6 +103,14 @@ class ServingRealtimeRobotOpenPI:
|
||||
for stage_config in getattr(engine_client, "stage_configs", []) or []:
|
||||
if getattr(stage_config, "stage_type", None) != "diffusion":
|
||||
continue
|
||||
# Typed diffusion stages keep model-owned OpenPI handshake
|
||||
# metadata in diffusion_config.model_config. The out-of-process
|
||||
# head only has this stage view because full od_config lives in
|
||||
# the worker.
|
||||
diffusion_config = getattr(stage_config, "diffusion_config", None)
|
||||
model_config = getattr(diffusion_config, "model_config", None)
|
||||
if model_config is not None:
|
||||
break
|
||||
engine_args = getattr(stage_config, "engine_args", None)
|
||||
model_config = getattr(engine_args, "model_config", None)
|
||||
if model_config is not None:
|
||||
|
||||
@@ -4,18 +4,20 @@
|
||||
|
||||
|
||||
def _should_enable_profiler_endpoints(stage_configs: list | None) -> bool:
|
||||
"""Check if any stage has profiler_config set in its engine_args."""
|
||||
"""Check whether any typed or legacy stage enables a profiler."""
|
||||
if not stage_configs:
|
||||
return False
|
||||
for stage in stage_configs:
|
||||
engine_args = stage.get("engine_args") if isinstance(stage, dict) else getattr(stage, "engine_args", None)
|
||||
if engine_args is None:
|
||||
continue
|
||||
profiler_config = (
|
||||
engine_args.get("profiler_config")
|
||||
if isinstance(engine_args, dict)
|
||||
else getattr(engine_args, "profiler_config", None)
|
||||
stage.get("profiler_config") if isinstance(stage, dict) else getattr(stage, "profiler_config", None)
|
||||
)
|
||||
if profiler_config is None:
|
||||
engine_args = stage.get("engine_args") if isinstance(stage, dict) else getattr(stage, "engine_args", None)
|
||||
profiler_config = (
|
||||
engine_args.get("profiler_config")
|
||||
if isinstance(engine_args, dict)
|
||||
else getattr(engine_args, "profiler_config", None)
|
||||
)
|
||||
if profiler_config is not None:
|
||||
profiler = (
|
||||
profiler_config.get("profiler")
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
from dataclasses import asdict, is_dataclass
|
||||
from multiprocessing import shared_memory as _shm
|
||||
from typing import Any
|
||||
|
||||
@@ -274,6 +278,8 @@ def _to_dict(x: Any) -> dict[str, Any]:
|
||||
try:
|
||||
if isinstance(x, dict):
|
||||
return dict(x)
|
||||
if is_dataclass(x) and not isinstance(x, type):
|
||||
return asdict(x)
|
||||
return _omega_to_dict(x)
|
||||
except Exception:
|
||||
try:
|
||||
|
||||
@@ -18,6 +18,13 @@ logger = init_logger(__name__)
|
||||
|
||||
def inject_omni_kv_config(stage: Any, omni_conn_cfg: dict[str, Any], omni_from: str, omni_to: str) -> None:
|
||||
"""Inject connector configuration into stage engine arguments."""
|
||||
typed_connector_config = getattr(stage, "connector_config", None)
|
||||
if typed_connector_config is not None:
|
||||
omni_conf_dict = dict(typed_connector_config.omni_kv_config or {})
|
||||
omni_conf_dict.update(connector_config=omni_conn_cfg, omni_from_stage=omni_from, omni_to_stage=omni_to)
|
||||
typed_connector_config.omni_kv_config = omni_conf_dict
|
||||
return
|
||||
|
||||
# Prepare omni_kv_config dict
|
||||
omni_conf_dict = {}
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user