Skip to content

fix(models): use dtype consistently for Transformers loads (#2200) - #2257

Open
Nari-Ab wants to merge 2 commits into
MakazhanAlpamys:mainfrom
Nari-Ab:codex/transformers-load-dtype
Open

Nari-Ab wants to merge 2 commits into
MakazhanAlpamys:mainfrom
Nari-Ab:codex/transformers-load-dtype

Conversation

@Nari-Ab

@Nari-Ab Nari-Ab commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Closes #2200.

Replace deprecated torch_dtype load arguments with dtype in one sweep of Transformers model-loading calls and their kwargs dictionaries. Precision values and quantization decisions stay the same. Unsloth/Peft APIs, checkpoint config fields (including utils/kimi_k2.py) and unrelated utility files are unchanged.

Invert the existing floor-compatibility guard so it rejects the deprecated spelling. It covers direct calls, local dictionaries/updates/unpacks and locally selected AutoModel loader aliases, including the DPO path. Existing wrapper/CLI assertions follow the new spelling. Real tiny models saved locally exercise a CPU from_pretrained path and a meta-skeleton from_config path, with Python warnings and deprecated-dtype logging rejected; no model download is needed.

Validation on Python 3.11/macOS, main 7196345:

  • Current Transformers 5.20.2: 716 passed, 18 skipped across the affected loader/trainer/CLI and guard tests, with forced color. Skips are 14 CUDA-only and 4 optional bitsandbytes cases.
  • Actual Transformers 5.16.1 installed in an isolated temporary target: 92 passed across floor guards, dtype wrappers and the real local-model loads. Independently repeated by the parent with the same result. This uses installed Torch 2.14.1; it does not claim execution of the whole hosted pinned floor stack.
  • Before production changes, 2 tests fail and 38 controls pass; a real from_config call fails on the exact deprecated dtype warning. Six independent mutations (direct kwarg, trainer dictionary, incremental dictionary, real config-load warning, direct scanner and dictionary scanner) are caught and restored.
  • AST-equivalence verification covers all 29 changed source files after normalizing argument names and documentation; dtype expressions and algorithm behavior are preserved. Repo-wide Ruff, new-file formatting and whitespace checks pass. The changelog describes the removed warning.

Dependencies for verification were installed only in /private/tmp targets; the existing venv was not modified. Existing Typer/PEFT/TRL/pickle warnings remain, including three warnings in the focused floor run. No real GPU, native Linux/Windows or full-project local suite is claimed. The maintainer-controlled hosted floor/full CI remains required before merge.

This branch has not been deployed

No deployments
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.

Replace the deprecated torch_dtype= argument with dtype= at the transformers model load sites

1 participant