Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tests/config/test_omni_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,42 @@ def test_nested_stage_override_deep_merges_structured_model_config() -> None:
assert model_config["policy_server_config"]["action_space"] == "joint_position"


def test_global_model_config_override_deep_merges_structured_model_config() -> None:
Comment thread
MaciejBalaNV marked this conversation as resolved.
Resolved
pipeline = _resolve_pipeline_or_skip("cosmos3_omni_deploy")
# cosmos3_omni.yaml already ships ``guardrails: false``; flip it back to True
# (plus a nested key) so the CLI override is observable.
deploy = load_deploy_config(_DEPLOY_DIR / "cosmos3_omni.yaml")
deploy.stages[0].engine_extras["model_config"] = {
"guardrails": True,
"inference_overrides": {"history_mode": "full"},
}

baseline = VllmOmniConfig.from_pipeline_config(pipeline, user_deploy_config=deploy)
assert baseline.stage_by_id(0).diffusion_config.model_config["guardrails"] is True

# --no-guardrails emits a global (not stage-scoped) model_config override.
config = VllmOmniConfig.from_pipeline_config(
pipeline,
user_deploy_config=deploy,
cli_overrides={"model_config": {"guardrails": False}},
)

model_config = config.stage_by_id(0).diffusion_config.model_config
assert model_config["guardrails"] is False
assert model_config["inference_overrides"]["history_mode"] == "full"


def test_global_model_config_override_skips_llm_stages() -> None:
overrides = {"model_config": {"guardrails": False}}

assert "model_config" not in omni_config_module._stage_cli_overrides(
0, overrides, execution_type=StageExecutionType.LLM_AR
)
assert omni_config_module._stage_cli_overrides(0, overrides, execution_type=StageExecutionType.DIFFUSION)[
"model_config"
] == {"guardrails": False}


def _build_single_diffusion_config(
*,
cli_overrides: dict | None = None,
Expand Down
6 changes: 5 additions & 1 deletion vllm_omni/config/omni_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
_QuantizationConfigType: TypeAlias = QuantizationConfig | str | Mapping[str, Any] | None

_DIFFUSION_SHARED_ONLY_ENGINE_FIELDS = frozenset({"kv_cache_dtype", "seed"})
# Global CLI inputs that are not EngineArgs/deploy fields but still target the
# stages that own them (``--no-guardrails`` rides on ``model_config``). Stages
# that do not own them skip them silently instead of rejecting the flag.
_OWNER_ONLY_GLOBAL_STAGE_CLI_FIELDS = frozenset({"model_config"})
Comment thread
MaciejBalaNV marked this conversation as resolved.
Resolved


class _QuantizationEngineOverrides(TypedDict, total=False):
Expand Down Expand Up @@ -367,7 +371,7 @@ def _stage_cli_overrides(
**stage_scoped,
}
runtime_overrides = build_stage_runtime_overrides(stage_id, dict(cli_overrides))
global_stage_fields = _global_stage_cli_fields()
global_stage_fields = _global_stage_cli_fields() | _OWNER_ONLY_GLOBAL_STAGE_CLI_FIELDS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main point of the change.

owned_fields = None if execution_type is None else _STAGE_ENGINE_FIELDS_BY_EXECUTION_TYPE[execution_type]
result: dict[str, Any] = {}
for key, value in runtime_overrides.items():
Expand Down
Loading