In train.py lines 331 and 344, ShowUIForConditionalGeneration.from_pretrained and Qwen2VLForConditionalGeneration.from_pretrained are called with torch_dtype=torch_dtype (e.g. torch_dtype=torch_dtype, low_cpu_mem_usage=True, _attn_implementation=..., quantization_config=bnb_config, device_map=...).
The torch_dtype keyword argument was deprecated in transformers 4.56 (PR #39782) and replaced by dtype. On transformers 4.56+ these calls emit a DeprecationWarning, and the argument will be removed in a future release, breaking training.
Suggested fix: choose the keyword based on the installed transformers version with packaging.version:
import transformers
from packaging.version import Version
def _dtype_kwargs(dtype):
"""`dtype` keyword of `from_pretrained` exists since transformers 4.56 (PR #39782);
older versions use `torch_dtype`."""
if Version(transformers.__version__) >= Version("4.56"):
return {"dtype": dtype}
return {"torch_dtype": dtype}
model = ShowUIForConditionalGeneration.from_pretrained(
model_url,
**_dtype_kwargs(torch_dtype),
low_cpu_mem_usage=True,
_attn_implementation=args.attn_imple,
quantization_config=bnb_config,
device_map=f"cuda:{args.local_rank}",
lm_skip_layer=lm_skip_layer,
lm_skip_ratio=args.lm_skip_ratio,
)
(Same pattern for the Qwen2VLForConditionalGeneration call on line 344.) This keeps compatibility with transformers < 4.56 and stops the deprecation warning on 4.56+.
In
train.pylines 331 and 344,ShowUIForConditionalGeneration.from_pretrainedandQwen2VLForConditionalGeneration.from_pretrainedare called withtorch_dtype=torch_dtype(e.g.torch_dtype=torch_dtype, low_cpu_mem_usage=True, _attn_implementation=..., quantization_config=bnb_config, device_map=...).The
torch_dtypekeyword argument was deprecated in transformers 4.56 (PR #39782) and replaced bydtype. On transformers 4.56+ these calls emit aDeprecationWarning, and the argument will be removed in a future release, breaking training.Suggested fix: choose the keyword based on the installed transformers version with
packaging.version:(Same pattern for the
Qwen2VLForConditionalGenerationcall on line 344.) This keeps compatibility with transformers < 4.56 and stops the deprecation warning on 4.56+.