Skip to content

Conversation

@pockers21
Copy link

@pockers21 pockers21 commented Nov 3, 2025

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:

  • Transformers v4.46.2 does NOT contain integrations.use_kernel_forward_from_hub.
  • Transformers v4.53.3 adds both, and Qwen3 code relies on them.
  • requiments.txt also contains transformers 4.53.x

This PR aligns setup.py dependency pins so pip install . pulls a compatible Transformers version.

Repro (source-based, no install)

Directory: any scratch dir (e.g., /root/tmp/tf_src). The repository layout uses src/transformers/....

  1. Download tag tarballs and extract
BASE=/root/tmp/tf_src
mkdir -p "$BASE" && cd "$BASE"
source /etc/network_turbo 2>/dev/null || true
wget -q https://github.com/huggingface/transformers/archive/refs/tags/v4.46.2.tar.gz -O transformers-v4.46.2.tar.gz
wget -q https://github.com/huggingface/transformers/archive/refs/tags/v4.53.3.tar.gz -O transformers-v4.53.3.tar.gz
tar -xzf transformers-v4.46.2.tar.gz
tar -xzf transformers-v4.53.3.tar.gz
  1. Old (4.46.2) — symbol and module are missing
test -f transformers-4.46.2/src/transformers/integrations/hub_kernels.py || echo '4.46.2: hub_kernels.py MISSING'
rg -n 'use_kernel_forward_from_hub' transformers-4.46.2/src/transformers || \
  grep -Rnw 'use_kernel_forward_from_hub' transformers-4.46.2/src/transformers || echo '4.46.2: NOT FOUND'

sed -n '1,120p' transformers-4.46.2/src/transformers/integrations/__init__.py
  1. New (4.53.3) — symbol and module exist and are used
ls transformers-4.53.3/src/transformers/integrations | grep hub_kernels.py   # => hub_kernels.py

sed -n '55,100p' transformers-4.53.3/src/transformers/integrations/hub_kernels.py

rg -n 'use_kernel_forward_from_hub' transformers-4.53.3/src/transformers/models | head

Conclusion: v4.46.2 lacks APIs required by Qwen3; import failure is due to missing symbols, not environment quirks.

Fix & Verification

Change setup.py install_requires to match requirements.txt and ensure a compatible Transformers is installed via pip install .:

  • torch>=2.6.0
  • transformers>=4.53.3,<5
  • accelerate>=0.26.0

Verification options:

repro_min.py

  • Minimal runtime import check (after installing the above deps):
    import sys
    print("python:", sys.version)
    try:
        from eagle.model.ea_model import EaModel  # noqa: F401
        print("EAGLE import OK")
    except Exception as e:
        print("EAGLE import FAIL:", repr(e))
        raise
     # should print: EAGLE import OK
    

Notes

  • pip install . follows setup.py’s install_requires; it does not automatically honor requirements.txt. Therefore the pins must be corrected in setup.py.
  • Upper bound <5 on Transformers is added as a safety guard.
  • This PR does not change runtime behavior; it fixes local install/import failure.

Compatibility note (Transformers 4.53.1 / 4.53.3): GenerationMixin import

  • Symptom (with 4.53.x):
    • ImportError: cannot import name 'GenerationMixin' from 'transformers.generation'
  • Root cause:
    • In Transformers ≥4.53, GenerationMixin is no longer re-exported from transformers.generation/__init__.py; it lives in transformers.generation.utils.
  • Minimal fix (no behavior change):
    • Replace occurrences of:
      • from transformers.generation import GenerationMixin
    • With:
      • from transformers.generation.utils import GenerationMixin

Code 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.py
      • from transformers.generation import GenerationMixin
      • from transformers.generation.utils import GenerationMixin
    • eagle/model/modeling_qwen3_kv.py
      • from transformers.generation import GenerationMixin
      • from transformers.generation.utils import GenerationMixin
  • Formatting (no‑op):

    • eagle/model/ea_model.py
      • add final newline (no functional change)

@pockers21 pockers21 changed the title fix(qwen3): require Transformers≥4.53.3 and update GenerationMixin import fix(qwen2/3): require Transformers≥4.53.3 and update GenerationMixin import Nov 3, 2025
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.

1 participant