Skip to content

fix: use dtype instead of deprecated torch_dtype - #100

Open
xyf5432 wants to merge 1 commit into
showlab:mainfrom
xyf5432:fix/use-dtype-instead-of-torch-dtype
Open

fix: use dtype instead of deprecated torch_dtype#100
xyf5432 wants to merge 1 commit into
showlab:mainfrom
xyf5432:fix/use-dtype-instead-of-torch-dtype

Conversation

@xyf5432

@xyf5432 xyf5432 commented Aug 28, 2026

Copy link
Copy Markdown

Summary

config.torch_dtype and the torch_dtype keyword argument were deprecated in transformers 4.56 (PR #39782) and replaced by dtype. This PR updates the two from_pretrained calls in train.py (ShowUIForConditionalGeneration line 331 and Qwen2VLForConditionalGeneration line 344) to select the keyword from the installed transformers version using packaging.version, so transformers < 4.56 keeps working. All other arguments (_attn_implementation, quantization_config, device_map, lm_skip_layer, lm_skip_ratio, ...) are unchanged.

Changes

  • train.py: add a _dtype_kwargs helper that returns {"dtype": ...} on transformers >= 4.56 and {"torch_dtype": ...} otherwise; both from_pretrained calls pass it as **_dtype_kwargs(torch_dtype).

Test

  • The modified file compiles (python -m py_compile).
  • On transformers >= 4.56 the calls use dtype and emit no deprecation warning; on older versions they pass torch_dtype unchanged.

Fixes #99

…4.56

config.torch_dtype and the torch_dtype keyword argument were deprecated in transformers 4.56 (PR #39782). Pass dtype based on the installed transformers version (packaging.version), falling back to torch_dtype on older versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use dtype instead of deprecated torch_dtype for transformers >= 4.56

1 participant