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
71a114d3
Unverified
Commit
71a114d3
authored
Jun 08, 2023
by
Marc Sun
Committed by
GitHub
Jun 08, 2023
Browse files
fix get_keys_to_not_convert function (#24095)
* fix get_keys_to_not_convert funct * Fix style
parent
8c5f3067
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
src/transformers/utils/bitsandbytes.py
src/transformers/utils/bitsandbytes.py
+4
-4
No files found.
src/transformers/utils/bitsandbytes.py
View file @
71a114d3
...
...
@@ -245,9 +245,9 @@ def get_keys_to_not_convert(model):
tied_params
=
find_tied_parameters
(
tied_model
)
# For compatibility with Accelerate < 0.18
if
isinstance
(
tied_params
,
dict
):
tied_keys
=
list
(
tied_params
.
values
())
tied_keys
=
sum
(
list
(
tied_params
.
values
())
,
[])
+
list
(
tied_params
.
keys
())
else
:
tied_keys
=
sum
(
[
x
[
1
:]
for
x
in
tied_params
]
,
[])
tied_keys
=
sum
(
tied_params
,
[])
has_tied_params
=
len
(
tied_keys
)
>
0
# Check if it is a base model
...
...
@@ -258,12 +258,12 @@ def get_keys_to_not_convert(model):
return
[]
# otherwise they have an attached head
list_modules
=
list
(
model
.
named_
parameters
())
list_modules
=
list
(
model
.
named_
children
())
list_last_module
=
[
list_modules
[
-
1
][
0
]]
# add last module together with tied weights
intersection
=
set
(
list_last_module
)
-
set
(
tied_keys
)
list_untouched
=
tied_keys
+
list
(
intersection
)
list_untouched
=
list
(
set
(
tied_keys
))
+
list
(
intersection
)
# remove ".weight" from the keys
names_to_remove
=
[
".weight"
,
".bias"
]
...
...
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