[diffusion] UX: suppress noisy worker startup warnings (#34512)

This commit is contained in:
Mick
2026-08-12 17:53:45 +08:00
committed by GitHub
parent 644d55ebfa
commit b3bffef70a
3 changed files with 56 additions and 1 deletions
@@ -15,6 +15,13 @@ import numpy as np
import torch
from setproctitle import setproctitle
from sglang.multimodal_gen.runtime.utils.logging_utils import ( # isort: skip
globally_suppress_loggers,
)
# spawned workers import model dependencies before entering run_scheduler_process
globally_suppress_loggers()
from sglang.multimodal_gen import envs
from sglang.multimodal_gen.runtime.distributed import (
get_sp_group,
@@ -65,7 +72,6 @@ from sglang.multimodal_gen.runtime.server_args import PortArgs, ServerArgs
from sglang.multimodal_gen.runtime.utils.common import set_cuda_arch, set_musa_arch
from sglang.multimodal_gen.runtime.utils.logging_utils import (
configure_logger,
globally_suppress_loggers,
init_logger,
)
from sglang.multimodal_gen.runtime.utils.perf_logger import (
@@ -517,6 +517,17 @@ class _UvicornAccessLogFilter(logging.Filter):
return True
class _PytreeEnumRegistrationFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
message = record.getMessage()
return not (
"is an Enum subclass and is now natively supported by torch.compile"
in message
and "Calling register_constant() on Enum subclasses is deprecated"
in message
)
def configure_logger(server_args, prefix: str = ""):
log_format = f"[%(asctime)s{prefix}] %(message)s"
datefmt = "%m-%d %H:%M:%S"
@@ -570,6 +581,13 @@ def globally_suppress_loggers():
for name in target_names:
logging.getLogger(name).setLevel(logging.ERROR)
pytree_logger = logging.getLogger("torch.utils._pytree")
if not any(
isinstance(filter_, _PytreeEnumRegistrationFilter)
for filter_ in pytree_logger.filters
):
pytree_logger.addFilter(_PytreeEnumRegistrationFilter())
# source: https://github.com/vllm-project/vllm/blob/a11f4a81e027efd9ef783b943489c222950ac989/vllm/utils/system_utils.py#L60
@contextlib.contextmanager
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: Apache-2.0
import logging
import unittest
from sglang.multimodal_gen.runtime.utils.logging_utils import (
globally_suppress_loggers,
)
class TestSuppressNoisyDependencyLogs(unittest.TestCase):
def test_filters_only_pytree_enum_registration_deprecation(self):
logger = logging.getLogger("torch.utils._pytree")
with self.assertLogs(logger, level=logging.WARNING) as captured:
globally_suppress_loggers()
logger.warning(
"<enum 'KernelPreference'> is an Enum subclass and is now "
"natively supported by torch.compile as an opaque value type. "
"Calling register_constant() on Enum subclasses is deprecated "
"and will be an error in a future release."
)
logger.warning("unrelated pytree warning")
self.assertEqual(
captured.output,
["WARNING:torch.utils._pytree:unrelated pytree warning"],
)
if __name__ == "__main__":
unittest.main()