Skip to content

refine(repro): enable deterministic algorithms - #1307

Merged
Borda merged 3 commits into
developfrom
test/stabilize-seg-convergence-flake
Aug 7, 2026
Merged

Borda merged 3 commits into
developfrom
test/stabilize-seg-convergence-flake

Conversation

@Borda

@Borda Borda commented Aug 7, 2026

Copy link
Copy Markdown
Member

This pull request improves reproducibility and updates a synthetic training benchmark test. The main changes include making PyTorch's deterministic algorithms setting more robust and updating the segmentation convergence test to run for an additional epoch.

Reproducibility improvements:

  • Enhanced the seed_all function to use torch.use_deterministic_algorithms with warn_only=True, ensuring deterministic operations where possible and logging a warning if full determinism can't be enabled instead of raising an error. [1] [2]

Benchmark test updates:

  • Updated the segmentation convergence test in test_train_convergence_segmentation to check results after 6 epochs instead of 5, and to run for 6 epochs, improving test reliability. [1] [2]

- seed_all now calls torch.use_deterministic_algorithms(True, warn_only=True) after the cuDNN flags, so every op with a deterministic kernel uses it and the rest warn at execution time instead of raising
- guard the call with try/except RuntimeError, logging via get_logger so a failure to enable determinism degrades to a warning rather than propagating out of seed_all
- import get_logger in reproducibility
- test_train_convergence_segmentation: raise epochs 5 -> 6 and update the docstring epoch references, widening the convergence margin above GPU run-to-run noise

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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 targets improved experiment reproducibility by enabling PyTorch’s deterministic algorithms mode (best-effort, warning on unsupported ops) and adjusts the synthetic segmentation training convergence benchmark to run for one additional epoch to stabilize results.

Changes:

  • Update seed_all() to call torch.use_deterministic_algorithms(True, warn_only=True) and warn (instead of raising) if determinism cannot be enabled.
  • Update the synthetic segmentation convergence benchmark to train for 6 epochs (and update the corresponding docstring assertions).

Reviewed changes

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

File Description
src/rfdetr/utilities/reproducibility.py Enables PyTorch deterministic algorithms mode with guarded warning behavior; updates reproducibility-related documentation/comments.
tests/benchmarks/test_training_synthetic.py Extends the segmentation convergence benchmark from 5 to 6 epochs and updates the test docstring accordingly.

Comment thread src/rfdetr/utilities/reproducibility.py
Comment thread src/rfdetr/utilities/reproducibility.py Outdated
Comment thread tests/benchmarks/test_training_synthetic.py Outdated
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84%. Comparing base (5c7ce81) to head (933be50).

❌ Your patch check has failed because the patch coverage (60%) is below the target coverage (95%). You can increase the patch coverage or adjust the target coverage.
❌ Your project check has failed because the head coverage (84%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #1307   +/-   ##
=======================================
- Coverage       84%     84%   -0%     
=======================================
  Files          110     110           
  Lines        13623   13628    +5     
=======================================
+ Hits         11454   11457    +3     
- Misses        2169    2171    +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Borda and others added 2 commits August 7, 2026 14:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Reformatted multi-line comment in `seed_all` to improve clarity and adhere to line length conventions.
@Borda
Borda merged commit 22da513 into develop Aug 7, 2026
40 checks passed
@Borda
Borda deleted the test/stabilize-seg-convergence-flake branch August 7, 2026 13:41
Borda added a commit that referenced this pull request Aug 11, 2026
- seed_all now calls torch.use_deterministic_algorithms(True, warn_only=True) after the cuDNN flags, so every op with a deterministic kernel uses it and the rest warn at execution time instead of raising
- guard the call with try/except RuntimeError, logging via get_logger so a failure to enable determinism degrades to a warning rather than propagating out of seed_all
- import get_logger in reproducibility
- test_train_convergence_segmentation: raise epochs 5 -> 6 and update the docstring epoch references, widening the convergence margin above GPU run-to-run noise

---------

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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