[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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user