[Model] Add native MAGI-2 Preview diffusion support (#5918)
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com> Signed-off-by: hsliuustc0106 <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
13c617a140
commit
d4096e01fe
78 files changed
+9896
-459
No files matched your search
@@ -1,3 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
|
||||
import os
|
||||
from collections.abc import Mapping
|
||||
from functools import lru_cache
|
||||
@@ -12,6 +15,14 @@ DIFFUSION_MODEL_INDEX_FILES = (
|
||||
"modular_model_index.json",
|
||||
)
|
||||
|
||||
_MAGI2_MODEL_ID = "sand-ai/MAGI-2-preview"
|
||||
_MAGI2_REQUIRED_FILES = (
|
||||
"preview/model.safetensors.index.json",
|
||||
"text_encoder/config.json",
|
||||
"vae/Wan2.2_VAE.pth",
|
||||
"turbo_vae/checkpoint.ckpt",
|
||||
)
|
||||
|
||||
|
||||
def get_diffusion_model_index(
|
||||
model_name: str,
|
||||
@@ -46,6 +57,26 @@ def _looks_like_bagel(model_name: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def _looks_like_magi2(model_name: str) -> bool:
|
||||
"""Detect the official Hub ID or a complete local Preview checkpoint."""
|
||||
normalized = str(model_name).strip().rstrip("/")
|
||||
hub_prefix = "https://huggingface.co/"
|
||||
if normalized.lower().startswith(hub_prefix):
|
||||
normalized = normalized[len(hub_prefix) :]
|
||||
normalized = normalized.split("/tree/", 1)[0]
|
||||
if normalized.lower() == _MAGI2_MODEL_ID.lower():
|
||||
return True
|
||||
return os.path.isdir(normalized) and all(
|
||||
os.path.isfile(os.path.join(normalized, *relative.split("/"))) for relative in _MAGI2_REQUIRED_FILES
|
||||
)
|
||||
|
||||
|
||||
def resolve_native_diffusion_model_class(model_name: str) -> str | None:
|
||||
"""Resolve native checkpoints that have no root HF or Diffusers config."""
|
||||
|
||||
return "Magi2Pipeline" if _looks_like_magi2(model_name) else None
|
||||
|
||||
|
||||
def _looks_like_dreamzero(model_name: str) -> bool:
|
||||
"""Best-effort detection for DreamZero-style VLA diffusion checkpoints."""
|
||||
try:
|
||||
@@ -104,6 +135,11 @@ def is_diffusion_model(model_name: str) -> bool:
|
||||
2. Check using vllm's get_hf_file_to_dict utility
|
||||
3. Try the standard diffusers approach (may fail due to import issues)
|
||||
"""
|
||||
# Some native diffusion checkpoints have neither a standard Diffusers
|
||||
# index nor a root HF config. Recognize their exact Hub ID/local signature.
|
||||
if resolve_native_diffusion_model_class(model_name) is not None:
|
||||
return True
|
||||
|
||||
# Strategy 1: Check local file system first (fastest, avoids import issues)
|
||||
if os.path.isdir(model_name):
|
||||
for filename in DIFFUSION_MODEL_INDEX_FILES:
|
||||
|
||||
Reference in new issue
Block a user