Proposal: avoid unsupported TorchScript on Python 3.14 - #1406
Open
cdeil wants to merge 1 commit into
Open
Conversation
cdeil
requested review from
Borda,
SkalskiP,
isaacrob and
probicheaux
as code owners
August 26, 2026 11:06
Author
|
I have read the CLA Document and I sign the CLA. |
cdeil
force-pushed
the
fix/python314-torchscript-fallback
branch
from
August 26, 2026 11:38
49e08c1 to
ae91778
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes RF-DETR’s top-level import compatible with Python 3.14+ by avoiding module-import-time TorchScript compilation (torch.jit.script), while keeping the existing scripted aliases on currently supported Python versions.
Changes:
- Add a Python-version-gated eager fallback for the four import-time TorchScripted loss helpers in
box_ops.pyandcriterion.py. - Add a subprocess regression test that fails if a
torch.jit.scriptdeprecation warning is emitted duringimport rfdetr. - Expand CPU CI to include Python 3.14 and update package/documentation metadata to advertise 3.14 support.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/utilities/test_package.py | Adds an import-time warning-as-error subprocess regression test for torch.jit.script. |
| src/rfdetr/utilities/box_ops.py | Avoids torch.jit.script at import time on Python 3.14+ via eager alias fallback. |
| src/rfdetr/models/criterion.py | Avoids torch.jit.script at import time on Python 3.14+ and updates in-file commentary about the eager alias boundary. |
| pyproject.toml | Adds the Python 3.14 classifier. |
| AGENTS.md | Updates stated tested Python range and CI CPU workflow description to include 3.14. |
| .github/workflows/ci-tests-cpu.yml | Adds Python 3.14 to the Ubuntu CPU test matrix. |
| .github/CONTRIBUTING.md | Updates contributor docs to list Python 3.14 as supported/tested. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+285
to
286
| - **Python Versions:** 3.10, 3.11, 3.12, 3.13, 3.14 | ||
| - **CPU Workflow:** `pytest -m "not gpu"` - Runs on all OS/Python combinations |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1406 +/- ##
=======================================
- Coverage 86% 86% -0%
=======================================
Files 114 114
Lines 14880 14882 +2
=======================================
- Hits 12835 12784 -51
- Misses 2045 2098 +53 🚀 New features to boost your workflow:
|
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
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.
Hi! While checking RF-DETR on Python 3.14, I saw this warning during a normal top-level import with PyTorch 2.13:
Would you be interested in handling it with the conditional eager fallback proposed here?
Evidence
Importing
rfdetrexecutes four module-leveltorch.jit.scriptcalls:batch_dice_lossandbatch_sigmoid_ce_lossdice_lossandsigmoid_ce_lossWith the warning promoted to an error, current
developstops at the first site:The existing dependency-resolution matrix includes Python 3.14, but it only performs an install-plan dry run. The executable CPU test matrix currently stops at Python 3.13, so it cannot observe an import-time warning. A fresh install using the CPU workflow's command currently resolves PyTorch 2.13 and reproduces it.
Proposed behavior
This does not appear to be a performance issue at import time: seven fresh-process imports were effectively unchanged (1.982 s vs. 1.970 s median), and the four top-level scripting calls accounted for roughly 8 ms. A small CPU loss microbenchmark also showed identical outputs and only microseconds of eager overhead (Dice: 21.9 vs. 20.0 µs; sigmoid CE: 44.8 vs. 44.7 µs). The motivation is avoiding an explicitly unsupported path before it becomes a failure.
Validation
developatbox_ops.py:210.pre-commit run --all-filespassed in the documented Python 3.10 tooling environment.Would this conditional eager fallback be the compatibility policy you prefer, or would you rather remove or replace these TorchScript aliases more broadly?