feat: add MOLE model support to DatasetSpecificMoEWrapper - #1848
Merged
Merged
Conversation
Add merge_MOLE_model function to DatasetSpecificMoEWrapper for combining MOLE model heads with the main model during inference.
rayg1234
reviewed
Mar 4, 2026
| self.global_mole_tensors.expert_mixing_coefficients = ( | ||
| torch.zeros(1, len(self.dataset_name_to_exp), dtype=data.pos.dtype) | ||
| .scatter_(1, torch.tensor([[expert_idx]]), 1.0) | ||
| .to(data.pos.device) |
Contributor
There was a problem hiding this comment.
should the torch.zeros be initialized on device instead of moving it after?
rayg1234
reviewed
Mar 4, 2026
| nan_tensor = head_output[key].new_full( | ||
| head_output[key].shape, float("nan") | ||
| ) | ||
| for dataset in self.non_merged_dataset_names: |
Contributor
There was a problem hiding this comment.
self.non_merged_dataset_names is None if not merged?
Contributor
Author
There was a problem hiding this comment.
correct, but guarded behind merged_on_dataset!=None
Its unclear in the correct form, i changed
-
self.non_merged_dataset_names = None
-
self.non_merged_dataset_names: list[str] = []
I think thats cleaner, does that work?
- Initialize expert_mixing_coefficients tensors directly on device instead of creating on CPU and transferring with .to(). Avoids unnecessary CPU→GPU transfer overhead. - Change non_merged_dataset_names from None to empty list default. Makes iteration safe and type explicit with list[str] annotation.
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.
Add merge_MOLE_model function to DatasetSpecificMoEWrapper for combining MOLE model heads with the main model during inference.