Repository navigation
Inject the model revision into concrete config loads too - #7099
Merged
Merged
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. |
Member
Author
|
Merging this PR as a trivial fix in CI. |
17 tasks done
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.
This PR makes the
MODEL_REVISIONSoverride apply to concrete config classes as well, so a tiny model under test is read at the pinned revision everywhere.Motivation
apply_model_revisionspatchesfrom_pretrainedon theAuto*classes and onPreTrainedModel,PreTrainedTokenizerBaseandProcessorMixin, but not on the base config class.AutoConfigis a factory and never appears in a concrete config's MRO:so a caller that reaches for the concrete class slips past the override.
peftdoes exactly that when deciding whether the embedding was resized:The model is loaded at the revision under test while its base config is read from the default branch, so any fixture PR that changes
vocab_sizemakes the two disagree and every PEFT test emits:That is 34 spurious warnings while validating #7098, and it also means
save_embedding_layersis silently forced on in those tests.Solution
Add the base config class to the patched set. Concrete configs do not define their own
from_pretrained, so they inherit the patched one.PretrainedConfigis the spelling that works across the supported range: 4.56.2 exports only that name, while 5.x exports both it andPreTrainedConfigpointing at the same object.Verification
Ran the suite with
MODEL_REVISIONSpinned to the #7098 fixture PRs, with and without this change:save_embedding_layerswarningsPAD/BOS/EOSvariantshttps://github.com/huggingface/trl/actions/runs/34141451081/job/101804124860
The token realignment counts are the control and are unchanged, confirming the patch does not alter which revision the model itself loads from. Total lines differ by 3 (463 against 460) purely because the earlier run had 4 reruns and this one had none.
With
MODEL_REVISIONSempty, which is its state onmain, the fixture returns early and nothing is patched at all.Changes
from_pretrainedon the base config class alongside theAuto*and other base classesNote
Low Risk
Test-only conftest change; no production code paths, and patching is skipped when
MODEL_REVISIONSis empty on main.Overview
Extends the
apply_model_revisionspytest fixture soMODEL_REVISIONSalso applies when configs are loaded through concrete config classes (e.g.Qwen2Config.from_pretrained), not onlyAutoConfigand model/tokenizer loaders.PretrainedConfigis added to the patched classes and imports (using thePretrainedConfigspelling for compatibility across transformers 4.x/5.x). Concrete configs inheritfrom_pretrainedfrom that base, so pinned Hub revisions now apply consistently when libraries such as PEFT reload config by class.This removes config-at-default-branch vs weights-at-pinned-revision mismatches during tiny-model PR CI (e.g. spurious
save_embedding_layerswarnings). WhenMODEL_REVISIONSis empty, the fixture still exits early and behavior is unchanged.Reviewed by Cursor Bugbot for commit 1219797. Bugbot is set up for automated code reviews on this repo. Configure here.