[Model] Migrate MammothModa2 DiT to the shared diffusion runtime (#7134)
Signed-off-by: levius <2114377220@qq.com> Signed-off-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: amy-why-3459 <wuhaiyan17@huawei.com> Co-authored-by: Yueqian Lin <linyueqian@outlook.com>
This commit is contained in:
16 files changed
+1046
-427
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
|
||||
"""Tests for endpoint restrictions logic."""
|
||||
|
||||
import pytest
|
||||
@@ -44,6 +44,32 @@ def test_restricted_completions_returns_400():
|
||||
assert body["error"]["type"] == "BadRequestError"
|
||||
|
||||
|
||||
def test_restricted_image_edits_returns_400():
|
||||
"""Ensure pipelines can reject image edits independently of generation."""
|
||||
app = FastAPI()
|
||||
|
||||
@app.post("/v1/images/edits")
|
||||
async def existing_handler():
|
||||
return {"ok": True}
|
||||
|
||||
@app.post("/v1/images/generations")
|
||||
async def generations_handler():
|
||||
return {"ok": True}
|
||||
|
||||
restrictions = (EndpointRestriction(OmniServingCapability.IMAGE_EDITS, REJECTION_REASON),)
|
||||
shutdown_unsupported_routes(app, restrictions)
|
||||
|
||||
client = TestClient(app)
|
||||
resp = client.post("/v1/images/edits")
|
||||
assert resp.status_code == 400
|
||||
assert resp.json()["error"]["message"] == REJECTION_REASON
|
||||
|
||||
# The restriction is endpoint-specific and must not remove generations.
|
||||
resp = client.post("/v1/images/generations")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json() == {"ok": True}
|
||||
|
||||
|
||||
def test_unrestricted_completions_not_blocked():
|
||||
"""Ensure that if we don't shutdown any routes, the route stays."""
|
||||
app = _make_app_with_server_route()
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.helpers.stage_config import get_deploy_config_path
|
||||
from vllm_omni.config.endpoint_policy import OmniServingCapability
|
||||
from vllm_omni.config.stage_config import StageExecutionType, load_deploy_config
|
||||
from vllm_omni.diffusion.registry import _DIFFUSION_MODELS
|
||||
from vllm_omni.model_executor.models.mammoth_moda2.pipeline import (
|
||||
MAMMOTH_MODA2_AR_PIPELINE,
|
||||
MAMMOTH_MODA2_PIPELINE,
|
||||
)
|
||||
from vllm_omni.model_executor.models.registry import _OMNI_MODELS
|
||||
|
||||
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
||||
|
||||
|
||||
def test_mammothmoda2_generation_stage_uses_shared_diffusion_runtime() -> None:
|
||||
ar_stage, dit_stage = MAMMOTH_MODA2_PIPELINE.stages
|
||||
assert ar_stage.execution_type is StageExecutionType.LLM_AR
|
||||
assert dit_stage.execution_type is StageExecutionType.DIFFUSION
|
||||
assert dit_stage.model_arch == "MammothModa2DiTPipeline"
|
||||
assert dit_stage.custom_process_input_func.endswith(".ar2diffusion")
|
||||
assert dit_stage.omni_kv_config == {"need_recv_cache": False}
|
||||
assert dit_stage.input_sources == (0,)
|
||||
assert dit_stage.final_output is True
|
||||
assert dit_stage.final_output_type == "image"
|
||||
|
||||
|
||||
def test_mammothmoda2_dit_is_registered_only_with_diffusion_runtime() -> None:
|
||||
assert _DIFFUSION_MODELS["MammothModa2DiTPipeline"] == (
|
||||
"mammoth_moda2",
|
||||
"pipeline_mammothmoda2_dit",
|
||||
"MammothModa2DiTPipeline",
|
||||
)
|
||||
assert "MammothModa2DiTPipeline" not in _OMNI_MODELS
|
||||
|
||||
|
||||
def test_mammothmoda2_deploy_does_not_shadow_request_sampling_fields() -> None:
|
||||
deploy = load_deploy_config(get_deploy_config_path("mammoth_moda2.yaml"))
|
||||
|
||||
assert deploy.stages[1].default_sampling_params is None
|
||||
|
||||
|
||||
def test_mammothmoda2_rejects_unsupported_image_edits() -> None:
|
||||
restrictions = {
|
||||
restriction.capability: restriction.reason for restriction in MAMMOTH_MODA2_PIPELINE.endpoint_restrictions
|
||||
}
|
||||
|
||||
assert set(restrictions) == {OmniServingCapability.IMAGE_EDITS}
|
||||
assert "img2img" in restrictions[OmniServingCapability.IMAGE_EDITS]
|
||||
assert MAMMOTH_MODA2_AR_PIPELINE.endpoint_restrictions == ()
|
||||
|
||||
|
||||
def test_mammothmoda2_ar_only_topology_is_unchanged() -> None:
|
||||
assert len(MAMMOTH_MODA2_AR_PIPELINE.stages) == 1
|
||||
stage = MAMMOTH_MODA2_AR_PIPELINE.stages[0]
|
||||
assert stage.execution_type is StageExecutionType.LLM_AR
|
||||
assert stage.final_output_type == "text"
|
||||
@@ -95,6 +95,20 @@ def _from_pipeline_key(
|
||||
)
|
||||
|
||||
|
||||
def test_mammothmoda2_diffusion_stage_projects_native_backend_config() -> None:
|
||||
config = _from_pipeline_key(
|
||||
"mammoth_moda2",
|
||||
cli_overrides={"model": "/models/MammothModa2-Preview"},
|
||||
)
|
||||
stage = config.stage_by_id(1)
|
||||
assert isinstance(stage, VllmOmniDiffusionStageConfig)
|
||||
assert stage.diffusion_config.model_class_name == "MammothModa2DiTPipeline"
|
||||
assert stage.diffusion_config.model == "/models/MammothModa2-Preview"
|
||||
assert stage.diffusion_config.step_execution is False
|
||||
assert stage.scheduler_config.max_num_seqs == 1
|
||||
assert stage.connector_config.omni_kv_config == {"need_recv_cache": False}
|
||||
|
||||
|
||||
def test_minimax_h3_text_encoder_tp_targets_only_structured_stage_zero() -> None:
|
||||
config = _from_pipeline_key(
|
||||
"minimax_h3_disaggregated",
|
||||
|
||||
Reference in new issue
Block a user