refactor(checkpoint): make the target-module rename hook a StateDictAdapter method - #3591
Open
stanley1208 wants to merge 3 commits into
Open
refactor(checkpoint): make the target-module rename hook a StateDictAdapter method#3591stanley1208 wants to merge 3 commits into
stanley1208 wants to merge 3 commits into
Conversation
…dapter method Follow-up to NVIDIA-NeMo#3435. The rename hook for adapter_config.json's target_modules was discovered with getattr in _extract_target_modules, which is easy to miss when writing a new adapter. It's now a regular method on the StateDictAdapter base that returns the name unchanged, so adapters whose to_hf renames modules just override it (kimi_k3 already does) and addons.py calls it through an isinstance check instead. Legacy adapters that don't subclass StateDictAdapter (llama, qwen2/3, kimivl, and the mixin-only test adapters) skip the hook like they did with the old getattr guard, so their PEFT saves keep working. Signed-off-by: stanley1208 <stanley.mei08@gmail.com>
Contributor
|
Thank you I appreciate it! |
Contributor
|
/claude review |
Contributor
|
/ok to test 4cc45eb |
Contributor
|
LGTM Reviewed all 3 changed files. The change swaps the duck-typed Verified:
|
Contributor
|
/ok to test 35e1eba |
Contributor
|
/ok to test 0556d59 |
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.
@HuiyingLi follow up to #3435.
made the rename hook a real method on
StateDictAdapterinstead of a getattr. so now the base class has the method, it just returns the name unchanged, and kimi_k3 overrides it with its own renames.some older adapters (llama, qwen2/3, kimivl) don't inherit from
StateDictAdapter, so I added an isinstance check to keep their saves working like before.