[PG] Support full reduction ops (Product/Min/Max) and fix reduce kernel indexing bug#1440
[PG] Support full reduction ops (Product/Min/Max) and fix reduce kernel indexing bug#1440UNIDY2002 merged 4 commits intokvcache-ai:mainfrom
Conversation
…tests in test_mooncake_backend.py to cover new ops
…tests in test_mooncake_backend.py to cover new ops
Summary of ChangesHello @hhr2449, 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 significantly enhances the CUDA backend's distributed communication capabilities by introducing support for product, minimum, and maximum reduction operations. Concurrently, it addresses a crucial indexing error in the 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.
Code Review
This pull request successfully adds support for PRODUCT, MIN, and MAX reduction operations to the CUDA backend and fixes a critical indexing bug in the reduceKernel. The changes in the CUDA kernel are correct and the TORCH_CHECK has been updated accordingly. The accompanying Python tests are well-written and cover the new functionality. I've included a few minor suggestions to improve code style and adhere to PEP 8 guidelines in the test file.
| tensor = torch.tensor([2], dtype = torch.int32, device = "cuda") | ||
| dist.all_reduce(tensor, op = dist.ReduceOp.PRODUCT) |
There was a problem hiding this comment.
There are extra spaces around the = for keyword arguments. According to the PEP 8 style guide, there should be no spaces in this context. This issue is also present on lines 30-31 and 35-36.
| tensor = torch.tensor([2], dtype = torch.int32, device = "cuda") | |
| dist.all_reduce(tensor, op = dist.ReduceOp.PRODUCT) | |
| tensor = torch.tensor([2], dtype=torch.int32, device="cuda") | |
| dist.all_reduce(tensor, op=dist.ReduceOp.PRODUCT) |
References
- PEP 8 recommends not using spaces around the
=sign for keyword arguments. (link)
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Description
Part of #1225
This PR implements support for reduction operations in the CUDA backend and fixes a indexing bug in the
reduceKernel.Key Changes:
Support for New Reduce Ops:
PRODUCT,MIN, andMAXlogic inreduceKernellaunchReduceKernelassertions to allow these operations.Bugfix in
reduceKernel:acc) in the CUDA kernel.acc = src[elem_idx]acc = src[rank * numElements + elem_idx]Unit Tests:
mooncake-wheel/tests/test_mooncake_backend.pyto include test cases forall_reduce_product,all_reduce_min, andall_reduce_max.Type of Change
How Has This Been Tested?
I ran the updated unit tests in a GPU environment to verify the correctness of the new reduction operations and the kernel logic.
python3 -m unittest mooncake-wheel.tests.test_mooncake_backendChecklist
./scripts/code_format.shbefore submitting.