[diffusion] logging: improve logging (#19312)
This commit is contained in:
@@ -47,7 +47,7 @@ def _maybe_download_model(
|
||||
from sglang.multimodal_gen.runtime.utils.hf_diffusers_utils import hf_hub_download
|
||||
|
||||
if os.path.exists(model_name_or_path):
|
||||
logger.info("Model already exists locally")
|
||||
logger.debug("Model already exists locally")
|
||||
return model_name_or_path
|
||||
|
||||
if not download:
|
||||
@@ -57,7 +57,7 @@ def _maybe_download_model(
|
||||
# Try `model_index.json` first (diffusers models)
|
||||
source_hub = "MS Hub" if envs.SGLANG_USE_MODELSCOPE.get() else "HF Hub"
|
||||
try:
|
||||
logger.info(
|
||||
logger.debug(
|
||||
"Downloading model_index.json from %s for %s...",
|
||||
source_hub,
|
||||
model_name_or_path,
|
||||
@@ -67,14 +67,14 @@ def _maybe_download_model(
|
||||
filename="model_index.json",
|
||||
local_dir=local_dir,
|
||||
)
|
||||
logger.info("Downloaded to %s", file_path)
|
||||
logger.debug("Downloaded to %s", file_path)
|
||||
return os.path.dirname(file_path)
|
||||
except Exception as e_index:
|
||||
logger.debug("model_index.json not found or failed: %s", e_index)
|
||||
|
||||
# Fallback to `config.json`
|
||||
try:
|
||||
logger.info(
|
||||
logger.debug(
|
||||
"Downloading config.json from %s for %s...",
|
||||
source_hub,
|
||||
model_name_or_path,
|
||||
@@ -84,7 +84,7 @@ def _maybe_download_model(
|
||||
filename="config.json",
|
||||
local_dir=local_dir,
|
||||
)
|
||||
logger.info("Downloaded to %s", file_path)
|
||||
logger.debug("Downloaded to %s", file_path)
|
||||
return os.path.dirname(file_path)
|
||||
except Exception as e_config:
|
||||
raise ValueError(
|
||||
|
||||
@@ -423,13 +423,13 @@ def get_model_info(
|
||||
return None
|
||||
|
||||
# 4. Combine and return the complete model info
|
||||
logger.info("Using native sglang backend for model '%s'", model_path)
|
||||
logger.debug("Using native sglang backend for model '%s'", model_path)
|
||||
model_info = ModelInfo(
|
||||
pipeline_cls=pipeline_cls,
|
||||
sampling_param_cls=config_info.sampling_param_cls,
|
||||
pipeline_config_cls=config_info.pipeline_config_cls,
|
||||
)
|
||||
logger.info(f"Found model info: {model_info}")
|
||||
logger.debug(f"Found model info: {model_info}")
|
||||
|
||||
return model_info
|
||||
|
||||
|
||||
@@ -125,35 +125,16 @@ class ComponentLoader(ABC):
|
||||
if isinstance(component, nn.Module):
|
||||
component = component.eval()
|
||||
current_gpu_mem = current_platform.get_available_gpu_memory()
|
||||
model_size = get_memory_usage_of_component(component)
|
||||
model_size = get_memory_usage_of_component(component) or "NA"
|
||||
consumed = gpu_mem_before_loading - current_gpu_mem
|
||||
|
||||
# detect component device
|
||||
try:
|
||||
component_device = str(next(component.parameters()).device)
|
||||
is_on_gpu = "cuda" in component_device
|
||||
except (StopIteration, AttributeError):
|
||||
is_on_gpu = False
|
||||
component_device = "unknown"
|
||||
|
||||
if is_on_gpu:
|
||||
logger.info(
|
||||
f"Loaded %s: %s ({source} version). model size: %.2f GB, consumed GPU: %.2f GB, avail GPU mem: %.2f GB",
|
||||
component_name,
|
||||
component.__class__.__name__,
|
||||
model_size,
|
||||
consumed,
|
||||
current_gpu_mem,
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
f"Loaded %s: %s ({source} version). model size: %.2f GB, device: %s, avail GPU mem: %.2f GB",
|
||||
component_name,
|
||||
component.__class__.__name__,
|
||||
model_size,
|
||||
component_device,
|
||||
current_gpu_mem,
|
||||
)
|
||||
logger.info(
|
||||
f"Loaded %s: %s ({source} version). model size: %s GB, consumed GPU mem: %.2f GB, avail GPU mem: %.2f GB",
|
||||
component_name,
|
||||
component.__class__.__name__,
|
||||
model_size,
|
||||
consumed,
|
||||
current_gpu_mem,
|
||||
)
|
||||
return component, consumed
|
||||
|
||||
def load_native(
|
||||
|
||||
@@ -282,7 +282,7 @@ class Req:
|
||||
return pprint.pformat(asdict(self), indent=2, width=120)
|
||||
|
||||
def log(self, server_args: ServerArgs):
|
||||
if self.is_warmup:
|
||||
if self.is_warmup or self.suppress_logs:
|
||||
return
|
||||
# TODO: in some cases (e.g., TI2I), height and weight might be undecided at this moment
|
||||
if self.height:
|
||||
@@ -300,8 +300,8 @@ class Req:
|
||||
self.negative_prompt, key_hint="negative_prompt"
|
||||
)
|
||||
|
||||
# log non-sensitive parameters at info level
|
||||
info_str = f"""Sampling params:
|
||||
# Log sampling parameters
|
||||
debug_str = f"""Sampling params:
|
||||
width: {target_width}
|
||||
height: {target_height}
|
||||
num_frames: {self.num_frames}
|
||||
@@ -319,16 +319,7 @@ class Req:
|
||||
save_output: {self.save_output}
|
||||
output_file_path: {self.output_file_path()}
|
||||
""" # type: ignore[attr-defined]
|
||||
|
||||
# log full prompts at debug level only (for debugging purposes)
|
||||
debug_str = f"""Full prompts:
|
||||
prompt: {self.prompt}
|
||||
neg_prompt: {self.negative_prompt}
|
||||
"""
|
||||
|
||||
if not self.suppress_logs:
|
||||
logger.info(info_str)
|
||||
logger.debug(debug_str)
|
||||
logger.debug(debug_str)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -605,7 +605,7 @@ def maybe_download_model_index(model_name_or_path: str) -> dict[str, Any]:
|
||||
# Add the pipeline name for downstream use
|
||||
config["pipeline_name"] = config["_class_name"]
|
||||
|
||||
logger.info(
|
||||
logger.debug(
|
||||
"Downloaded model_index.json for %s, pipeline: %s",
|
||||
model_name_or_path,
|
||||
config["_class_name"],
|
||||
|
||||
Reference in New Issue
Block a user