[BUG] Fix some bugs in OpenMoE Implementation #5267
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.
📌 Checklist before creating the PR
[doc/gemini/tensor/...]: A concise description
🚨 Issue number
📝 What does this PR do?
The original implementation will raise some bugs when running on CPU. So I modified the colossalai/moe/layers.py to avoid importing LoadBalancer when unnecessary.
The original convert_openmoe_checkpoint.py is very memory-consuming(almost taking up 3x model weights space), which cause it inconvenient to convert 34B version(requiring ~500GB memory). I added
init_empty_weights
and remove the unnecessary model loading code to save up memory in the conversion process. Now it can use ~170GB memory to convert 34B version on CPU.Update the inference example/script to allow multi-GPUs inference(using HuggingFace library) and provide an inference demo on Colab, which can be seen in the new README.md.
Update the model config of base and 8B versions, also add config file of 34B model.
To test the correctness of this PR, you can run the Colab notebook here to test all of my modifications.
https://colab.research.google.com/drive/1Je0oAm3o9ZyZC5Yp7fJmWUn-qrsrASSc?usp=sharing
💥 Checklist before requesting a review
⭐️ Do you enjoy contributing to Colossal-AI?
Tell us more if you don't enjoy contributing to Colossal-AI.