Skip to content

ci: add legacy-checkpoint backward-compat workflow and test suite#994

Open
Borda wants to merge 11 commits into
developfrom
ci/legacy
Open

ci: add legacy-checkpoint backward-compat workflow and test suite#994
Borda wants to merge 11 commits into
developfrom
ci/legacy

Conversation

@Borda
Copy link
Copy Markdown
Member

@Borda Borda commented Apr 24, 2026

This pull request introduces a robust system for automated backward-compatibility testing of RF-DETR model checkpoints across historical releases. It adds a new GitHub Actions workflow that generates checkpoints using past package versions and verifies that the current codebase can load them, ensuring seamless upgrades for users. The implementation includes test infrastructure, configuration files, and scripts for checkpoint generation and validation.

The most important changes are:

Continuous Integration: Backward-Compatibility Workflow

  • Added .github/workflows/ci-legacy-checkpoints.yml, a new GitHub Actions workflow that (1) reads a list of historical versions, (2) generates a checkpoint with each version, (3) uploads artifacts, and (4) runs compatibility tests with the current codebase.
  • Updated .github/workflows/ci-tests-cpu.yml and .github/workflows/ci-tests-gpu.yml to exclude the new legacy tests from standard test jobs, ensuring they only run in the dedicated compatibility workflow. [1] [2]

Test Infrastructure: Checkpoint Generation and Validation

  • Added tests/legacy/generate_checkpoint.py, a script that generates minimal checkpoints using a specified released version of rfdetr, handling API differences across versions.
  • Added tests/legacy/test_checkpoint_compat.py, a test suite that loads each generated checkpoint with the current codebase, verifying successful loading and expected model structure.

Configuration: Version Matrix

  • Added tests/legacy/checkpoint_versions.txt to specify which historical rfdetr versions are included in the compatibility test matrix.

closes #990

- Add tests/legacy/ with checkpoint_versions.txt (1.4.0–1.6.0), generate_checkpoint.py (creates a .pth from the installed rfdetr version), and test_checkpoint_compat.py (18 parametrized tests; auto-skip locally when checkpoint files absent)
- Add .github/workflows/ci-legacy-checkpoints.yml: reads versions file → parallel matrix jobs install old rfdetr and generate checkpoints → test-compat job loads all with current code
- Exclude tests/legacy/ from ci-tests-cpu and ci-tests-gpu via --ignore

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 24, 2026 11:37
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80%. Comparing base (4771607) to head (32289ae).
⚠️ Report is 1 commits behind head on develop.

❌ Your project check has failed because the head coverage (80%) 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   #994   +/-   ##
======================================
  Coverage       80%    80%           
======================================
  Files          100    100           
  Lines         8392   8392           
======================================
  Hits          6676   6676           
  Misses        1716   1716           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated CI workflow and accompanying test/scripts to continuously validate that the current RF-DETR code can load checkpoints produced by older released versions, helping prevent backward-compatibility regressions for users upgrading across releases.

Changes:

  • Added a new GitHub Actions workflow that builds a version matrix, generates per-version checkpoints, and runs compatibility tests against current source.
  • Introduced tests/legacy/ tooling: a checkpoint generator script, a parametrized compatibility test suite, and a versions matrix file.
  • Updated existing CPU/GPU test workflows to exclude the legacy compatibility tests from standard CI runs.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/legacy/test_checkpoint_compat.py New pytest suite to load legacy-generated checkpoints with current code.
tests/legacy/generate_checkpoint.py Script to generate minimal checkpoints using an installed historical rfdetr version.
tests/legacy/checkpoint_versions.txt Version list driving the backward-compat matrix.
.github/workflows/ci-legacy-checkpoints.yml New CI workflow to generate legacy checkpoints and run compat tests.
.github/workflows/ci-tests-cpu.yml Excludes tests/legacy from standard CPU test jobs.
.github/workflows/ci-tests-gpu.yml Excludes tests/legacy from standard GPU test jobs.
.gitignore Ignores .developments/ directory.

