fix(utils/weight_conversion): handle str target_modules/target_parameters in MoE config conversion#3236
Closed
Anai-Guo wants to merge 1 commit into
Closed
Conversation
…ters in MoE config conversion Closes huggingface#3229.
Member
|
Thanks for the PR but there is already another one (#3232). |
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.
Summary
Closes #3229.
_convert_peft_config_moeinsrc/peft/utils/transformers_weight_conversion.pynormalizedpeft_config.target_modulesandpeft_config.target_parametersviaset(value or [])before iterating them against the MoE target-module mapping. When a user passes a single string for these fields (a supported shape elsewhere in PEFT, e.g.target_modules="gate_up_proj"),set("gate_up_proj")silently splits the string into individual characters ({"g","a","t","e","_","u","p","r","o","j"}). The downstreamfor target in peft_config.target_modulesloop then matches none of the expected module names, so config conversion for MoE models silently produced wrong results. Reported in modelscope/ms-swift#9321.What changed
src/peft/utils/transformers_weight_conversion.py(_convert_peft_config_moe): replace_normalize_to_sethelper that mapsstrto a single-element set,Nonetoset(), and otherwise falls back toset(value). Pure normalization change; no other code paths affected.Verification
set([...])/set((...))/set({...})semantics unchanged;Nonestill becomesset()instead of erroring.str:target_modules="gate_up_proj"becomes{"gate_up_proj"}so the per-target loop sees one well-formed module name instead of ten one-character non-matches.AI-assisted, human reviewed.