-
Notifications
You must be signed in to change notification settings - Fork 81
CI: Add data packing test #513
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?
Conversation
Summary of ChangesHello @guapisolo, 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 a comprehensive test suite to verify the integrity of the data packing mechanism. It specifically addresses concerns regarding potential accuracy degradation by comparing loss computations using both packed and traditionally padded data. The new tests cover various scenarios, including distributed training setups with context parallelism, thereby bolstering confidence in the data processing pipeline's reliability. Highlights
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 a valuable test suite to verify the correctness of data packing logic by comparing its loss calculations against a standard padded data approach. The tests are well-designed, covering various scenarios including different tensor parallelism sizes and context parallelism, which significantly increases confidence in the data packing implementation. The update to pyproject.toml is also a good modernization of the configuration. I've identified a couple of minor areas for improvement within the new test code to enhance its robustness and clarity.
| if mask.sum() == 0: | ||
| mask[0] = 1 |
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.
There's a potential IndexError here if response_len is 0. In that case, mask would be an empty tensor, mask.sum() would be 0, and mask[0] = 1 would raise an error. While the current test cases use positive response_len values, making this helper function more robust to handle a response_len of 0 would be good practice for future use.
| if mask.sum() == 0: | |
| mask[0] = 1 | |
| if response_len > 0 and mask.sum() == 0: | |
| mask[0] = 1 |
| for cp_rank in range(cp_size): | ||
| monkeypatch.setattr(mpu, "get_context_parallel_world_size", lambda: cp_size) | ||
| monkeypatch.setattr(mpu, "get_context_parallel_rank", lambda cp_rank=cp_rank: cp_rank) | ||
| monkeypatch.setattr(mpu, "get_tensor_model_parallel_world_size", lambda: tp_size) |
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 monkeypatch.setattr calls for get_context_parallel_world_size and get_tensor_model_parallel_world_size are setting constant values within the loop. These can be moved outside the loop. This refactoring improves clarity by separating the setup that is constant across loop iterations from the setup that changes, and it avoids redundant calls.
| for cp_rank in range(cp_size): | |
| monkeypatch.setattr(mpu, "get_context_parallel_world_size", lambda: cp_size) | |
| monkeypatch.setattr(mpu, "get_context_parallel_rank", lambda cp_rank=cp_rank: cp_rank) | |
| monkeypatch.setattr(mpu, "get_tensor_model_parallel_world_size", lambda: tp_size) | |
| monkeypatch.setattr(mpu, "get_context_parallel_world_size", lambda: cp_size) | |
| monkeypatch.setattr(mpu, "get_tensor_model_parallel_world_size", lambda: tp_size) | |
| for cp_rank in range(cp_size): | |
| monkeypatch.setattr(mpu, "get_context_parallel_rank", lambda cp_rank=cp_rank: cp_rank) |
Some people have concern about miles's data packing logic will reduce accuracy. So add this CI.