[diffusion] fix: fix local-path detection for MiniMax-H3 and other non-diffusers models (#33365)

Co-authored-by: Mick <mickjagger19@icloud.com>
This commit is contained in:
TobyMint
2026-08-04 14:03:35 +08:00
committed by GitHub
co-authored by Mick
parent 4494fb96b2
commit 101bb2327c
4 changed files with 60 additions and 50 deletions
+12 -15
View File
@@ -9,7 +9,6 @@ from huggingface_hub import HfApi
from sglang.srt.environ import envs
from sglang.utils import (
has_diffusion_overlay_registry_match,
is_known_non_diffusers_diffusion_model,
load_diffusion_overlay_registry_from_env,
)
@@ -25,14 +24,14 @@ def _is_overlay_diffusion_model(model_path: str) -> bool:
return has_diffusion_overlay_registry_match(model_path, _load_overlay_registry())
def _is_registered_diffusion_model(model_path: str) -> bool:
def _is_diffusion_model_from_registry(model_path: str) -> bool:
try:
from sglang.multimodal_gen.registry import has_registered_diffusion_model_path
from sglang.multimodal_gen.registry import is_registered_diffusion_model_path
except ImportError:
# if diffusion dependencies are not installed
return False
return has_registered_diffusion_model_path(model_path)
return is_registered_diffusion_model_path(model_path)
def _is_diffusers_model_dir(model_dir: str) -> bool:
@@ -59,8 +58,9 @@ def _is_gated_diffusion_repo(repo_id: str) -> bool:
def get_is_diffusion_model(model_path: str) -> bool:
"""Detect whether model_path points to a diffusion model.
For local directories, checks the filesystem directly.
For HF/ModelScope model IDs, attempts to fetch only model_index.json.
For registered models, consults the diffusion registry first.
For other local directories, checks the filesystem directly.
For other HF/ModelScope model IDs, attempts to fetch only model_index.json.
For gated repos where file download fails, falls back to HF model card
metadata (library_name == "diffusers").
Returns False on any failure (network error, 404, offline mode, etc.)
@@ -70,16 +70,13 @@ def get_is_diffusion_model(model_path: str) -> bool:
# short-circuit, if applicable for the overlay mechanism (diffusion-only)
return True
# the diffusion registry is authoritative for native models, including
# local directories without a top-level model_index.json
if _is_diffusion_model_from_registry(model_path):
return True
if os.path.isdir(model_path):
if _is_diffusers_model_dir(model_path):
return True
return is_known_non_diffusers_diffusion_model(model_path)
if is_known_non_diffusers_diffusion_model(model_path):
return True
if _is_registered_diffusion_model(model_path):
return True
return _is_diffusers_model_dir(model_path)
try:
if envs.SGLANG_USE_MODELSCOPE.get():