Skip to content

Fix GPU benchmark lazy device placement - #22

Merged
Borda merged 1 commit into
mainfrom
copilot/fix-gpu-tests-issue
Apr 16, 2026
Merged

Borda merged 1 commit into
mainfrom
copilot/fix-gpu-tests-issue

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

  • Tests pass
  • Docs if needed
  • pre-commit passes

Changes

The GPU COCO benchmark was forwarding CUDA tensors through a model whose weights were still on CPU. This regressed after RF-DETR moved to lazy device placement, which the benchmark bypasses by calling the raw model directly.

  • Benchmark device sync

    • Move the underlying nn.Module onto the requested test device immediately after model construction in the GPU/CPU benchmark path.
    • Keep the fix scoped to the benchmark that uses rfdetr.model.model(...) directly.
  • Behavioral intent

    • Align the test with current RF-DETR initialization semantics without changing library code.
    • Preserve the existing benchmark flow and thresholds.
rfdetr = model_cls(device=device)
rfdetr.model.model = rfdetr.model.model.to(device)

Related

@Borda
Borda marked this pull request as ready for review April 16, 2026 20:02
Copilot AI review requested due to automatic review settings April 16, 2026 20:02
@Borda Borda added the bug Something isn't working label Apr 16, 2026

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

Fixes the COCO GPU inference benchmark in rfdetr_plus tests when RF-DETR uses lazy device placement, by ensuring the underlying nn.Module weights are moved onto the benchmark’s selected device before directly calling the raw model.

Changes:

  • Explicitly moves rfdetr.model.model to the chosen device in the COCO detection inference benchmark.
  • Adds inline comments explaining why the benchmark must materialize device placement (since it bypasses public inference APIs).

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (5ac42d6) to head (ca45e8e).

Additional details and impacted files
@@        Coverage Diff         @@
##           main   #22   +/-   ##
==================================
  Coverage    94%   94%           
==================================
  Files         6     6           
  Lines        71    71           
==================================
  Hits         67    67           
  Misses        4     4           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda
Borda merged commit 3a0c5c8 into main Apr 16, 2026
17 checks passed
@Borda
Borda deleted the copilot/fix-gpu-tests-issue branch April 16, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants