[bnb] Force requires_grad to be False (#22396)

for rg to be `False`
This commit is contained in:
Younes Belkada 2023-03-27 16:55:55 +02:00 committed by GitHub
parent 7dcd8703ef
commit d324b70f00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,6 +133,8 @@ def replace_8bit_linear(model, threshold=6.0, modules_to_not_convert=None, curre
has_fp16_weights=False,
threshold=threshold,
)
# Force requires grad to False to avoid unexpected errors
model._modules[name].requires_grad_(False)
# Remove the last key for recursion
current_key_name.pop(-1)
return model