[cherry-pick][release/v0.18.0post1][Perf] Wan2.2 I2V optimization: convert datatype from FP32 to BF16 in… (#2618)

Signed-off-by: KexiongYu <yukexiong1@huawei.com>
Signed-off-by: Canlin Guo <961750412@qq.com>
Signed-off-by: David Chen <530634352@qq.com>
Co-authored-by: Y. Fisher <yukexiong1@huawei.com>
Co-authored-by: Canlin Guo <961750412@qq.com>
This commit is contained in:
authored and GitHub committed 2026-04-09 09:57:14 +08:00
1 parent 2f289c78db
commit 73d31edf63
7 files changed
+123 -11

No files matched your search

+21
View File
@@ -1,12 +1,16 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from contextlib import nullcontext
from enum import Enum
from typing import Any
import torch
from vllm.logger import init_logger
from vllm.platforms import Platform
logger = init_logger(__name__)
class OmniPlatformEnum(Enum):
"""Enum for supported Omni platforms."""
@@ -109,6 +113,23 @@ class OmniPlatform(Platform):
def get_free_memory(cls, device: torch.device | None = None) -> int:
raise NotImplementedError
@classmethod
def create_autocast_context(
cls,
*,
device_type: str,
dtype: torch.dtype,
enabled: bool = True,
):
if not enabled:
return nullcontext()
try:
return torch.autocast(device_type=device_type, dtype=dtype, enabled=True)
except (RuntimeError, TypeError, ValueError) as exc:
logger.warning("autocast unavailable for device_type=%s dtype=%s: %s", device_type, dtype, exc)
return nullcontext()
@classmethod
def supports_cpu_offload(cls) -> bool:
return True