Summary
Starting with transformers 4.56.0 (huggingface/transformers#39782), the torch_dtype keyword argument of PreTrainedModel.from_pretrained is deprecated in favor of dtype. Code that still uses torch_dtype emits the deprecation warning "torch_dtype is deprecated! Use dtype instead!" on every invocation, and the deprecated API is scheduled for removal in a future major release.
This repository still passes torch_dtype at the location below. Note that requirements/runtime.txt allows transformers >= 4.45.2, i.e. older versions that do not accept dtype yet. The proposed change therefore keeps a fallback for transformers < 4.56.0 so the code keeps working across the whole supported range: dtype is honored identically to torch_dtype on transformers >= 4.56.0.
Trigger point
llmc/models/llava_hf.py line L30-33:
self.vlm_model = LlavaForConditionalGeneration.from_pretrained(
self.model_path,
config=self.vlm_model_config,
torch_dtype=self.torch_dtype,
low_cpu_mem_usage=True,
)
Proposed change
try:
# transformers >= 4.56: `dtype` is the replacement for `torch_dtype`
self.vlm_model = LlavaForConditionalGeneration.from_pretrained(
self.model_path,
config=self.vlm_model_config,
dtype=self.torch_dtype,
low_cpu_mem_usage=True,
)
except TypeError:
# transformers < 4.56: `dtype` is not accepted yet
self.vlm_model = LlavaForConditionalGeneration.from_pretrained(
self.model_path,
config=self.vlm_model_config,
torch_dtype=self.torch_dtype,
low_cpu_mem_usage=True,
)
Would a PR updating this call to dtype (with the fallback above) be welcome?
Summary
Starting with transformers 4.56.0 (huggingface/transformers#39782), the
torch_dtypekeyword argument ofPreTrainedModel.from_pretrainedis deprecated in favor ofdtype. Code that still usestorch_dtypeemits the deprecation warning "torch_dtypeis deprecated! Usedtypeinstead!" on every invocation, and the deprecated API is scheduled for removal in a future major release.This repository still passes
torch_dtypeat the location below. Note thatrequirements/runtime.txtallows transformers >= 4.45.2, i.e. older versions that do not acceptdtypeyet. The proposed change therefore keeps a fallback for transformers < 4.56.0 so the code keeps working across the whole supported range:dtypeis honored identically totorch_dtypeon transformers >= 4.56.0.Trigger point
llmc/models/llava_hf.pyline L30-33:Proposed change
Would a PR updating this call to
dtype(with the fallback above) be welcome?