Skip to content

Forward the requested revision to every remote-code force-import - #1819

Merged
jlarson4 merged 2 commits into
TransformerLensOrg:devfrom
YHC66:fix-dream-forward-revision
Sep 28, 2026
Merged

jlarson4 merged 2 commits into
TransformerLensOrg:devfrom
YHC66:fix-dream-forward-revision

Conversation

@YHC66

@YHC66 YHC66 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #1810, as suggested in #1810 (comment).

prepare_loading force-imports remote-code classes so their modeling module is in sys.modules to patch. Each Hub revision is its own module copy, and these force-imports always used the default revision, so with boot(..., revision=...) the pinned copy that from_pretrained imports afterwards never got the patches. #1810 fixed this for restore_default_rope_init; this PR forwards model_kwargs.get("revision") at the remaining force-import sites:

  • Dream: DreamGenerationConfig and DreamAttention
  • BD3LM, GIDD, InternLM2, OpenELM, Ouro, Raven, RWKV-7 (fallback path when fla is not installed)

With no revision given, revision=None is what get_class_from_dynamic_module already defaults to, so the unpinned path is unchanged.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

Testing (Python 3.12, macOS, transformers from the lock file):

  • New test_prepare_loading_imports_the_requested_revision in tests/unit/model_bridge/test_prepare_loading_orchestration.py, parametrized over all nine remote-code adapters: it stubs get_class_from_dynamic_module, calls prepare_loading with {"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.
  • black, isort and pycln are clean on the changed files.

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 jlarson4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for picking this up! One comment, on the test's adapter list.

Comment thread tests/unit/model_bridge/test_prepare_loading_orchestration.py
@jlarson4
jlarson4 merged commit a5e1970 into TransformerLensOrg:dev Sep 28, 2026
27 checks passed
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.

2 participants