Skip to content

Pin every tiny test model to a Hub commit - #8262

Merged
albertvillanova merged 3 commits into
mainfrom
pin-tiny-model-revisions
Nov 23, 2026
Merged

albertvillanova merged 3 commits into
mainfrom
pin-tiny-model-revisions

Conversation

@albertvillanova

@albertvillanova albertvillanova commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

This PR pins every trl-internal-testing model the tests load to a commit sha of its Hub repo, so that each TRL commit, PR and release tests against the exact files it was written for.

Motivation

Tiny models are test fixtures, but the tests load them from the Hub's main, which changes over time:

A Hub commit sha is a git hash of the content, so a pin fixes code, weights, tokenizer and chat template. This is how the repo already treats its other CI inputs: every GitHub Action is pinned by sha and updated through a reviewed PR.

This addresses TRL's own side of #8234: the other repos that load these tiny models from the Hub's main are not affected by this PR.

Solution

MODEL_REVISIONS in tests/conftest.py already injects a revision into the transformers and PEFT loaders. It was only used for a temporary commit pointing at a Hub PR ref, to run CI against a proposed tiny model before merging it. It now also permanently pins every tiny model. A tiny model update still starts with that temporary commit. Once CI is green and the Hub PR is merged, the PR ref is replaced with the commit sha the merge created, and the TRL PR is merged with it. A release carries the pins of its commit, so it needs no extra step. The fixture raises when a test loads a trl-internal-testing model that isn't in MODEL_REVISIONS, so a new tiny model can't stay unpinned.

The tests that run the training scripts in a child process (torchrun in the distributed tests, trl <command> in the CLI tests) still load the Hub's main: they don't go through the conftest.py fixtures. On main, they differ from the pinned tests only between the Hub merge and the TRL merge, but on a release branch they get every later tiny model update. I will pin them too in a follow-up PR.

Changes

  • Pin the 72 tiny models used by the tests to their current Hub commit
  • Document the update procedure in tests/conftest.py, and point to it from scripts/generate_tiny_models/README.md
  • Always apply the revision wrapper, now that MODEL_REVISIONS is never empty
  • Raise when a test loads a trl-internal-testing model that isn't pinned

Note

Medium Risk
Changes how every CI test loads remote Hub weights and adapters; a missing or wrong pin will break the suite, but behavior is more predictable and limits unreviewed Hub main updates (including trust_remote_code tiny models).

Overview
Every trl-internal-testing fixture used in pytest is now listed in MODEL_REVISIONS with a fixed Hub commit sha, and the existing apply_model_revisions fixture always rewrites revision (and clears _commit_hash when needed) for transformers and PEFT loaders so tests no longer track moving main.

A new check_pinned guard fails fast if any trl-internal-testing/ model is loaded with revision unset or main but missing from the dict. scripts/generate_tiny_models/README.md points authors at the update workflow documented in tests/conftest.py (Hub PR ref → merge → record final sha).

Reviewed by Cursor Bugbot for commit 61b60c4. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added the 🔧 maintenance CI, tooling, tests, or repo upkeep label Nov 12, 2026
@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Comment thread tests/conftest.py Resolved
@qgallouedec

Copy link
Copy Markdown
Member

Thanks, I'm in favour.
Since you opened this, 3/72 tiny models were updated on the Hub, each with its own TRL PR (e.g. #8415), so a pin costs one line in a PR that already exists, while v1.18-release tests against all 30 new versions.

I'd recommend 2 things before merging:

  • refresh the pins: 30 are behind the Hub main, tiny-Inkling2LoopForConditionalGeneration is missing (added yesterday), and tiny-Llama4ForCausalLM is no longer used
  • raise in the fixture when a trl-internal-testing/ model isn't in MODEL_REVISIONS, otherwise new models will silently stay unpinned

@albertvillanova

Copy link
Copy Markdown
Member Author

Thanks! Done: the pins are refreshed to the current Hub main (30 updated, tiny-Inkling2LoopForConditionalGeneration added, tiny-Llama4ForCausalLM removed), and the fixture now raises when a test loads a trl-internal-testing model that isn't in MODEL_REVISIONS.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 61b60c4. Configure here.

Comment thread tests/conftest.py Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 maintenance CI, tooling, tests, or repo upkeep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants