FIX AdaMSS: register adamss_newB in other_param_names (delete_adapter leak)#3367
Closed
DaoyuanLi2816 wants to merge 1 commit into
Closed
FIX AdaMSS: register adamss_newB in other_param_names (delete_adapter leak)#3367DaoyuanLi2816 wants to merge 1 commit into
DaoyuanLi2816 wants to merge 1 commit into
Conversation
adamss_newB is a per-adapter frozen projection buffer (BufferDict) but was listed in neither adapter_layer_names nor other_param_names, so the generic BaseTunerLayer machinery (which iterates adapter_layer_names + other_param_names) never touched it: delete_adapter() left the deleted adapter in adamss_newB (leak) and per-adapter device moves skipped it. Frozen per-adapter buffers belong in other_param_names, like vera_A/vera_B in VeRA.
Contributor
Author
|
Superseded by #3376, which now registers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
AdamssLayer.adamss_newBis a per-adapter frozen projection buffer (BufferDict(persistent=True)), but it is listed in neitheradapter_layer_namesnorother_param_names. The genericBaseTunerLayermachinery iteratesadapter_layer_names + other_param_names, so it never touchesadamss_newB:delete_adapter(name)removesnamefromadamss_A/adamss_Bbut leaves it inadamss_newB— the deleted adapter's projection buffer leaks._move_adapter_to_device_of_base_layer) skip it. (In the commonget_peft_model(...).to(device)flownn.Module.to()still moves the registered submodule, so that only bites exotic multi-device-base setups; the delete leak is the concrete issue.)Frozen per-adapter buffers belong in
other_param_names— this is exactly what VeRA does with itsvera_A/vera_BBufferDicts. The existing comment shows the author correctly keptadamss_newBout ofadapter_layer_names(it isn't trainable) but missed that it still needs registering inother_param_names.How it was verified
delete_adapter("a1")leaves"a1"in every layer'sadamss_newBonmain(whileadamss_Ais correctly cleaned); with the fix it's removed.test_delete_adapter_removes_newB_buffer— it fails onmainand passes with the fix.delete_adapterstill works with no crash (theadamss_prefix means the module-level delete already filters these keys), and forward /merge_and_unloadare unaffected.tests/test_adamss_asa.pypasses (9 passed);ruff check/ruff format --checkclean.AI assistance
AI assistance was used to prepare this change. I reviewed every changed line, verified the behavior as described above, and take responsibility for the patch.