[Feature] Transfer AR-to-diffusion payloads over NIXL (#6264)
Signed-off-by: yuanwu <yuan.wu@intel.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
8953d082c0
commit
cb5f508212
60 files changed
+4397
-641
No files matched your search
@@ -1588,19 +1588,32 @@ stages:
|
||||
assert "text_encoder_tp_size" not in stages[1].runtime_overrides
|
||||
assert stages[1].yaml_engine_args["parallel_config"]["tensor_parallel_size"] == 1
|
||||
|
||||
def test_minimax_h3_disaggregated_defaults_match_validated_topology(self):
|
||||
@pytest.mark.parametrize(
|
||||
"deploy_name",
|
||||
["minimax_h3_disaggregated.yaml", "minimax_h3_disaggregated_turbo.yaml"],
|
||||
)
|
||||
def test_minimax_h3_disaggregated_defaults(self, deploy_name):
|
||||
pipeline = OMNI_PIPELINES["minimax_h3_disaggregated"]
|
||||
deploy = load_deploy_config(Path(get_deploy_config_path("minimax_h3_disaggregated.yaml")))
|
||||
deploy = load_deploy_config(Path(get_deploy_config_path(deploy_name)))
|
||||
stages = merge_pipeline_deploy(pipeline, deploy)
|
||||
|
||||
assert pipeline.model_arch == "MiniMaxH3Encoder"
|
||||
assert stages[0].model_stage == "encoder"
|
||||
assert stages[0].yaml_engine_args["model_arch"] == "MiniMaxH3Encoder"
|
||||
processor = "vllm_omni.model_executor.stage_input_processors.minimax_h3"
|
||||
assert stages[0].yaml_extras["prompt_transform_func"] == f"{processor}.prepare_encoder_prompt"
|
||||
assert (
|
||||
stages[0].yaml_engine_args["custom_process_next_stage_input_func"]
|
||||
== f"{processor}.encoder2diffusion_full_payload"
|
||||
)
|
||||
assert stages[1].custom_process_input_func == f"{processor}.encoder2diffusion"
|
||||
assert tuple(stages[1].yaml_engine_args["stage_input_payload_keys"]) == ("encoder_output",)
|
||||
assert stages[1].yaml_engine_args["omni_kv_config"]["need_recv_cache"] is False
|
||||
assert stages[1].yaml_engine_args["model_arch"] == "MiniMaxH3Pipeline"
|
||||
assert stages[0].yaml_runtime["num_replicas"] == 1
|
||||
assert stages[1].yaml_runtime["num_replicas"] == 1
|
||||
assert stages[1].yaml_engine_args["model_loaded"] == {
|
||||
"text_encoder": False,
|
||||
"vae_encoder": False,
|
||||
}
|
||||
assert stages[1].yaml_engine_args["model_loaded"] == {"text_encoder": False, "vae_encoder": False}
|
||||
assert stages[0].yaml_engine_args["tensor_parallel_size"] == 2
|
||||
assert stages[0].yaml_engine_args["max_num_seqs"] == 1
|
||||
assert stages[0].yaml_engine_args["hf_overrides"]["minimax_h3_encoder_components"] == {
|
||||
"text_encoder": {"parallel_mode": "tp"},
|
||||
@@ -1614,7 +1627,12 @@ stages:
|
||||
assert parallel["ulysses_degree"] == 4
|
||||
assert parallel["vae_patch_parallel_size"] == 4
|
||||
assert stages[1].yaml_engine_args["inline_diffusion"] is True
|
||||
assert stages[1].yaml_extras["default_sampling_params"]["num_inference_steps"] == 50
|
||||
sampling = stages[1].yaml_extras["default_sampling_params"]
|
||||
if "turbo" in deploy_name:
|
||||
assert sampling["num_inference_steps"] == 5
|
||||
assert sampling["extra_args"] == {"flow_shift": 6.0, "audio_flow_shift": 3.0}
|
||||
else:
|
||||
assert sampling["num_inference_steps"] == 50
|
||||
|
||||
turbo = load_deploy_config(Path(get_deploy_config_path("minimax_h3_disaggregated_turbo.yaml")))
|
||||
turbo_stages = merge_pipeline_deploy(pipeline, turbo)
|
||||
@@ -1625,6 +1643,73 @@ stages:
|
||||
assert turbo_sampling["num_inference_steps"] == 5
|
||||
assert turbo_sampling["extra_args"] == {"flow_shift": 6.0, "audio_flow_shift": 3.0}
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"deploy_name",
|
||||
["minimax_h3_disaggregated.yaml", "minimax_h3_disaggregated_turbo.yaml"],
|
||||
)
|
||||
@pytest.mark.parametrize("shared_memory", [False, True], ids=["nixl", "shared_memory"])
|
||||
def test_minimax_h3_deploy_connector_wiring_and_roles(self, deploy_name, shared_memory):
|
||||
from vllm_omni.config.stage_config import resolve_deploy_yaml
|
||||
from vllm_omni.distributed.omni_connectors.utils.initialization import load_omni_transfer_config
|
||||
from vllm_omni.engine.stage_init_utils import get_stage_connector_spec
|
||||
|
||||
base_config = resolve_deploy_yaml(get_deploy_config_path(deploy_name))
|
||||
if not shared_memory:
|
||||
deploy_name = deploy_name.replace(".yaml", "_nixl.yaml")
|
||||
deploy_path = get_deploy_config_path(deploy_name)
|
||||
config = resolve_deploy_yaml(deploy_path)
|
||||
assert config["async_chunk"] is False
|
||||
connector_name = "shared_memory_connector" if shared_memory else "nixl_connector"
|
||||
assert connector_name in config["connectors"]
|
||||
assert config["stages"][0]["output_connectors"] == {"to_stage_1": connector_name}
|
||||
assert config["stages"][1]["input_connectors"] == {"from_stage_0": connector_name}
|
||||
load_deploy_config(deploy_path)
|
||||
for base_stage, stage in zip(base_config["stages"], config["stages"], strict=True):
|
||||
edge_keys = {"input_connectors", "output_connectors"}
|
||||
assert {key: value for key, value in stage.items() if key not in edge_keys} == {
|
||||
key: value for key, value in base_stage.items() if key not in edge_keys
|
||||
}
|
||||
transfer = load_omni_transfer_config(config_dict=config)
|
||||
assert transfer is not None
|
||||
assert set(transfer.connectors) == {("0", "1")}
|
||||
edge = transfer.connectors[("0", "1")]
|
||||
expected_name = "SharedMemoryConnector" if shared_memory else "NixlConnector"
|
||||
assert edge.name == expected_name
|
||||
assert "role" not in edge.extra
|
||||
for stage_id, role in ((0, "sender"), (1, "receiver")):
|
||||
spec = get_stage_connector_spec(transfer, stage_id, async_chunk=False)
|
||||
assert spec["name"] == expected_name
|
||||
assert spec["extra"]["role"] == role
|
||||
if shared_memory:
|
||||
assert "from_stage" not in spec["extra"]
|
||||
assert "to_stage" not in spec["extra"]
|
||||
else:
|
||||
assert spec["extra"]["from_stage"] == 0
|
||||
assert spec["extra"]["to_stage"] == 1
|
||||
assert spec["extra"]["host"] == "auto"
|
||||
assert spec["extra"]["zmq_port"] == 50071
|
||||
assert spec["extra"]["backends"] == ["UCX"]
|
||||
assert "role" not in edge.extra
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"deploy_name",
|
||||
["minimax_h3_disaggregated.yaml", "minimax_h3_disaggregated_turbo.yaml"],
|
||||
)
|
||||
def test_minimax_h3_builtin_stage_one_tp4_ulysses1_override(self, deploy_name):
|
||||
stages, _ = StageConfigFactory._create_legacy_from_registry(
|
||||
OMNI_PIPELINES["minimax_h3_disaggregated"],
|
||||
{"stage_1_tensor_parallel_size": 4, "stage_1_ulysses_degree": 1},
|
||||
deploy_config_path=get_deploy_config_path(deploy_name),
|
||||
)
|
||||
encoder_args = stages[0].to_omegaconf().engine_args
|
||||
diffusion_args = stages[1].to_omegaconf().engine_args
|
||||
assert encoder_args.tensor_parallel_size == 2
|
||||
assert "ulysses_degree" not in stages[0].runtime_overrides
|
||||
assert diffusion_args.parallel_config.tensor_parallel_size == 4
|
||||
assert diffusion_args.parallel_config.ulysses_degree == 1
|
||||
assert diffusion_args.parallel_config.vae_patch_parallel_size == 4
|
||||
assert tuple(diffusion_args.stage_input_payload_keys) == ("encoder_output",)
|
||||
|
||||
def test_minimax_h3_text_encoder_tp_alias_targets_stage_zero(self):
|
||||
pipeline = OMNI_PIPELINES["minimax_h3_disaggregated"]
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
from dataclasses import fields
|
||||
from dataclasses import fields, replace
|
||||
from inspect import Parameter, signature
|
||||
from multiprocessing.reduction import ForkingPickler
|
||||
from pathlib import Path
|
||||
@@ -246,6 +246,12 @@ def test_vllm_omni_config_from_pipeline_config_matches_merge_pipeline_deploy(mod
|
||||
assert omni_stage.diffusion_config is not None
|
||||
assert omni_stage.diffusion_config.stage_id == legacy_stage.stage_id
|
||||
assert omni_stage.diffusion_config.model_arch == engine_args.get("model_arch")
|
||||
assert omni_stage.diffusion_config.stage_input_payload_keys == engine_args.get(
|
||||
"stage_input_payload_keys", ()
|
||||
)
|
||||
assert omni_stage.diffusion_config.stage_output_payload_keys == engine_args.get(
|
||||
"stage_output_payload_keys", ()
|
||||
)
|
||||
elif omni_stage.stage_pipeline_config.execution_type == StageExecutionType.LLM_AR:
|
||||
assert isinstance(omni_stage, VllmOmniARStageConfig)
|
||||
assert not hasattr(omni_stage, "diffusion_config")
|
||||
@@ -1725,6 +1731,58 @@ def test_from_pipeline_config_rejects_reserved_diffusion_kv_mode(tmp_path):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("source", ["default", "topology", "deploy", "stage-cli"])
|
||||
@pytest.mark.parametrize("key_container", [list, tuple])
|
||||
def test_diffusion_stage_payload_keys_roundtrip(source, key_container):
|
||||
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
||||
from vllm_omni.engine.stage_init_utils import build_engine_args_dict_from_omni_stage_config
|
||||
|
||||
topology_keys = {
|
||||
"stage_input_payload_keys": ("conditioning", "metadata"),
|
||||
"stage_output_payload_keys": ("latents",),
|
||||
}
|
||||
override_keys = {
|
||||
"stage_input_payload_keys": (),
|
||||
"stage_output_payload_keys": ("audio", "video"),
|
||||
}
|
||||
pipeline = _resolve_pipeline_or_skip("dreamzero")
|
||||
topology = pipeline.get_stage(0)
|
||||
if source != "default":
|
||||
topology = replace(topology, **topology_keys)
|
||||
pipeline = replace(pipeline, stages=(topology,))
|
||||
deploy = _load_default_deploy(pipeline)
|
||||
cli_overrides = {}
|
||||
if source == "deploy":
|
||||
deploy = replace(deploy, stages=[StageDeployConfig(stage_id=0, engine_extras=override_keys)])
|
||||
elif source == "stage-cli":
|
||||
cli_overrides = {f"stage_0_{name}": value for name, value in override_keys.items()}
|
||||
|
||||
stage = VllmOmniConfig.from_pipeline_config(
|
||||
pipeline, user_deploy_config=deploy, cli_overrides=cli_overrides
|
||||
).stage_by_id(0)
|
||||
expected = topology_keys if source == "topology" else override_keys
|
||||
if source == "default":
|
||||
expected = dict.fromkeys(topology_keys, ())
|
||||
legacy_stage = merge_pipeline_deploy(pipeline, deploy)[0]
|
||||
legacy_args = {**legacy_stage.yaml_engine_args, **(override_keys if source == "stage-cli" else {})}
|
||||
restored_stage = ForkingPickler.loads(ForkingPickler.dumps(stage))
|
||||
engine_args = build_engine_args_dict_from_omni_stage_config(restored_stage, model="test-model")
|
||||
diffusion_kwargs = omni_config_module.extract_diffusion_stage_config_kwargs(
|
||||
engine_args, stage_id=restored_stage.stage_id, include_engine_adapter_metadata=True
|
||||
)
|
||||
for name in topology_keys:
|
||||
diffusion_kwargs[name] = key_container(diffusion_kwargs[name])
|
||||
od_config = OmniDiffusionConfig.from_kwargs(**diffusion_kwargs)
|
||||
|
||||
for name, keys in expected.items():
|
||||
assert legacy_args.get(name, ()) == keys
|
||||
assert getattr(stage.diffusion_config, name) == keys
|
||||
assert engine_args[name] == keys
|
||||
assert getattr(od_config, name) == keys
|
||||
for name in topology_keys:
|
||||
assert getattr(topology, name) == (() if source == "default" else topology_keys[name])
|
||||
|
||||
|
||||
def test_diffusion_config_field_classification_covers_current_fields():
|
||||
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
||||
|
||||
@@ -1745,6 +1803,8 @@ def test_diffusion_config_field_classification_covers_current_fields():
|
||||
"diffusion_kv_cache_dtype",
|
||||
"diffusion_kv_mode",
|
||||
"diffusion_kv_max_rows_per_request",
|
||||
"stage_input_payload_keys",
|
||||
"stage_output_payload_keys",
|
||||
} <= omni_config_module._DIFFUSION_ONLY_CONFIG_FIELDS
|
||||
assert {
|
||||
"revision",
|
||||
|
||||
Reference in new issue
Block a user