Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
65ea1904
Unverified
Commit
65ea1904
authored
May 14, 2024
by
Pashmina Cameron
Committed by
GitHub
May 14, 2024
Browse files
PEFT: Access active_adapters as a property in Trainer (#30790)
Access active_adapters as a property
parent
c02d302e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/trainer.py
src/transformers/trainer.py
+3
-3
No files found.
src/transformers/trainer.py
View file @
65ea1904
...
@@ -2533,7 +2533,7 @@ class Trainer:
...
@@ -2533,7 +2533,7 @@ class Trainer:
if
os
.
path
.
exists
(
resume_from_checkpoint
):
if
os
.
path
.
exists
(
resume_from_checkpoint
):
# For BC for older PEFT versions
# For BC for older PEFT versions
if
hasattr
(
model
,
"active_adapters"
):
if
hasattr
(
model
,
"active_adapters"
):
active_adapters
=
model
.
active_adapters
()
active_adapters
=
model
.
active_adapters
if
len
(
active_adapters
)
>
1
:
if
len
(
active_adapters
)
>
1
:
logger
.
warning
(
"Multiple active adapters detected will only consider the first adapter"
)
logger
.
warning
(
"Multiple active adapters detected will only consider the first adapter"
)
active_adapter
=
active_adapters
[
0
]
active_adapter
=
active_adapters
[
0
]
...
@@ -2626,8 +2626,8 @@ class Trainer:
...
@@ -2626,8 +2626,8 @@ class Trainer:
):
):
# For BC for older PEFT versions
# For BC for older PEFT versions
if
hasattr
(
model
,
"active_adapters"
):
if
hasattr
(
model
,
"active_adapters"
):
active_adapter
=
model
.
active_adapters
()
[
0
]
active_adapter
=
model
.
active_adapters
[
0
]
if
len
(
model
.
active_adapters
()
)
>
1
:
if
len
(
model
.
active_adapters
)
>
1
:
logger
.
warning
(
"Detected multiple active adapters, will only consider the first one"
)
logger
.
warning
(
"Detected multiple active adapters, will only consider the first one"
)
else
:
else
:
active_adapter
=
model
.
active_adapter
active_adapter
=
model
.
active_adapter
...
...
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