Skip to content

[Cleanup] Replace bare print() with logger and use specific exception types#2228

Merged
lishunyang12 merged 2 commits into
vllm-project:mainfrom
Lidang-Jiang:cleanup/replace-print-with-logger-and-specific-exceptions
Apr 3, 2026
Merged

[Cleanup] Replace bare print() with logger and use specific exception types#2228
lishunyang12 merged 2 commits into
vllm-project:mainfrom
Lidang-Jiang:cleanup/replace-print-with-logger-and-specific-exceptions

Conversation

@Lidang-Jiang
Copy link
Copy Markdown
Contributor

Summary

Replace 8 bare print() calls in production code with proper logger calls (5 files), and replace 2 generic raise Exception with specific exception types (2 files).

Motivation: Bare print() bypasses vLLM's logging configuration (log levels, formatters, handlers). Generic Exception prevents callers from catching specific error types.

Benchmark code and intentional file I/O print(file=f) calls are left unchanged.

Changes

Exception types (2 files)

File Change
diffusion/diffusion_engine.py:102 raise Exception(...)raise RuntimeError(...)
model_executor/models/cosyvoice3/utils.py:183 raise Exception(...)raise TypeError(...)

print() → logger (5 files, 8 calls)

File Change
diffusion/attention/backends/ring/ring_utils.py print(f"ERROR...")logger.error(...)
diffusion/models/dreamid_omni/fusion.py print("Warning:...")logger.warning(...)
diffusion/models/hunyuan_image_3/hunyuan_image_3_tokenizer.py print(vars)logger.debug(...)
diffusion/models/hunyuan_image_3/hunyuan_image_3_transformer.py print(f"Skipping...")logger.warning(...)
model_executor/models/qwen3_tts/tokenizer_25hz/vq/core_vq.py print(f"VQ expire...")logger.info(...)

All new loggers use from vllm.logger import init_logger consistent with the rest of the codebase. Lazy %s formatting is used instead of f-strings.

Test plan

  • ruff check passes on all 7 modified files
  • ruff format --check passes on all 7 modified files
  • All pre-commit hooks pass
  • No functional logic changed — only logging and exception type improvements

🤖 Generated with Claude Code

… types

Replace 8 bare print() calls in production code with proper logger calls
(5 files), and replace 2 generic `raise Exception` with RuntimeError/TypeError
(2 files). Benchmark code and intentional file I/O print(file=f) calls are
left unchanged.

Motivation: Bare print() bypasses vLLM's logging configuration (log levels,
formatters, handlers). Bare Exception prevents callers from catching specific
error types.

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Copy link
Copy Markdown
Collaborator

@gcanlin gcanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gcanlin gcanlin added the ready label to trigger buildkite CI label Mar 27, 2026
Copy link
Copy Markdown
Collaborator

@lishunyang12 lishunyang12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall, one nit

print(f"ERROR in _update_out_and_lse: {e}")
print(f"out: {out.shape}, lse: {lse.shape}")
print(f"block_out: {block_out.shape}, block_lse: {block_lse.shape}")
logger.error("ERROR in _update_out_and_lse: %s", e)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: logger.error already tags the message as ERROR-level — the "ERROR" prefix is redundant.

Suggested change
logger.error("ERROR in _update_out_and_lse: %s", e)
logger.error("_update_out_and_lse failed: %s", e)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed in d7fcb80 — removed the redundant "ERROR" prefix.

Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
@lishunyang12 lishunyang12 merged commit 515d15e into vllm-project:main Apr 3, 2026
7 of 8 checks passed
linyueqian pushed a commit to JuanPZuluaga/vllm-omni that referenced this pull request Apr 3, 2026
… types (vllm-project#2228)

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: JuanPZuluaga <juanz9312@gmal.com>
skf-1999 pushed a commit to Semmer2/vllm-omni that referenced this pull request Apr 7, 2026
… types (vllm-project#2228)

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
vraiti pushed a commit to vraiti/vllm-omni that referenced this pull request Apr 9, 2026
… types (vllm-project#2228)

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
lengrongfu pushed a commit to lengrongfu/vllm-omni that referenced this pull request May 1, 2026
… types (vllm-project#2228)

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
clodaghwalsh17 pushed a commit to clodaghwalsh17/nm-vllm-omni-ent that referenced this pull request May 12, 2026
… types (vllm-project#2228)

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready label to trigger buildkite CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants