[diffusion] fix: fix hunyuanvideo and add 2-gpu ci test (#13720)

Co-authored-by: Mick <mickjagger19@icloud.com>
This commit is contained in:
Yuhao Yang
2025-11-22 20:54:51 +08:00
committed by GitHub
parent ac43822634
commit a22de641ef
16 changed files with 822 additions and 438 deletions

View File

@@ -124,15 +124,20 @@ def _print_warning_once(logger: Logger, msg: str) -> None:
logger.warning(msg, stacklevel=2)
def _get_rank_info():
"""Get rank and local rank from environment variables."""
def get_is_main_process():
try:
rank = int(os.environ["RANK"])
local_rank = int(os.environ["LOCAL_RANK"])
except (KeyError, ValueError):
rank = 0
local_rank = 0
return rank, local_rank
return rank == 0
def get_is_local_main_process():
try:
rank = int(os.environ["LOCAL_RANK"])
except (KeyError, ValueError):
rank = 0
return rank == 0
def _log_process_aware(
@@ -145,9 +150,8 @@ def _log_process_aware(
**kwargs: Any,
) -> None:
"""Helper function to log a message if the process rank matches the criteria."""
rank, local_rank = _get_rank_info()
is_main_process = rank == 0
is_local_main_process = local_rank == 0
is_main_process = get_is_main_process()
is_local_main_process = get_is_local_main_process()
should_log = (
not main_process_only
@@ -393,8 +397,7 @@ def suppress_other_loggers(not_suppress_on_main_rank: bool = False):
should_suppress = True
if not_suppress_on_main_rank:
rank, _ = _get_rank_info()
if rank == 0:
if get_is_main_process() == 0:
should_suppress = False
loggers_to_suppress = ["urllib3"]

View File

@@ -15,7 +15,10 @@ from dateutil.tz import UTC
import sglang
import sglang.multimodal_gen.envs as envs
from sglang.multimodal_gen.runtime.utils.logging_utils import _SGLDiffusionLogger
from sglang.multimodal_gen.runtime.utils.logging_utils import (
_SGLDiffusionLogger,
get_is_main_process,
)
@dataclasses.dataclass
@@ -246,14 +249,15 @@ class PerformanceLogger:
)
try:
log_dir = get_diffusion_perf_log_dir()
if not os.path.exists(log_dir):
os.makedirs(log_dir, exist_ok=True)
if get_is_main_process():
log_dir = get_diffusion_perf_log_dir()
if not os.path.exists(log_dir):
os.makedirs(log_dir, exist_ok=True)
log_file = os.path.join(log_dir, "performance.log")
log_file = os.path.join(log_dir, "performance.log")
with open(log_file, "a", encoding="utf-8") as f:
f.write(json.dumps(dataclasses.asdict(record)) + "\n")
with open(log_file, "a", encoding="utf-8") as f:
f.write(json.dumps(dataclasses.asdict(record)) + "\n")
except (OSError, PermissionError) as e:
print(f"WARNING: Failed to log performance record: {e}", file=sys.stderr)