Repository navigation
[LoRA] Target modules by FQN - #5095
Conversation
| # each occurrence of an aliased config before an earlier FQN mutates the | ||
| # shared object, keeping exact-FQN selection path-local. Walking bottom-up | ||
| # also lets a Dist-MoE parent select its wrapper from converted children. | ||
| configs = list(model.traverse(Module.Config, recurse=True)) |
There was a problem hiding this comment.
_make_frozen_config uses shallow copy. So if there is a list of config field inside a shared config, but we only want to transform some modules not all of them that share that config, does this still hold/work correctly?
There was a problem hiding this comment.
That would be problematic. I will try to fix it.
There was a problem hiding this comment.
It seems a problem that is not too easy to fix in a nice way.
The problem in general is that the model config is often conceptually a tree, but it could sometimes be a DAG because some modules may share the config.
One way to handle this case would be to first canonicalize the model config into a tree, and then applying the transform on the modules.
Another way would be to just deepcopy every time, but this would incur unnecessary many copies for each subtrees because we traverse from bottom up.
But is it possible that say different layers genuinely share a common module? I don't know the answer.
There was a problem hiding this comment.
okay, let's not fix this now as discussed offline. We need a separate diff stack to fix the transform and config traversal problems. Please add a note.
fegin
left a comment
There was a problem hiding this comment.
Please add a note about the config/transform issue before landing.
| # each occurrence of an aliased config before an earlier FQN mutates the | ||
| # shared object, keeping exact-FQN selection path-local. Walking bottom-up | ||
| # also lets a Dist-MoE parent select its wrapper from converted children. | ||
| configs = list(model.traverse(Module.Config, recurse=True)) |
There was a problem hiding this comment.
okay, let's not fix this now as discussed offline. We need a separate diff stack to fix the transform and config traversal problems. Please add a note.
|
@fegin I made it error out in the cases
|
Addresses #4995 (comment)
Also addresses #4995 (comment)
since
handlerinterface is gone.Summary
HuggingFace link and Megatron link target LoRA modules by FQN.
This PR lets the user only specify the FQN, and the transform handles applying the correct LoRA for different kinds of modules, including
Linear,GroupedLinear,DistMoeRoutedExperts.Only complication is the
DistMoeRoutedExpertsbecause the previous implementation assumed bothw13andw2are targeted, but this one allows one to target only one of them.GroupedLinearorLinearLoRA for targeted modulesDistMoeRoutedExpertsand it has childw13orw2that is already LoRA transformed, edit_weight_operandsto return the LoRA weight summed matrix.