fix(qwen2/3): require Transformers≥4.53.3 and update GenerationMixin import #310
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.
Background
Importing the EAGLE Qwen3 path (
from eagle.model.ea_model import EaModel) fails under old Transformers because required APIs are missing. From the source point of view:integrations.use_kernel_forward_from_hub.This PR aligns
setup.pydependency pins sopip install .pulls a compatible Transformers version.Repro (source-based, no install)
Directory: any scratch dir (e.g.,
/root/tmp/tf_src). The repository layout usessrc/transformers/....Conclusion: v4.46.2 lacks APIs required by Qwen3; import failure is due to missing symbols, not environment quirks.
Fix & Verification
Change
setup.pyinstall_requires to matchrequirements.txtand ensure a compatible Transformers is installed viapip install .:torch>=2.6.0transformers>=4.53.3,<5accelerate>=0.26.0Verification options:
repro_min.py
Notes
pip install .followssetup.py’sinstall_requires; it does not automatically honorrequirements.txt. Therefore the pins must be corrected insetup.py.<5on Transformers is added as a safety guard.Compatibility note (Transformers 4.53.1 / 4.53.3): GenerationMixin import
ImportError: cannot import name 'GenerationMixin' from 'transformers.generation'GenerationMixinis no longer re-exported fromtransformers.generation/__init__.py; it lives intransformers.generation.utils.from transformers.generation import GenerationMixinfrom transformers.generation.utils import GenerationMixinCode changes (summary)
To make the codebase work with Transformers ≥4.53.x (required by Qwen3 for
integrations.use_kernel_forward_from_hub), this PR contains only compatibility‑scoped edits. No algorithm or behavior is changed.Compatibility (import‑path) updates:
eagle/model/modeling_qwen2_kv.pyfrom transformers.generation import GenerationMixinfrom transformers.generation.utils import GenerationMixineagle/model/modeling_qwen3_kv.pyfrom transformers.generation import GenerationMixinfrom transformers.generation.utils import GenerationMixinFormatting (no‑op):
eagle/model/ea_model.py