Skip to content

[Bug] Reference to depreciated torch_dtype. #3352

Description

@JonathanRaines
  1. Did you update? pip install --upgrade unsloth unsloth_zoo: Yes
  2. Colab or Kaggle or local / cloud: local
  3. Number GPUs used, use nvidia-smi: n/a
  4. Which notebook? Please link!: n/a
  5. Which Unsloth version, TRL version, transformers version, PyTorch version? Unsloth: 2025.7.2, TRL: 0.19.1, tranformers 4.56.1, pytorch 2.8.0
  6. Which trainer? SFTTrainer, GRPOTrainer etc: n/a
model, tokenizer = unsloth.FastModel.from_pretrained(
        model_name="unsloth/gemma-3-1b-it-unsloth-bnb-4bit",
        max_seq_length=512,
        load_in_4bit = True,
    )

I get:
File "[...]/.venv/lib/python3.13/site-packages/unsloth/models/loader.py", line 830, in from_pretrained
"bnb_4bit_compute_dtype" : model.config.to_dict()["torch_dtype"],
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'torch_dtype'
FastModel appears to have been updated to use "dtype" instead of "torch_dtype" but this line still tries to access "torch_dtype" as a key.
Manually changing it to model.config.to_dict()["dtype"], fixes the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions