Refactor PEER - #123
Open
Oleksiy Ostapenko (oleksost) wants to merge 6 commits into
Open
Conversation
Oleksiy Ostapenko (oleksost)
requested a review
from Alessandro Sordoni (sordonia)
October 18, 2024 15:56
| @dataclass | ||
| class PEERConfig(ModifierConfig): | ||
| n_heads: int = 8 | ||
| moe__num_experts: int = 100 |
| def experts_names(self): | ||
| return self.model.experts_names | ||
|
|
||
| def get_expert_instance(self, name): |
There was a problem hiding this comment.
this is only available for multiexpert, i am not sure to add this dependency here
| module = MultiExpertModule(**vars(expert.training_config)).to("cuda") | ||
| module.add_expert_instance(expert, is_default=True) | ||
|
|
||
| elif args.merge_or_route in ["peer"]: |
There was a problem hiding this comment.
can you explain what you are trying to do?
| for expert_name in module.experts_names: | ||
| expert = module.get_expert_instance(expert_name) | ||
| expert: Expert = module.get_expert_instance(expert_name) | ||
| expert.expert_info.training_config = args |
There was a problem hiding this comment.
remove this, not a good idea to store complex object in training_config, it will be transformed to a Dict in the next PR :)
| self.selector = selector or TaskNameSelector() | ||
| self._default_expert_name = None | ||
| self.expert_infos = {} | ||
| self.experts = nn.ModuleDict({}) |
There was a problem hiding this comment.
not all containers have "experts", see my last PR on making LoRA faster
| self.experts = nn.ModuleDict({}) | ||
|
|
||
| @property | ||
| def num_experts(self): |
There was a problem hiding this comment.
let's use len(self)
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.
TODO: