Commit 501df99
authored
FIX: Avoid needless copy from modules_to_save (huggingface#2220)
Resolves huggingface#2206
The problem is that we keep a "global" modules_to_save on the model
which contains all possible modules_to_save for each adapter. When the
first adapter targets layer "foo" with modules_to_save and the second
adapter targets "bar", then "foo" will create a copy of the original
module for the second adapter, even though it's not needed.
This does not change the result but is unnecessary and takes up memory.
Thus it should be avoided.1 parent ce8abe4 commit 501df99
File tree
4 files changed
+32
-9
lines changed- src/peft
- utils
- tests
4 files changed
+32
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
949 | 949 | | |
950 | 950 | | |
951 | 951 | | |
952 | | - | |
| 952 | + | |
| 953 | + | |
953 | 954 | | |
954 | 955 | | |
955 | 956 | | |
| |||
1446 | 1447 | | |
1447 | 1448 | | |
1448 | 1449 | | |
1449 | | - | |
| 1450 | + | |
1450 | 1451 | | |
1451 | 1452 | | |
1452 | 1453 | | |
| |||
2237 | 2238 | | |
2238 | 2239 | | |
2239 | 2240 | | |
2240 | | - | |
| 2241 | + | |
2241 | 2242 | | |
2242 | 2243 | | |
2243 | 2244 | | |
| |||
2458 | 2459 | | |
2459 | 2460 | | |
2460 | 2461 | | |
2461 | | - | |
| 2462 | + | |
2462 | 2463 | | |
2463 | 2464 | | |
2464 | 2465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
279 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
| |||
416 | 418 | | |
417 | 419 | | |
418 | 420 | | |
419 | | - | |
| 421 | + | |
420 | 422 | | |
421 | 423 | | |
422 | | - | |
| 424 | + | |
423 | 425 | | |
424 | 426 | | |
425 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1608 | 1608 | | |
1609 | 1609 | | |
1610 | 1610 | | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
1611 | 1631 | | |
1612 | 1632 | | |
1613 | 1633 | | |
| |||
0 commit comments