Comment thread tests/legacy/test_checkpoint_compat.py Outdated
Comment thread tests/legacy/test_checkpoint_compat.py
Comment thread tests/legacy/generate_checkpoint.py Outdated
Comment thread .github/workflows/ci-legacy-checkpoints.yml Outdated
@roboflow roboflow deleted a comment from Copilot AI Apr 24, 2026
Borda and others added 8 commits April 24, 2026 13:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add a scoped transformers.pytorch_utils compatibility shim so old RF-DETR releases, including 1.4, can import during checkpoint generation.

Co-authored-by: Codex <codex@openai.com>
Add scoped transformers compatibility shims so old RF-DETR releases, including 1.4, can import removed pruning and backbone helpers during checkpoint generation.

Co-authored-by: Codex <codex@openai.com>
…uild_model, generate_checkpoint

- TestGetStateDict: three-level layout, legacy two-level fallback, RuntimeError on invalid model
- TestGetPatchSize: model_config path, config fallback, default-16 fallback
- TestBuildModel: preferred-class missing falls through to RFDETRBase; all candidates absent raises RuntimeError
- TestGenerateCheckpoint: integration smoke-test verifies model/args/epoch/rfdetr_version keys

[resolve #4] /review finding by foundry:qa-specialist (report: .temp/output-review-ci-legacy-2026-04-24.md):
"No test for generate_checkpoint.py — _get_state_dict, _get_patch_size, _build_model, generate_checkpoint have no unit tests"

---
Co-authored-by: Claude Code <noreply@anthropic.com>
v1.6.5 is the version reported broken in #990 (PE interpolation shape
mismatch). Including it catches the specific regression class.

Comments explain why 1.1.0–1.3.0 remain disabled (pretrain_weights=None
not supported before 1.4.0).

[resolve #6] /review finding by foundry:qa-specialist (report: .temp/output-review-ci-legacy-2026-04-24.md):
"Version matrix omits 1.6.5 (the reported broken release); no comment on why 1.1–1.3 disabled"

---
Co-authored-by: Claude Code <noreply@anthropic.com>
…ons unit tests

- _pytest_params: locally skip missing checkpoints; in CI (CI=true) run the
  test so artifact download failures cause a visible assertion error instead
  of a silent skip
- _read_versions: accept optional path parameter so callers can inject a
  file directly — removes need for module-level monkeypatching in tests
- TestReadVersions: five parametrized cases covering blank lines, comment
  lines, surrounding whitespace, empty file, and non-existent file

[resolve #2] @Copilot inline (gh): "missing checkpoints silently skipped in CI masks regressions" (test_checkpoint_compat.py:81)
[resolve #8] /review finding by foundry:qa-specialist (report: .temp/output-review-ci-legacy-2026-04-24.md):
"No test for _read_versions() with malformed input"

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Adds test_generate_checkpoint.py to the pytest invocation so unit tests
for the generation helpers (_get_state_dict, _get_patch_size, _build_model,
generate_checkpoint) also run in CI against the installed dev package.

---
Co-authored-by: Claude Code <noreply@anthropic.com>
Borda and others added 2 commits April 24, 2026 18:32
…formers v5

- Add _init_backbone_shim that sets stage_names, _out_features, _out_indices,
  num_features from config — mirrors the v4 BackboneMixin method that transformers
  v5 removed (replaced by cooperative-MRO __init__ → _init_transformers_backbone)
- _install_transformers_compat() patches the shim onto BackboneMixin if absent,
  alongside the existing find_pruneable_heads_and_indices and
  get_aligned_output_features_output_indices shims
- Add unit test verifying the shim is installed and sets expected attributes

---
Co-authored-by: Claude Code <noreply@anthropic.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.

v1.6.5 breaks model loading for me

2 participants