-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: Default to RichProgressBar and RichModelSummary if rich is avai… #20896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
littlebullGit
wants to merge
10
commits into
Lightning-AI:master
Choose a base branch
from
littlebullGit:feature/9580-rich-defaults
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Default to RichProgressBar and RichModelSummary if rich is avai… #20896
littlebullGit
wants to merge
10
commits into
Lightning-AI:master
from
littlebullGit:feature/9580-rich-defaults
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Borda
reviewed
Jun 12, 2025
tests/tests_pytorch/callbacks/progress/test_tqdm_progress_bar.py
Outdated
Show resolved
Hide resolved
Borda
reviewed
Jun 12, 2025
tests/tests_pytorch/callbacks/progress/test_tqdm_progress_bar.py
Outdated
Show resolved
Hide resolved
f8081b0
to
929c530
Compare
bhimrazy
reviewed
Jun 13, 2025
bhimrazy
reviewed
Jun 15, 2025
…lable Implements automatic detection of the 'rich' package and enables RichProgressBar and RichModelSummary by default in the Trainer when the package is present. This enhances the user experience with improved visual feedback without requiring manual configuration. Includes comprehensive tests for various scenarios. Fixes Lightning-AI#9580
…and rich progress bars
The RichProgressBar was failing in multi-GPU environments because it could not handle tensor metrics from different devices. This commit overrides the get_metrics method to convert all tensor metrics to floats before they are rendered, preventing errors. An accompanying test is added to verify the fix.
The test_progress_bar_max_val_check_interval_ddp test was failing in CI due to an AttributeError. This occurred because _RICH_AVAILABLE was not mocked, leading to RichProgressBar being used incorrectly. This commit adds the necessary @patch decorator to ensure TQDMProgressBar is instantiated as expected.
Addresses a PR comment by bhimrazy regarding inconsistent _RICH_AVAILABLE checks. This commit: 1. Defines _RICH_MIN_VERSION = "10.2.2" in utilities/imports.py. 2. Updates _RICH_AVAILABLE in utilities/imports.py to use this minimum version. 3. Modifies callbacks/progress/rich_progress.py to import and use the centralized _RICH_AVAILABLE from utilities/imports.py, removing its local definition. This ensures a single source of truth for rich package availability and version checking.
Co-authored-by: Bhimraj Yadav <[email protected]>
Fixes import statements in files that were still importing _RICH_AVAILABLE from rich_progress.py instead of the centralized utilities.imports. Updated files: - src/lightning/pytorch/callbacks/rich_model_summary.py - src/lightning/pytorch/loops/evaluation_loop.py - src/lightning/pytorch/utilities/testing/_runif.py - tests/tests_pytorch/trainer/logging_/test_eval_loop_logging.py This completes the centralization of _RICH_AVAILABLE checks.
0e502fa
to
8f97b42
Compare
pls add it as part of your PR :) |
Added entry to CHANGELOG.md documenting the new feature that defaults to RichProgressBar and RichModelSummary when the rich package is available, with fallback to TQDM variants.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR implements automatic detection of the optional rich package. If rich is available in the environment, PyTorch Lightning will now default to using RichProgressBar and RichModelSummary for an enhanced visual experience during training and model summarization. If rich is not available, it gracefully falls back to the standard TQDMProgressBar and ModelSummary.
This change aims to improve the out-of-the-box user experience by providing richer feedback mechanisms without requiring manual configuration when rich is installed. The existing behavior of respecting user-provided callbacks or explicit disabling of progress bars/model summaries is maintained.
The rich package is an optional dependency to enable the new default behaviors. If not present, the existing default callbacks are used.
Fixes #9580
No breaking changes are introduced by this PR.
Before submitting
Changelog Entry Suggestion (for CHANGELOG.md):
📚 Documentation preview 📚: https://pytorch-lightning--20896.org.readthedocs.build/en/20896/