Skip to content

[fix][5889686] AutoCast: Fix logger#890

Merged
galagam merged 2 commits intoNVIDIA:mainfrom
galagam:fix-autocast-logger
Feb 17, 2026
Merged

[fix][5889686] AutoCast: Fix logger#890
galagam merged 2 commits intoNVIDIA:mainfrom
galagam:fix-autocast-logger

Conversation

@galagam
Copy link
Contributor

@galagam galagam commented Feb 13, 2026

What does this PR do?

Type of change: Bug fix
Overview:
Previously relied on quantization logger, which caused logs to be suppressed when onnx.autocast was used directly
Instead:

  • Inherit format and level if called from onnx.quantization
  • Configure independent format and level if called from onnx.autocast

Before your PR is "Ready for review"

  • Make sure you read and follow Contributor guidelines and your commits are signed.
  • Is this change backward compatible?: Yes
  • Did you write any new necessary tests?: No
  • Did you add or update any necessary documentation?: No
  • Did you update Changelog?: No

Additional Information

Summary by CodeRabbit

  • Bug Fixes

    • Improved logging configuration to ensure consistent behavior across modules with enhanced file and console output management.
    • Fixed log file handling to automatically create required directories.
    • Enhanced logger propagation logic for more reliable output routing.
  • Chores

    • Refined logging initialization for better automatic configuration at startup.

@galagam galagam requested a review from a team as a code owner February 13, 2026 11:26
@galagam galagam requested a review from gcunhase February 13, 2026 11:26
@galagam galagam self-assigned this Feb 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Refactors the autocast logging configuration to use a hierarchical logger namespace ("modelopt.onnx.autocast") with conditional parent logger inheritance, centralized formatter application, and hybrid propagation logic supporting both standalone and parent-backed usage patterns.

Changes

Cohort / File(s) Summary
Logging Configuration Refactor
modelopt/onnx/autocast/logging_config.py
Updated logger initialization to use namespaced identifier. Added conditional parent logger level inheritance, centralized formatter for file and console handlers, directory creation for log files, and dynamic propagation logic based on parent handler presence. Post-configuration now applies levels to all modelopt.onnx.autocast child loggers. Auto-configures on module import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: fixing the logger for AutoCast by making it context-aware and properly namespaced under modelopt.onnx.autocast instead of relying on a generic 'autocast' logger.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@modelopt/onnx/autocast/logging_config.py`:
- Around line 32-50: The function configure_logging currently treats
level=logging.INFO as "not provided" which breaks explicit INFO uses; change the
signature of configure_logging to use level=None as the default, update the
docstring to state None means "inherit parent or default", and implement logic
in configure_logging so: if parent_logger has handlers and level is None then
set level = parent_logger.level, else if level is None set level = logging.INFO;
also preserve support for string level names by mapping strings to logging
constants before calling logger.setLevel(level) (reference configure_logging,
parent_logger, logger.setLevel).
🧹 Nitpick comments (1)
modelopt/onnx/autocast/logging_config.py (1)

87-91: Consider that loggerDict may contain PlaceHolder entries.

logging.root.manager.loggerDict is a semi-private API and can contain PlaceHolder objects for intermediate namespace nodes. Calling logging.getLogger(name) on line 90 safely returns a real Logger, but it also materializes placeholders into full loggers as a side effect. This is unlikely to cause issues in practice, but a defensive check would make the intent clearer:

Optional: skip non-Logger entries
     for name in logging.root.manager.loggerDict:
-        if name.startswith("modelopt.onnx.autocast"):
-            logging.getLogger(name).setLevel(level)
+        if name.startswith("modelopt.onnx.autocast"):
+            child = logging.root.manager.loggerDict[name]
+            if isinstance(child, logging.Logger):
+                child.setLevel(level)

parent_has_handlers = len(parent_logger.handlers) > 0

# If parent is configured and no explicit level provided, inherit parent's level
if parent_has_handlers and level == logging.INFO:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check level == logging.INFO or should we just propagate the parent's level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored, the logic is clearer now. Please revisit.

Copy link
Contributor

@gcunhase gcunhase left a comment

Choose a reason for hiding this comment

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

Added 1 comment, otherwise LGTM. Approving.

@galagam galagam requested a review from a team as a code owner February 15, 2026 07:26
@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.74%. Comparing base (ca1f968) to head (f5bfb89).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
modelopt/onnx/autocast/logging_config.py 73.68% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #890      +/-   ##
==========================================
- Coverage   73.74%   73.74%   -0.01%     
==========================================
  Files         199      199              
  Lines       21163    21177      +14     
==========================================
+ Hits        15606    15616      +10     
- Misses       5557     5561       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Previously relied on quantization logger, which caused logs to be suppressed when
onnx.autocast was used directly
Instead:
- Inherit format and level if called from onnx.quantization
- Configure independent format and level if called from onnx.autocast

Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
@galagam galagam force-pushed the fix-autocast-logger branch from 22a5c15 to f5bfb89 Compare February 17, 2026 09:34
@galagam galagam merged commit 9763505 into NVIDIA:main Feb 17, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants