Skip to content

SmolVLM2: RuntimeError: Unsloth: Failed to make input require gradients! #317

@anderlem

Description

@anderlem

When loading SmolVLM2 ("HuggingFaceTB/SmolVLM2-2.2B-Instruct") with Unsloth, I get

File "lib/python3.12/site-packages/unsloth_zoo/peft_utils.py", line 216, in requires_grad_pre_hook
raise RuntimeError("Unsloth: Failed to make input require gradients!")
RuntimeError: Unsloth: Failed to make input require gradients!

I think this is because here
https://github.com/huggingface/transformers/blob/8ac2b916b042b1f78b75c9eb941c0f5d2cdd8e10/src/transformers/models/smolvlm/modeling_smolvlm.py#L396-L399
the inputs are not passed as positional arguments, and therefore the requires_grad_pre_hook does not get the inputs (cf. the docs at https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.module.register_module_forward_pre_hook.html)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions