[Bugfix] Fix DataType Handling in Default Diffusion Config (#2530)
Signed-off-by: Alex Brooks <albrooks@redhat.com>
This commit is contained in:
1 parent
7a72f34ce4
commit
08e2e1fc8e
2 files changed
+32
-9
No files matched your search
@@ -5,14 +5,17 @@ from collections import Counter
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import torch
|
||||||
from pytest_mock import MockerFixture
|
from pytest_mock import MockerFixture
|
||||||
|
|
||||||
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
from vllm_omni.diffusion.data import OmniDiffusionConfig
|
||||||
from vllm_omni.engine.arg_utils import OmniEngineArgs
|
from vllm_omni.engine.arg_utils import OmniEngineArgs
|
||||||
|
from vllm_omni.engine.async_omni_engine import AsyncOmniEngine
|
||||||
from vllm_omni.entrypoints.utils import (
|
from vllm_omni.entrypoints.utils import (
|
||||||
_convert_dataclasses_to_dict,
|
_convert_dataclasses_to_dict,
|
||||||
_filter_dict_like_object,
|
_filter_dict_like_object,
|
||||||
filter_dataclass_kwargs,
|
filter_dataclass_kwargs,
|
||||||
|
load_and_resolve_stage_configs,
|
||||||
resolve_model_config_path,
|
resolve_model_config_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -304,3 +307,18 @@ class TestResolveModelConfigPath:
|
|||||||
|
|
||||||
assert result is not None
|
assert result is not None
|
||||||
assert "glm_image.yaml" in result
|
assert "glm_image.yaml" in result
|
||||||
|
|
||||||
|
|
||||||
|
class TestLoadAndResolveStageConfigs:
|
||||||
|
def test_load_and_resolve_with_kwargs(self):
|
||||||
|
"""Ensure that dtype survives default stage creation."""
|
||||||
|
kwargs = {"dtype": torch.float32}
|
||||||
|
config_path, stage_configs = load_and_resolve_stage_configs(
|
||||||
|
model="black-forest-labs/FLUX.2-klein-4B",
|
||||||
|
stage_configs_path=None,
|
||||||
|
kwargs=kwargs,
|
||||||
|
default_stage_cfg_factory=lambda: AsyncOmniEngine._create_default_diffusion_stage_cfg(kwargs),
|
||||||
|
)
|
||||||
|
assert config_path is None
|
||||||
|
assert len(stage_configs) == 1
|
||||||
|
assert "dtype" in stage_configs[0]["engine_args"]
|
||||||
@@ -920,15 +920,7 @@ class AsyncOmniEngine:
|
|||||||
num_devices = max(1, int(parallel_config.world_size))
|
num_devices = max(1, int(parallel_config.world_size))
|
||||||
devices = ",".join(str(i) for i in range(num_devices))
|
devices = ",".join(str(i) for i in range(num_devices))
|
||||||
|
|
||||||
default_stage_cfg = [
|
stage_engine_args = {
|
||||||
{
|
|
||||||
"stage_id": 0,
|
|
||||||
"stage_type": "diffusion",
|
|
||||||
"runtime": {
|
|
||||||
"process": True,
|
|
||||||
"devices": devices,
|
|
||||||
},
|
|
||||||
"engine_args": {
|
|
||||||
"max_num_seqs": 1,
|
"max_num_seqs": 1,
|
||||||
"parallel_config": parallel_config,
|
"parallel_config": parallel_config,
|
||||||
"model_class_name": kwargs.get("model_class_name", None),
|
"model_class_name": kwargs.get("model_class_name", None),
|
||||||
@@ -958,7 +950,20 @@ class AsyncOmniEngine:
|
|||||||
if kwargs.get("profiler_config") is not None
|
if kwargs.get("profiler_config") is not None
|
||||||
else {}
|
else {}
|
||||||
),
|
),
|
||||||
|
}
|
||||||
|
# Only set dtype if it was already explicitly passed and normalized
|
||||||
|
if "dtype" in normalized_kwargs:
|
||||||
|
stage_engine_args["dtype"] = normalized_kwargs["dtype"]
|
||||||
|
|
||||||
|
default_stage_cfg = [
|
||||||
|
{
|
||||||
|
"stage_id": 0,
|
||||||
|
"stage_type": "diffusion",
|
||||||
|
"runtime": {
|
||||||
|
"process": True,
|
||||||
|
"devices": devices,
|
||||||
},
|
},
|
||||||
|
"engine_args": stage_engine_args,
|
||||||
"final_output": True,
|
"final_output": True,
|
||||||
"final_output_type": "image",
|
"final_output_type": "image",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user