Suggested title
[Bug] ModelScope 1.37.1 fails to load BERT/T5 NLP models with transformers 5.x because transformers.onnx was removed
Checklist
Describe the bug
ModelScope 1.37.1 still imports ONNX config classes from transformers.onnx in several NLP configuration modules. In an environment where transformers==5.8.1 is installed, transformers.onnx no longer exists, so common NLP pipelines such as BERT fill-mask fail during model import.
This blocks normal non-plugin models, for example iic/nlp_bert_fill-mask_chinese-base, before inference starts:
modelscope/models/nlp/bert/configuration.py:21: in <module>
from transformers.onnx import OnnxConfig
E ModuleNotFoundError: No module named 'transformers.onnx'
E ModuleNotFoundError: BertForMaskedLM: No module named 'transformers.onnx'
E ModuleNotFoundError: FillMaskPipeline: BertForMaskedLM: No module named 'transformers.onnx'
The direct imports still exist in the 1.37.1 source tree:
modelscope/models/nlp/bert/configuration.py:21
modelscope/models/nlp/megatron_bert/configuration.py:22
modelscope/models/nlp/xlm_roberta/configuration.py:21
modelscope/models/nlp/T5/configuration.py:19
requirements/framework.txt currently leaves transformers unconstrained, so a fresh install can resolve to transformers 5.x and hit this failure.
Expected behavior: BERT/T5/XLM-RoBERTa/MegatronBERT model loading should either work with supported transformers versions, or ModelScope should declare an upper bound that prevents incompatible transformers 5.x installs.
To Reproduce
- What command or script did you run?
docker run --rm \
-v /mnt/nas2/hzh/modelscope:/workspace \
-w /workspace \
modelscope-registry.cn-hangzhou.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.8.1-py312-torch2.10.0-1.37.1 \
bash -lc 'pip install pytest pytest-ordering pytest-assume jsonpath-ng filelock -q && cd /workspace/test_release1.37 && python -m pytest test_r37_trust_remote_code.py::TestR37TrustRemoteCode::test_safe_model_not_blocked_without_trust test_r37_trust_remote_code.py::TestR37TrustRemoteCode::test_normal_model_compatible_with_136 -v --tb=short'
A minimal script reproduces the same failure:
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
pipeline(
task=Tasks.fill_mask,
model='iic/nlp_bert_fill-mask_chinese-base',
)
- Did you make any modifications on the code or config? Did you understand what you have modified?
No source-code modification was made to ModelScope for this repro. The SDK was installed from the release/1.37 source tree at commit 121f4150fa9615882414bf424199e15be09c8ae5. The pytest file only exercises normal public model loading.
- What dataset did you use?
No dataset is required. The public model iic/nlp_bert_fill-mask_chinese-base was used.
Your Environments (required)
- OS: test report records Linux Ubuntu 22.04 host running the docker image below; exact
uname -a was not captured by the automation log.
- CPU: exact
lscpu output was not captured by the automation log. Host also has 2 x NVIDIA A100-SXM4-80GB GPUs, driver 570.133.20, CUDA 12.8.
- Commit id (e.g.
a3ffc7d8): 121f4150fa9615882414bf424199e15be09c8ae5 (release/1.37, ModelScope 1.37.1)
- You may add addition that may be helpful for locating the problem, such as
- Docker image:
modelscope-registry.cn-hangzhou.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.8.1-py312-torch2.10.0-1.37.1
- Python:
3.12.13
- pytest:
9.0.3
- transformers:
5.8.1
- modelscope:
1.37.1, installed from source
- Related requirement:
requirements/framework.txt contains unconstrained transformers
Please @ corresponding people according to your problem:
issue_01_transformers_onnx_removed.md
02c_trust_final.log
Suggested title
[Bug] ModelScope 1.37.1 fails to load BERT/T5 NLP models with transformers 5.x because
transformers.onnxwas removedChecklist
Describe the bug
ModelScope 1.37.1 still imports ONNX config classes from
transformers.onnxin several NLP configuration modules. In an environment wheretransformers==5.8.1is installed,transformers.onnxno longer exists, so common NLP pipelines such as BERT fill-mask fail during model import.This blocks normal non-plugin models, for example
iic/nlp_bert_fill-mask_chinese-base, before inference starts:The direct imports still exist in the 1.37.1 source tree:
requirements/framework.txtcurrently leavestransformersunconstrained, so a fresh install can resolve to transformers 5.x and hit this failure.Expected behavior: BERT/T5/XLM-RoBERTa/MegatronBERT model loading should either work with supported transformers versions, or ModelScope should declare an upper bound that prevents incompatible transformers 5.x installs.
To Reproduce
No source-code modification was made to ModelScope for this repro. The SDK was installed from the
release/1.37source tree at commit121f4150fa9615882414bf424199e15be09c8ae5. The pytest file only exercises normal public model loading.No dataset is required. The public model
iic/nlp_bert_fill-mask_chinese-basewas used.Your Environments (required)
uname -awas not captured by the automation log.lscpuoutput was not captured by the automation log. Host also has 2 x NVIDIA A100-SXM4-80GB GPUs, driver 570.133.20, CUDA 12.8.a3ffc7d8):121f4150fa9615882414bf424199e15be09c8ae5(release/1.37, ModelScope 1.37.1)modelscope-registry.cn-hangzhou.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.8.1-py312-torch2.10.0-1.37.13.12.139.0.35.8.11.37.1, installed from sourcerequirements/framework.txtcontains unconstrainedtransformersPlease @ corresponding people according to your problem:
issue_01_transformers_onnx_removed.md
02c_trust_final.log