Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PEER #123

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Refactor PEER #123

wants to merge 6 commits into from

Conversation

oleksost
Copy link
Collaborator

@oleksost oleksost commented Oct 18, 2024

  • make sure PEER can be saved in a library
  • PEER contained is also a modifier

TODO:

  • make sure the router is also saved
  • make sure training config is also saved
  • make sure it can also be loaded from a library

@oleksost oleksost requested a review from sordonia October 18, 2024 15:56
@dataclass
class PEERConfig(ModifierConfig):
n_heads: int = 8
moe__num_experts: int = 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two __

def experts_names(self):
return self.model.experts_names

def get_expert_instance(self, name):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only available for multiexpert, i am not sure to add this dependency here

@@ -186,6 +190,10 @@ def run_eval(args: EvaluationConfig):
module = MultiExpertModule(**vars(expert.training_config)).to("cuda")
module.add_expert_instance(expert, is_default=True)

elif args.merge_or_route in ["peer"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain what you are trying to do?

@@ -200,7 +201,8 @@ def upload_library(expert_library, module):
if isinstance(module, MoEModule):
with expert_library.batched_commit():
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this, not a good idea to store complex object in training_config, it will be transformed to a Dict in the next PR :)

@@ -35,6 +35,11 @@ def __init__(self, config, layer, selector=None):
self.selector = selector or TaskNameSelector()
self._default_expert_name = None
self.expert_infos = {}
self.experts = nn.ModuleDict({})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all containers have "experts", see my last PR on making LoRA faster

self.experts = nn.ModuleDict({})

@property
def num_experts(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use len(self)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants