Skip to content

[diffusion] logging: log available mem when each stage starts in debug level#18998

Merged
mickqian merged 11 commits intomainfrom
diffusion-logging
Feb 20, 2026
Merged

[diffusion] logging: log available mem when each stage starts in debug level#18998
mickqian merged 11 commits intomainfrom
diffusion-logging

Conversation

@mickqian
Copy link
Collaborator

…g level

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@github-actions github-actions bot added the diffusion SGLang Diffusion label Feb 19, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mickqian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the system's debuggability and resilience against GPU memory issues. By introducing more explicit logging for Out-Of-Memory (OOM) errors and providing detailed insights into available GPU memory at key operational stages, it aims to streamline the diagnosis and resolution of memory-related challenges during both module loading and runtime execution.

Highlights

  • Enhanced Out-Of-Memory (OOM) Error Handling: A warning message is now logged when an OOM exception occurs during request execution, providing immediate feedback on memory issues.
  • Consolidated OOM Exception Types: A new helper function, _oom_exceptions, was introduced to abstract and consolidate different OOM exception types, improving code readability and maintainability.
  • Improved GPU Memory Visibility: Available GPU memory is now logged at a debug level when pipeline modules are loaded and when a performance stage begins, offering crucial insights for debugging memory-related problems.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • python/sglang/multimodal_gen/runtime/managers/gpu_worker.py
    • Added a warning log for OOM exceptions encountered during execute_forward.
    • Reordered suggestions within the OOM_MSG constant for clarity.
    • Defined a new helper function _oom_exceptions to encapsulate various OOM exception types.
    • Updated the run_scheduler_process exception handling to catch _oom_exceptions().
  • python/sglang/multimodal_gen/runtime/pipelines_core/composed_pipeline_base.py
    • Imported current_platform to access platform-specific information.
    • Modified the module loading process to log available GPU memory at a debug level.
  • python/sglang/multimodal_gen/runtime/utils/perf_logger.py
    • Imported the logging module and current_platform.
    • Updated the __enter__ method of PerfLogger to include available GPU memory in the stage start log message when debug logging is enabled.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mickqian
Copy link
Collaborator Author

/tag-and-rerun-ci

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces useful memory logging at the debug level for different stages of the pipeline, which will aid in debugging memory-related issues. It also improves Out-of-Memory (OOM) error handling by centralizing the OOM exception types. The changes are generally good, but I've identified a potential runtime error in the OOM exception handling logic where an exception type might be accessed without checking for its existence, which could lead to a crash. I've provided a suggestion to make this more robust.

@mickqian
Copy link
Collaborator Author

/tag-and-rerun-ci

Comment on lines +316 to +318
"Memory usage of loaded modules (GiB): %s. Available memory: %s",
self.memory_usages,
round(current_platform.get_available_gpu_memory(), 2),
Copy link
Collaborator

Choose a reason for hiding this comment

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

prefer f-format string to c-style string

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we need the lazy evaluation, which is recommended by python logging documentation

@mickqian
Copy link
Collaborator Author

/rerun-failed-ci

@mickqian mickqian merged commit 38a6965 into main Feb 20, 2026
64 of 65 checks passed
@mickqian mickqian deleted the diffusion-logging branch February 20, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments