Skip to content

Show current learning rate in training progress bar - #809

Merged
Borda merged 6 commits into
developfrom
copilot/add-learning-rate-progress-bar
Mar 17, 2026
Merged

Borda merged 6 commits into
developfrom
copilot/add-learning-rate-progress-bar

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Users monitoring LR during fine-tuning had no visibility into the current learning rate from the tqdm progress bar — making it hard to observe warmup ramp-up, step decay, or cosine annealing in real time.

Changes

  • RFDETRModule.training_step: Reads the current LR from optimizer.param_groups[0]["lr"] after each step and logs it as train/lr with prog_bar=True, on_step=True, on_epoch=False. Works correctly for both step-decay and cosine schedulers.
  • test_module.py: Adds test_logs_learning_rate_to_prog_bar to TestTrainingStep asserting train/lr is logged with prog_bar=True.
  • test_metrics_csv.py: Adds train/lr to _REQUIRED_DETECTION to ensure it's always present in metrics.csv.

The LR now appears alongside train/loss in the progress bar:

Epoch 1: 100%|████| loss=2.34 train/lr=1e-04

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pypi.nvidia.com
    • Triggering command: `/home/REDACTED/.cache/uv/builds-v0/.tmp4iUnUY/bin/python /home/REDACTED/.cache/uv/builds-v0/.tmp4iUnUY/bin/python -c import sys

if sys.path[0] == "":
sys.path.pop(0)

sys.path = [] + sys.path

import wheel_stub.buildapi as backend

wheel_filename = backend.build_wheel("/home/REDACTED/.cache/uv/builds-v0/.tmpt5WLug", {}, None)
with open("/home/REDACTED/.cache/uv/builds` (dns block)

  • Triggering command: `/home/REDACTED/.cache/uv/builds-v0/.tmppOU1HV/bin/python /home/REDACTED/.cache/uv/builds-v0/.tmppOU1HV/bin/python -c import sys

if sys.path[0] == "":
sys.path.pop(0)

sys.path = [] + sys.path

import wheel_stub.buildapi as backend

wheel_filename = backend.build_wheel("/home/REDACTED/.cache/uv/builds-v0/.tmpmKS7yB", {}, None)
with open("/home/REDACTED/.cache/uv/builds` (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Version 1.6.0rc01: we need to see current learning_rate in progess bar</issue_title>
<issue_description>### Search before asking

  • I have searched the RF-DETR issues and found no similar feature requests.

Description

I tried the new 1.6.0rc01. It look neat but i need to monitor current learning_rate that will help me finetune the lr value when i use pretrained_weights. Please consider

Use case

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75%. Comparing base (0755e60) to head (4e0d532).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@          Coverage Diff           @@
##           develop   #809   +/-   ##
======================================
  Coverage       75%    75%           
======================================
  Files           91     91           
  Lines         6806   6817   +11     
======================================
+ Hits          5079   5089   +10     
- Misses        1727   1728    +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
Copilot AI changed the title [WIP] [ISSUE-1] Add current learning rate to progress bar Show current learning rate in training progress bar Mar 17, 2026
Copilot AI requested a review from Borda March 17, 2026 11:33
@Borda
Borda marked this pull request as ready for review March 17, 2026 11:38
Copilot AI review requested due to automatic review settings March 17, 2026 11:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds live learning-rate visibility during fine-tuning by logging the optimizer LR as a Lightning metric so it can appear in the tqdm progress bar.

Changes:

  • Log train/lr from the optimizer’s param group during RFDETRModule.training_step with prog_bar=True.
  • Add a unit test asserting train/lr is logged with prog_bar=True.
  • Require train/lr to exist in metrics.csv via the metrics CSV integration test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/rfdetr/training/module.py Logs train/lr each training step for progress-bar visibility.
tests/training/test_module.py Adds a unit test validating train/lr is logged to the progress bar.
tests/training/test_metrics_csv.py Adds train/lr to the required metrics.csv columns set.
Comments suppressed due to low confidence (1)

tests/training/test_metrics_csv.py:83

  • test_metrics_csv.py is described as enforcing the metric columns that plot_metrics() needs, but plot_metrics() currently only reads train/loss, val/loss, and test/loss (plus val/* AP/AR metrics). Adding train/lr here makes the test intent/documentation inconsistent and creates extra coupling; either update plot_metrics() to actually consume/plot LR, or keep this required-set limited to what the plotting code uses.
_REQUIRED_DETECTION = frozenset(
    {
        "train/loss",
        "train/lr",
        "val/loss",
        "val/mAP_50",
        "val/mAP_50_95",
        "val/mAR",
    }

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/rfdetr/training/module.py Outdated
Comment thread tests/training/test_module.py
Borda and others added 2 commits March 17, 2026 12:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Updated `train/lr` logging to always set `on_step=True` and `on_epoch=False` in training module.
- Added assertions in tests to validate these settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds visibility into the current learning rate during training by logging it to the Lightning progress bar (and ensuring it appears in metrics.csv), which helps users monitor scheduler behavior (warmup/decay/cosine) while fine-tuning.

Changes:

  • Log the optimizer learning rate as train/lr from RFDETRModule.training_step with prog_bar=True and step-level logging.
  • Add a unit test asserting train/lr is logged with progress-bar visibility.
  • Extend the metrics.csv integration test required-column set to include train/lr.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/rfdetr/training/module.py Logs current LR as train/lr during training_step for progress-bar visibility.
tests/training/test_module.py Adds a training-step unit test asserting train/lr is logged with prog_bar=True and step-only flags.
tests/training/test_metrics_csv.py Requires train/lr to exist and have non-NaN values in metrics.csv.
Comments suppressed due to low confidence (1)

tests/training/test_metrics_csv.py:83

  • _REQUIRED_DETECTION is described as the set of columns that plot_metrics() needs, but plot_metrics() currently only plots loss + val/* AP/AR metrics and does not use train/lr. Either update the test/module comments to reflect that this is an additional required metric beyond what plot_metrics() consumes, or extend plot_metrics() to handle/plot train/lr so the test intent matches the visualization behavior.
_REQUIRED_DETECTION = frozenset(
    {
        "train/loss",
        "train/lr",
        "val/loss",
        "val/mAP_50",
        "val/mAP_50_95",
        "val/mAR",
    }

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/rfdetr/training/module.py Outdated
Comment thread src/rfdetr/training/module.py Outdated
Borda and others added 2 commits March 17, 2026 13:15
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Added a real optimizer to tests for `param_groups` to ensure realistic "lr" key handling.
- Mocked optimizer return to align with the updated test setup.
@Borda
Borda merged commit 4087a88 into develop Mar 17, 2026
23 checks passed
@Borda
Borda deleted the copilot/add-learning-rate-progress-bar branch March 17, 2026 14:04
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.

Version 1.6.0rc: we need to see current learning_rate in progess bar

3 participants