Repository navigation
Forward the requested revision to every remote-code force-import - #1819
Merged
jlarson4 merged 2 commits intoSep 28, 2026
Merged
Conversation
prepare_loading force-imports remote modeling classes so their modules land in sys.modules to patch. Each Hub revision is its own module copy, and only the default revision was imported, so a pinned revision=... loaded by from_pretrained afterwards got an unpatched copy. TransformerLensOrg#1810 fixed this for restore_default_rope_init; do the same for Dream's DreamGenerationConfig and DreamAttention imports and for the BD3LM, GIDD, InternLM2, OpenELM, Ouro, Raven and RWKV-7 adapters.
jlarson4
reviewed
Sep 28, 2026
jlarson4
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for picking this up! One comment, on the test's adapter list.
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.
Description
Follow-up to #1810, as suggested in #1810 (comment).
prepare_loadingforce-imports remote-code classes so their modeling module is insys.modulesto patch. Each Hub revision is its own module copy, and these force-imports always used the default revision, so withboot(..., revision=...)the pinned copy thatfrom_pretrainedimports afterwards never got the patches. #1810 fixed this forrestore_default_rope_init; this PR forwardsmodel_kwargs.get("revision")at the remaining force-import sites:DreamGenerationConfigandDreamAttentionflais not installed)With no revision given,
revision=Noneis whatget_class_from_dynamic_modulealready defaults to, so the unpinned path is unchanged.Type of change
Checklist:
Testing (Python 3.12, macOS, transformers from the lock file):
test_prepare_loading_imports_the_requested_revisionintests/unit/model_bridge/test_prepare_loading_orchestration.py, parametrized over all nine remote-code adapters: it stubsget_class_from_dynamic_module, callsprepare_loadingwith{"revision": "abc123"}and checks every force-import received that revision. Before this change 8 of 9 fail (LLaDA2-MoE already passes after Keep Dream/LLaDA2 rope shim out of the shared ROPE_INIT_FUNCTIONS #1810).tests/unit/model_bridge -m "not slow": 4529 passed, 0 failed.