Repository navigation
Pin every tiny test model to a Hub commit - #8262
Conversation
|
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. |
|
Thanks, I'm in favour. I'd recommend 2 things before merging:
|
|
Thanks! Done: the pins are refreshed to the current Hub |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.

This PR pins every
trl-internal-testingmodel 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:head_dim, updated with Give the tiny Qwen2.5 model a head_dim Flash Attention accepts #8147) and CI fails for latest TRL release with dev dependencies for GPT-OSS and DeepSeek-V3: ValueError: You cannot perform fine-tuning on purely quantized models #8259 (tiny GPT-OSS and DeepSeek-V3 quantized, updated with Quantize the tiny DeepSeek-V3 and GPT-OSS models like their references (FP8, MXFP4) #8058). With the pins, neither failure would have happened: the release tests would have kept the tiny models they were released with. For the same reason, checking out an older commit tests it against today's models, which makes bisecting unreliable.tiny-RemoteForCausalLMships Python code that the tests run withtrust_remote_code=True, in CI jobs that holdHF_TOKEN. Anyone able to push to that repo can change the code CI runs.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
mainare not affected by this PR.Solution
MODEL_REVISIONSintests/conftest.pyalready 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 atrl-internal-testingmodel that isn't inMODEL_REVISIONS, so a new tiny model can't stay unpinned.The tests that run the training scripts in a child process (
torchrunin the distributed tests,trl <command>in the CLI tests) still load the Hub'smain: they don't go through theconftest.pyfixtures. Onmain, 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
tests/conftest.py, and point to it fromscripts/generate_tiny_models/README.mdMODEL_REVISIONSis never emptytrl-internal-testingmodel that isn't pinnedNote
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
mainupdates (includingtrust_remote_codetiny models).Overview
Every
trl-internal-testingfixture used in pytest is now listed inMODEL_REVISIONSwith a fixed Hub commit sha, and the existingapply_model_revisionsfixture always rewritesrevision(and clears_commit_hashwhen needed) for transformers and PEFT loaders so tests no longer track movingmain.A new
check_pinnedguard fails fast if anytrl-internal-testing/model is loaded withrevisionunset ormainbut missing from the dict.scripts/generate_tiny_models/README.mdpoints authors at the update workflow documented intests/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.