[BugFix][Cosmos3] Register opt-in T2I pipeline so deploy-config applies (#7971)
Signed-off-by: NumberWan <wantszkin2003@gmail.com>
This commit is contained in:
1 parent
7a8d956ece
commit
7650020618
6 files changed
+193
-24
No files matched your search
@@ -694,6 +694,105 @@ class TestCosmos3PolicyPipeline:
|
||||
assert stage.engine_args.model_config.policy_server_config.action_space == "joint_position"
|
||||
|
||||
|
||||
class TestCosmos3OmniDeployPipeline:
|
||||
"""Omni deploy yaml selects an opt-in topology so --deploy-config applies (#6874)."""
|
||||
|
||||
def test_registered_without_auto_capturing_cosmos3_omni(self):
|
||||
assert "cosmos3_omni_deploy" in OMNI_PIPELINES
|
||||
# Same shared HF metadata as policy: must not register cosmos3_omni for
|
||||
# auto-detect, or T2I/video/policy would collide.
|
||||
assert "cosmos3_omni" not in OMNI_PIPELINES
|
||||
pipeline = OMNI_PIPELINES["cosmos3_omni_deploy"]
|
||||
assert pipeline.hf_architectures == ()
|
||||
assert pipeline.diffusers_class_name is None
|
||||
# Align with CLI Cosmos3OmniDiffusersPipeline default (video), not T2I-only.
|
||||
assert pipeline.stages[0].final_output_type == "video"
|
||||
|
||||
def test_deploy_yaml_applies_guardrails_false(self):
|
||||
deploy = load_deploy_config(get_deploy_config_path("cosmos3_omni.yaml"))
|
||||
assert deploy.pipeline == "cosmos3_omni_deploy"
|
||||
assert deploy.stages[0].devices is None
|
||||
|
||||
stages = merge_pipeline_deploy(OMNI_PIPELINES["cosmos3_omni_deploy"], deploy)
|
||||
assert len(stages) == 1
|
||||
stage = stages[0].to_omegaconf()
|
||||
|
||||
assert stage.stage_type == "diffusion"
|
||||
assert stage.final_output_type == "video"
|
||||
assert stage.engine_args.model_class_name == "Cosmos3OmniDiffusersPipeline"
|
||||
assert stage.engine_args.model_config.guardrails is False
|
||||
assert "devices" not in stage.runtime
|
||||
|
||||
def test_deploy_yaml_accepts_documented_multi_gpu_cli(self):
|
||||
from vllm_omni.engine.stage_init_utils import _check_stage_device_layout
|
||||
|
||||
deploy = load_deploy_config(get_deploy_config_path("cosmos3_omni.yaml"))
|
||||
stages, _ = StageConfigFactory._create_legacy_from_registry(
|
||||
OMNI_PIPELINES["cosmos3_omni_deploy"],
|
||||
{
|
||||
"cfg_parallel_size": 2,
|
||||
"use_hsdp": True,
|
||||
"hsdp_shard_size": 2,
|
||||
},
|
||||
user_deploy_config=deploy,
|
||||
)
|
||||
assert len(stages) == 1
|
||||
omega = stages[0].to_omegaconf()
|
||||
assert omega.engine_args.model_config.guardrails is False
|
||||
assert omega.engine_args.parallel_config.cfg_parallel_size == 2
|
||||
assert omega.engine_args.parallel_config.use_hsdp is True
|
||||
assert omega.engine_args.parallel_config.hsdp_shard_size == 2
|
||||
assert "devices" not in omega.runtime
|
||||
_check_stage_device_layout(omega, dict(omega.engine_args))
|
||||
|
||||
def test_get_pipeline_config_honours_deploy_yaml_pipeline_key(self):
|
||||
deploy_path = get_deploy_config_path("cosmos3_omni.yaml")
|
||||
# No HF download: explicit pipeline: key is highest priority.
|
||||
pipeline = StageConfigFactory.get_pipeline_config(
|
||||
model="nvidia/Cosmos3-Super-Text2Image",
|
||||
trust_remote_code=True,
|
||||
deploy_config_path=deploy_path,
|
||||
)
|
||||
assert pipeline is not None
|
||||
assert pipeline.model_type == "cosmos3_omni_deploy"
|
||||
|
||||
def test_without_deploy_yaml_stays_on_unregistered_fallback(self):
|
||||
# Shared HF metadata must not auto-select a pipeline; only the deploy
|
||||
# yaml ``pipeline:`` key selects cosmos3_omni_deploy and merges guardrails.
|
||||
assert "cosmos3_omni" not in OMNI_PIPELINES
|
||||
|
||||
class FakeCosmos3Config(PretrainedConfig):
|
||||
model_type = "cosmos3_omni"
|
||||
|
||||
fake_config = FakeCosmos3Config()
|
||||
fake_config.architectures = ["Cosmos3OmniDiffusersPipeline"]
|
||||
model = "nvidia/Cosmos3-Super-Text2Image"
|
||||
deploy_path = get_deploy_config_path("cosmos3_omni.yaml")
|
||||
|
||||
StageConfigFactory.get_hf_config.cache_clear()
|
||||
StageConfigFactory.try_infer_model_type.cache_clear()
|
||||
with patch("vllm_omni.config.config_factory.get_config", return_value=fake_config):
|
||||
assert (
|
||||
StageConfigFactory.get_pipeline_config(
|
||||
model=model,
|
||||
trust_remote_code=True,
|
||||
deploy_config_path=None,
|
||||
)
|
||||
is None
|
||||
)
|
||||
|
||||
pipeline = StageConfigFactory.get_pipeline_config(
|
||||
model=model,
|
||||
trust_remote_code=True,
|
||||
deploy_config_path=deploy_path,
|
||||
)
|
||||
assert pipeline is not None
|
||||
assert pipeline.model_type == "cosmos3_omni_deploy"
|
||||
|
||||
stages = merge_pipeline_deploy(pipeline, load_deploy_config(deploy_path))
|
||||
assert stages[0].to_omegaconf().engine_args.model_config.guardrails is False
|
||||
|
||||
|
||||
class TestStagePipelineConfig:
|
||||
def test_frozen(self):
|
||||
s = StagePipelineConfig(stage_id=0, model_stage="a")
|
||||
|
||||
Reference in new issue
Block a user