In contrib/rlhflow/reward_modeling.py line 44, AutoModelForSequenceClassification.from_pretrained is called with torch_dtype=torch.bfloat16:
model = AutoModelForSequenceClassification.from_pretrained(
model_args.model_name_or_path, num_labels=1, torch_dtype=torch.bfloat16
)
The torch_dtype keyword argument was deprecated in transformers 4.56 (PR #39782) and replaced by dtype. On transformers 4.56+ this call emits a DeprecationWarning, and the argument will be removed in a future release, breaking the script.
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 = AutoModelForSequenceClassification.from_pretrained(
model_args.model_name_or_path, num_labels=1, **_dtype_kwargs(torch.bfloat16)
)
This keeps compatibility with transformers < 4.56 and stops the deprecation warning on 4.56+.
In
contrib/rlhflow/reward_modeling.pyline 44,AutoModelForSequenceClassification.from_pretrainedis called withtorch_dtype=torch.bfloat16:The
torch_dtypekeyword argument was deprecated in transformers 4.56 (PR #39782) and replaced bydtype. On transformers 4.56+ this call emits aDeprecationWarning, and the argument will be removed in a future release, breaking the script.Suggested fix: choose the keyword based on the installed transformers version with
packaging.version:This keeps compatibility with transformers < 4.56 and stops the deprecation warning on 4.56+.