Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
8cfc6678
Unverified
Commit
8cfc6678
authored
Mar 27, 2023
by
Sylvain Gugger
Committed by
GitHub
Mar 27, 2023
Browse files
Adapt find_tied_parameters to handle breaking change in Accelerate (#22360)
parent
204737fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
src/transformers/utils/bitsandbytes.py
src/transformers/utils/bitsandbytes.py
+6
-1
No files found.
src/transformers/utils/bitsandbytes.py
View file @
8cfc6678
...
@@ -154,7 +154,12 @@ def get_keys_to_not_convert(model):
...
@@ -154,7 +154,12 @@ def get_keys_to_not_convert(model):
tied_model
=
deepcopy
(
model
)
# this has 0 cost since it is done inside `init_empty_weights` context manager`
tied_model
=
deepcopy
(
model
)
# this has 0 cost since it is done inside `init_empty_weights` context manager`
tied_model
.
tie_weights
()
tied_model
.
tie_weights
()
tied_keys
=
list
(
find_tied_parameters
(
tied_model
).
values
())
tied_params
=
find_tied_parameters
(
tied_model
)
# For compatibility with Accelerate < 0.18
if
isinstance
(
tied_params
,
dict
):
tied_keys
=
list
(
tied_params
.
values
())
else
:
tied_keys
=
sum
([
x
[
1
:]
for
x
in
tied_params
],
[])
has_tied_params
=
len
(
tied_keys
)
>
0
has_tied_params
=
len
(
tied_keys
)
>
0
# Check if it is a base model
# Check if it is a base model
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment