FIX: Bug in target module optimization if child module name is suffix of parent module name #2144
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.
Solves the following bug:
huggingface/diffusers#9622 (comment)
The cause for the bug is as follows: When we have, say, a module called
"bar.0.query"
that we want to target and another module called"foo_bar.0.query"
that we don't want to target, there was potential for an error.This is not caused by
_find_minimal_target_modules
directly, but rather the bug was inside ofBaseTuner.inject_adapter
and how thenames_no_target
were chosen. Those used to be chosen based on suffix. In our example, however,"bar.0.query"
is a suffix of"foo_bar.0.query"
, therefore"foo_bar.0.query"
was not added tonames_no_target
when it should have. As a consequence, during the optimization, it looks like"query"
is safe to use astarget_modules
because we don't see that it wrongly matches"foo_bar.0.query"
.