Skip to content

Compatible with transformers 5.0 at TurboMind side#4304

Open
lvhan028 wants to merge 7 commits intoInternLM:mainfrom
lvhan028:compatible-transformers-5.0
Open

Compatible with transformers 5.0 at TurboMind side#4304
lvhan028 wants to merge 7 commits intoInternLM:mainfrom
lvhan028:compatible-transformers-5.0

Conversation

@lvhan028
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings January 28, 2026 10:02
@lvhan028 lvhan028 requested review from Copilot and lzhangzz and removed request for Copilot January 28, 2026 10:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make lmdeploy compatible with transformers 5.0 at the TurboMind side. Transformers 5.0 introduced a breaking change where rope-related parameters (including rope_theta and rope_scaling) are now aggregated into a single rope_parameters dictionary in the model configuration.

Changes:

  • Removed unused utility functions from lmdeploy/vl/model/utils.py including weight loading helpers and import hacks
  • Added support for the new rope_parameters structure in transformers 5.0 for LlamaModel while maintaining backward compatibility with older versions
  • Added similar rope_parameters support for DeepSeek2Model

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lmdeploy/vl/model/utils.py Cleaned up by removing unused functions: load_weight_ckpt, get_used_weight_files, load_model_from_weight_files, add_sys_path, and hack_import_with
lmdeploy/turbomind/deploy/source_model/llama.py Added conditional logic to check for rope_parameters (transformers 5.0) and extract rope_theta and rope_scaling from it, with fallback to the old structure for backward compatibility
lmdeploy/turbomind/deploy/source_model/deepseek2.py Added similar conditional logic to handle rope_parameters for DeepSeek2 models

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@RunningLeon RunningLeon left a comment

Choose a reason for hiding this comment

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

v5 broke for vl model

lmdeploy/lmdeploy/vl/model/utils.py", line 12, in <module>
from transformers.utils import (SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, WEIGHTS_INDEX_NAME, WEIGHTS_NAME,
ImportError: cannot import name 'is_safetensors_available' from 'transformers.utils' (/nvme1/xxx/miniconda3/envs/py310/lib/python3.10/site-packages/transformers/utils/__init__.py)

@lvhan028 lvhan028 force-pushed the compatible-transformers-5.0 branch from b855b0c to 2e214ad Compare February 26, 2026 06:58
@lvhan028 lvhan028 force-pushed the compatible-transformers-5.0 branch from d305d5b to eb70216 Compare February 27, 2026 08:51
@lvhan028
Copy link
Collaborator Author

v5 broke for vl model

lmdeploy/lmdeploy/vl/model/utils.py", line 12, in <module>
from transformers.utils import (SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, WEIGHTS_INDEX_NAME, WEIGHTS_NAME,
ImportError: cannot import name 'is_safetensors_available' from 'transformers.utils' (/nvme1/xxx/miniconda3/envs/py310/lib/python3.10/site-packages/transformers/utils/__init__.py)

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants