fix(core): make save_adapters/load_adapters round-trip - #16302
Open
SIDDARTHAREDDY8 wants to merge 1 commit into
Open
SIDDARTHAREDDY8 wants to merge 1 commit into
SIDDARTHAREDDY8 wants to merge 1 commit into
Conversation
Signed-off-by: SIDDARTHA REDDY <75976672+SIDDARTHAREDDY8@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #16102
AdapterModelPTMixin.save_adapters()/load_adapters()did not round-trip. Two independent defects, both innemo/core/classes/mixins/adapter_mixins.py:A file saved for a subset of adapters could not be loaded with the documented default
name=None.load_adaptersderived its restore list from the source model's entire adapter config (list(config.keys())) rather than from the file, raisingKeyErrorfor every adapter the file never contained. It now derives the list fromlist(state_dict.keys()), which is by construction exactly the adapters the file holds.Adapter state-dict keys were selected/stripped by substring (
adapter_name in k/k.replace(...)), so savingan4silently serialized all ofan4_v2's tensors into the file and broke the subsequent strictload_state_dict. Keys are now matched/stripped on the exact'<adapter_name>.'prefix, so overlapping names no longer contaminate each other.Test plan
tests/core/mixins/adapters/(3 files): 68 passed (TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1), including the 2 new regression tests.test_save_adapter_subset_then_load_with_default_nameandtest_save_load_adapter_with_name_that_is_prefix_of_anotherboth fail on unpatched code (KeyError; foreign keys in saved file) and pass with the fix.Notes for the reviewer