Skip to content

Commit 4911f9c

Browse files
Bump min transformers version from 4.48 to 4.53 (#558)
- CI tests for min transformers version (4.48) started failing since new peft 1.18 was released yesterday blocking all new PRs from merging - Transformers v5.0 is right around the corner so we should not recommend too older version - Set new minimum transformers to 4.53 instead of 4.48 - nemo:25.07+ and trtllm:1.0.0+ docker containers have transformers 4.53+ - ModelOpt will still likely work for transformers 4.48-4.52 for now but going forward will not be tested in CICD Signed-off-by: Keval Morabia <[email protected]>
1 parent 7b22e83 commit 4911f9c

File tree

9 files changed

+16
-27
lines changed

9 files changed

+16
-27
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ Model Optimizer Changelog (Linux)
66
**Deprecations**
77

88
**New Features**
9+
910
- Add support for PyTorch Geometric quantization.
1011

12+
**Misc**
13+
14+
- Bump minimum recommended transformers version to 4.53.
15+
16+
1117
0.40 (2025-12-xx)
1218
^^^^^^^^^^^^^^^^^
1319

modelopt/torch/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
try:
3333
from transformers import __version__ as _transformers_version
3434

35-
if not (_Version("4.48") <= _Version(_transformers_version) < _Version("5.0")):
35+
if not (_Version("4.53") <= _Version(_transformers_version) < _Version("5.0")):
3636
_warnings.warn(
3737
f"transformers version {_transformers_version} is not tested with nvidia-modelopt and may cause issues. "
3838
"Please install recommended version with `pip install nvidia-modelopt[hf]` if working with HF models.",

modelopt/torch/opt/plugins/transformers.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515

1616
"""ModelOpt plugin for enabling automatic save/restore of ModelOpt state for HuggingFace models."""
1717

18-
import os
1918
import types
2019
from contextlib import contextmanager
2120

2221
import torch
23-
import transformers
2422
from transformers import PreTrainedModel, Trainer, TrainerCallback
2523
from transformers import modeling_utils as tf_modeling_utils
2624

@@ -64,13 +62,6 @@ def _undo_torch_init_override_by_transformers():
6462

6563
def _new_from_pretrained(cls, /, pretrained_model_name_or_path, *args, **kwargs):
6664
"""Patch for `cls.from_pretrained` method to restore ModelOpt state."""
67-
if kwargs.get("tp_plan") is not None or (
68-
kwargs.get("device_map") == "auto" and os.environ.get("WORLD_SIZE")
69-
):
70-
assert transformers.__version__ >= "4.52.0", (
71-
"Tensor parallelism with ModelOpt requires transformers >= 4.52.0"
72-
)
73-
7465
with _patch_model_init_for_modelopt(
7566
cls, pretrained_model_name_or_path, extra_context=_undo_torch_init_override_by_transformers
7667
):

modelopt/torch/quantization/plugins/huggingface.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ def is_compatible_attention(attn):
124124
# In addition, the new attention interface is not available for some models such as T5
125125
# Hence lets do a crude check here to see if the attention module is using the new_attention_interface
126126
# This is not foolproof but should work for most cases
127-
if transformers.__version__ < "4.48.0":
128-
return False
129127
module = inspect.getmodule(attn)
130128
return getattr(module, "ALL_ATTENTION_FUNCTIONS", None) is not None
131129

modelopt/torch/quantization/plugins/transformers_trainer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@
3131
from modelopt.torch.distill.plugins.huggingface import KDTrainer
3232
from modelopt.torch.opt.conversion import restore_from_modelopt_state
3333
from modelopt.torch.opt.plugins import ModelOptHFTrainer
34-
from modelopt.torch.quantization.config import QuantizeConfig
35-
from modelopt.torch.quantization.nn import TensorQuantizer
36-
from modelopt.torch.quantization.utils import (
34+
from modelopt.torch.utils import print_rank_0
35+
36+
from ..config import QuantizeConfig
37+
from ..nn import TensorQuantizer
38+
from ..utils import (
3739
calibrate_with_adapters,
3840
disable_lora_quantizers_in_config,
3941
get_quantizer_state_dict,
4042
is_quantized,
4143
set_quantizer_state_dict,
4244
)
43-
from modelopt.torch.utils import print_rank_0
4445

4546
# TODO: Enable documentation rendering for this class
4647

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"diffusers>=0.32.2",
6262
"huggingface_hub>=0.24.0",
6363
"peft>=0.17.0",
64-
"transformers>=4.48,<5.0", # Should match modelopt/torch/__init__.py and tox.ini
64+
"transformers>=4.53,<5.0", # Should match modelopt/torch/__init__.py and tox.ini
6565
"deepspeed>=0.9.6 ; platform_system != 'Darwin' and platform_system != 'Windows'",
6666
],
6767
# linter tools

tests/_test_utils/torch/transformers_models.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
BertForQuestionAnswering,
2929
LlamaConfig,
3030
LlamaForCausalLM,
31+
Qwen3Config,
32+
Qwen3ForCausalLM,
3133
T5Config,
3234
T5ForConditionalGeneration,
3335
T5Tokenizer,
3436
)
3537

36-
if Version(transformers.__version__) >= Version("4.51"):
37-
from transformers import Qwen3Config, Qwen3ForCausalLM
38-
3938
if Version(transformers.__version__) >= Version("4.55"):
4039
from transformers import GptOssConfig, GptOssForCausalLM
4140

@@ -46,8 +45,6 @@
4645

4746
def get_tiny_qwen3(**config_kwargs) -> "Qwen3ForCausalLM":
4847
set_seed(SEED)
49-
if Version(transformers.__version__) < Version("4.51"):
50-
pytest.skip("Qwen3ForCausalLM is not supported in transformers < 4.51")
5148

5249
kwargs = {
5350
"hidden_size": 32,

tests/gpu/torch/quantization/plugins/test_transformers_tp.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import pytest
2020
import torch
2121
from _test_utils.torch.distributed.utils import spawn_multiprocess_job
22-
from packaging.version import Version
2322

2423
import modelopt.torch.quantization as mtq
2524

2625
pytest.importorskip("transformers")
27-
import transformers
2826
from _test_utils.torch.transformers_models import create_tiny_llama_dir
2927
from transformers import AutoModelForCausalLM
3028

@@ -44,7 +42,5 @@ def _test_transformers_tp(model_path, rank, size):
4442

4543

4644
def test_transformers_tp(need_2_gpus, tmp_path):
47-
if Version(transformers.__version__) < Version("4.52.0"):
48-
pytest.skip("This test requires transformers>=4.52.0")
4945
model_path = create_tiny_llama_dir(tmp_path)
5046
spawn_multiprocess_job(size=2, job=partial(_test_transformers_tp, model_path), backend="nccl")

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ deps =
2626
-e .[all,dev-test]
2727

2828
# Should match setup.py
29-
tf_min: transformers~=4.48.0
29+
tf_min: transformers~=4.53.0
3030
commands =
3131
python -m pytest tests/unit {env:COV_ARGS:}
3232

0 commit comments

Comments
 (0)