Commit c220ea9
authored
Fix load_adapter OOM caused by full-model warmup sizing (#46145)
* Fix load_adapter OOM caused by full-model warmup sizing
load_adapter passed every named parameter on the model, including the
base model, as expected_keys to _load_pretrained_model. Downstream,
caching_allocator_warmup summed those into a full base-model byte count
and issued a single same-size allocation on top of the already-resident
base model, OOMing whenever the base model occupies more than ~half of
GPU memory.
The file already defined an is_adapter_key helper for identifying
parameters belonging to the freshly-injected adapter, but it was declared
after the _load_pretrained_model call. Hoist the helper above the call
and apply it to expected_keys.
Adds a regression test that captures the device map passed to
caching_allocator_warmup during load_adapter and asserts it contains only
adapter-owned parameter names, not base-model names.
* Address review: use unittest.mock.patch and expand test docstring1 parent e1a37d2 commit c220ea9
2 files changed
Lines changed: 63 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
586 | 593 | | |
587 | 594 | | |
588 | 595 | | |
| |||
670 | 677 | | |
671 | 678 | | |
672 | 679 | | |
673 | | - | |
674 | | - | |
675 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
676 | 683 | | |
677 | 684 | | |
678 | 685 | | |
| |||
683 | 690 | | |
684 | 691 | | |
685 | 692 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
694 | 695 | | |
695 | 696 | | |
696 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
697 | 750 | | |
698 | 751 | | |
699 | 752 | | |
| |||
0 commit comments