Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/transformers/integrations/bitsandbytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ def _replace_with_bnb_linear(
if (isinstance(module, nn.Linear) or isinstance(module, Conv1D)) and name not in modules_to_not_convert:
# Check if the current key is not in the `modules_to_not_convert`
current_key_name_str = ".".join(current_key_name)

# Here we keep the `key in ".".join(current_key_name)` condition for backward compatibility
if not any(
(key + "." in current_key_name_str) or (key == current_key_name_str) for key in modules_to_not_convert
(key + "." in current_key_name_str)
or (key == current_key_name_str)
or (key in ".".join(current_key_name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use current_key_name_str here?

for key in modules_to_not_convert
):
with init_empty_weights():
if isinstance(module, Conv1D):
Expand Down