-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[WIP] [megatron] support megatron embedding/reranker #7630
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
base: main
Are you sure you want to change the base?
[WIP] [megatron] support megatron embedding/reranker #7630
Conversation
Summary of ChangesHello @Jintao-Huang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces foundational test cases to validate the integration and functionality of embedding and reranker models within the Megatron framework. It provides concrete examples of how to configure and execute fine-tuning tasks for these specialized models, ensuring their proper operation and demonstrating the necessary arguments for Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces tests for Megatron-based embedding and reranker models. The tests are a good starting point for verifying the new functionalities. However, there are a few issues in the test file that need to be addressed:
- A critical configuration mismatch between
CUDA_VISIBLE_DEVICESandtensor_model_parallel_sizewill cause the tests to fail. - The
test_rerankerfunction is not executed when the script is run directly. - There's a minor code duplication with imports that can be cleaned up.
Additionally, based on the provided code context, the implementation for handling embedding and generative_reranker task types in MegatronTrainer seems to be missing. This makes it difficult to fully assess the correctness of the tests and the feature itself. Please ensure the full implementation is included in the pull request for a complete review.
tests/megatron/test_embedding.py
Outdated
| @@ -0,0 +1,54 @@ | |||
| import os | |||
|
|
|||
| os.environ['CUDA_VISIBLE_DEVICES'] = '0' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CUDA_VISIBLE_DEVICES is set to '0', which makes only one GPU visible to the test. However, both test_embedding and test_reranker are configured with tensor_model_parallel_size=2, which requires at least two GPUs. This configuration mismatch will cause the test to fail. To fix this, you should make at least two GPUs visible.
| os.environ['CUDA_VISIBLE_DEVICES'] = '0' | |
| os.environ['CUDA_VISIBLE_DEVICES'] = '0,1' |
|
|
||
|
|
||
| def test_embedding(): | ||
| from swift.megatron import megatron_sft_main, MegatronSftArguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement from swift.megatron import megatron_sft_main, MegatronSftArguments is repeated in both test_embedding (line 7) and test_reranker (line 31). To follow the DRY (Don't Repeat Yourself) principle and improve code clarity, it's recommended to move this import to the top of the file, outside of the test functions.
| if __name__ == '__main__': | ||
| test_embedding() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.