MoE++: Accelerating Mixture-of-Experts Methods with Zero-Computation Experts
5
16 commits
6 linked in READMEs
updated Dec 7, 2024
Paper or resources for more information: [Paper] [Code]
We introduce three types of zero-computation experts: the zero expert, copy expert, and constant expert, which correspond to discard, skip, and replace operations, respectively. Moreover, we leverage gating residuals, enabling each token to consider the pathway taken in the previous layer when selecting the appropriate experts.
| HuggingFace Model | |
|---|---|
| MoE++7B-Base | ๐ค MoE++7B-Base |
| MoE++7B-Chat | ๐ Coming Soon |
For an MoE++ model, its computational complexity is always less than that of MoE models with the same number of parameters.
Extensive experimental results demonstrate that MoE++ achieves better performance while delivering 1.1~2.1x expert forward throughput compared to a vanilla MoE model of the same size, which lays a solid foundation for developing advanced and efficient MoE-related models.
Given that zero-computation experts have negligible parameters, we can deploy all zero-computation experts on each GPU, eliminating the significant communication overhead and expert load imbalance associated with FFN experts distributed across different GPUs.
MoE++ allows simple tokens to utilize fewer FFN experts, freeing up more FFN experts to focus on challenging tokens. This results in both Reduced Computation and Enhanced Performance.
These findings confirm that MoE++ allows simple tokens to utilize fewer FFN experts, freeing up more FFN experts to focus on challenging tokens.
Gating residuals effectively establish connections between different MoE++ layers and reduce the variance of routing scores. Meanwhile, the gating residuals do not change the mean and range of values of the routing scores. Consequently, gating residuals contribute to the stable routing of heterogeneous expert architectures in MoE++.
If you want to load the model from the model hub on Hugging Face or on local, you can use the following code snippets.
from transformers import AutoModelForCausalLM, AutoTokenizer
question = "Hello!"
model = AutoModelForCausalLM.from_pretrained("Chat-UniVi/MoE-Plus-Plus-7B", trust_remote_code=True, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained("Chat-UniVi/MoE-Plus-Plus-7B", trust_remote_code=True)
inputs = tokenizer(question, return_tensors='pt').to(model.device)
response = model.generate(inputs.input_ids, max_length=128)
print(tokenizer.decode(response.cpu()[0], skip_special_tokens=True))
Coming soon...
# For example, test MoE++ on winogrande
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 accelerate launch \
--main_process_port 2004 -m lm_eval --model hf \
--model_args pretrained=MoE-Plus-Plus-7B \
--tasks winogrande \
--batch_size 1 \
--output_path Results/winogrande
If you find this paper useful, please consider staring ๐ this repo and citing ๐ our paper:
@article{jin2024moe,
title={MoE++: Accelerating Mixture-of-Experts Methods with Zero-Computation Experts},
author={Jin, Peng and Zhu, Bo and Yuan, Li and Yan, Shuicheng},
journal={arXiv preprint arXiv:2410.07348},
year={2024}
}
MoE++: Accelerating Mixture-of-Experts Methods with Zero-Computation Experts
5
16 commits
6 linked in READMEs
updated Dec 7, 2024
Paper or resources for more information: [Paper] [Code]
We introduce three types of zero-computation experts: the zero expert, copy expert, and constant expert, which correspond to discard, skip, and replace operations, respectively. Moreover, we leverage gating residuals, enabling each token to consider the pathway taken in the previous layer when selecting the appropriate experts.
| HuggingFace Model | |
|---|---|
| MoE++7B-Base | ๐ค MoE++7B-Base |
| MoE++7B-Chat | ๐ Coming Soon |
For an MoE++ model, its computational complexity is always less than that of MoE models with the same number of parameters.
Extensive experimental results demonstrate that MoE++ achieves better performance while delivering 1.1~2.1x expert forward throughput compared to a vanilla MoE model of the same size, which lays a solid foundation for developing advanced and efficient MoE-related models.
Given that zero-computation experts have negligible parameters, we can deploy all zero-computation experts on each GPU, eliminating the significant communication overhead and expert load imbalance associated with FFN experts distributed across different GPUs.
MoE++ allows simple tokens to utilize fewer FFN experts, freeing up more FFN experts to focus on challenging tokens. This results in both Reduced Computation and Enhanced Performance.
These findings confirm that MoE++ allows simple tokens to utilize fewer FFN experts, freeing up more FFN experts to focus on challenging tokens.
Gating residuals effectively establish connections between different MoE++ layers and reduce the variance of routing scores. Meanwhile, the gating residuals do not change the mean and range of values of the routing scores. Consequently, gating residuals contribute to the stable routing of heterogeneous expert architectures in MoE++.
If you want to load the model from the model hub on Hugging Face or on local, you can use the following code snippets.
from transformers import AutoModelForCausalLM, AutoTokenizer
question = "Hello!"
model = AutoModelForCausalLM.from_pretrained("Chat-UniVi/MoE-Plus-Plus-7B", trust_remote_code=True, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained("Chat-UniVi/MoE-Plus-Plus-7B", trust_remote_code=True)
inputs = tokenizer(question, return_tensors='pt').to(model.device)
response = model.generate(inputs.input_ids, max_length=128)
print(tokenizer.decode(response.cpu()[0], skip_special_tokens=True))
Coming soon...
# For example, test MoE++ on winogrande
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 accelerate launch \
--main_process_port 2004 -m lm_eval --model hf \
--model_args pretrained=MoE-Plus-Plus-7B \
--tasks winogrande \
--batch_size 1 \
--output_path Results/winogrande
If you find this paper useful, please consider staring ๐ this repo and citing ๐ our paper:
@article{jin2024moe,
title={MoE++: Accelerating Mixture-of-Experts Methods with Zero-Computation Experts},
author={Jin, Peng and Zhu, Bo and Yuan, Li and Yan, Shuicheng},
journal={arXiv preprint arXiv:2410.07348},
year={2024}
}