Skip to content

Fix GenerationMixin compat with transformers>=5.14.0 - #1200

Merged
rwightman merged 1 commit into
mlfoundations:mainfrom
joan8627:fix/transformers-experts-implementation-compat
Jul 31, 2026
Merged

Fix GenerationMixin compat with transformers>=5.14.0#1200
rwightman merged 1 commit into
mlfoundations:mainfrom
joan8627:fix/transformers-experts-implementation-compat

Conversation

@joan8627

@joan8627 joan8627 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #1199

Summary

transformers 5.14.0 added a call to self.get_experts_implementation() inside GenerationMixin._optimize_model_for_decode(), invoked unconditionally from generate()'s decode loop. That method is only defined on transformers.PreTrainedModel, not on GenerationMixinitself.MultimodalGenerationWrapper (src/open_clip/generation.py) only inherits nn.Module+GenerationMixinby design -- it's a thin wrapper around open_clip's own generative models, not a fullPreTrainedModel-- so it breaks:AttributeError: 'MultimodalGenerationWrapper' object has no attribute 'get_experts_implementation'`. Full analysis and bisection in #1199.

Fix: a trivial override. This wrapper never has MoE submodels, so there's nothing to report -- an empty dict makes the caller's "grouped_mm" in experts_implementation.values() check a no-op, restoring correct behavior.

Test plan

  • tests/test_coca2.py (27 tests, including test_modern_coca_generate and all test_coca_generate_*) -- pass against transformers==5.14.1 (the actual broken version) with this fix, unpinned.
  • tests/test_naflex_mammut.py, tests/test_mammut.py -- all generate-related tests across MaMMUT/NaFlex variants also pass.
  • Confirmed the failure reproduces without this fix (same versions), and confirmed 85/85 tests pass across the three files with it.

@rwightman
rwightman merged commit fed5955 into mlfoundations:main Jul 31, 2026
4 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

2 participants