Conversation
Summary of ChangesHello @ympcMark, 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 refactors the Mooncake backend's buffer management strategy by moving away from implicitly indexing into 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 refactors the mechanism for sharing peer memory locations by introducing a SegmentInfo struct and using Torch's rendezvous store for communication, instead of relying on indexed access into SegmentDesc::buffers. This is a good change that improves code clarity and maintainability by replacing magic indices with named fields. The implementation looks solid, but I have identified one area for improvement regarding data validation to enhance robustness.
| meta_.segmentDescs[pollingRank] = segment_desc; | ||
| std::string buffer_key = "buffer_" + std::to_string(backendIndex_) + "_" + std::to_string(pollingRank); | ||
| auto buffer_data = store->get(buffer_key); | ||
| memcpy(&meta_.segmentInfos[pollingRank], buffer_data.data(), sizeof(SegmentInfo)); |
There was a problem hiding this comment.
The code copies data using memcpy without validating the size of the source buffer buffer_data. This is unsafe as it can lead to memory corruption if the store returns data of an unexpected size (e.g., due to version mismatches or data corruption). Please add a size check before this operation for robustness and security.
TORCH_CHECK(buffer_data.size() == sizeof(SegmentInfo), "Received SegmentInfo of unexpected size from store for rank ", pollingRank);
memcpy(&meta_.segmentInfos[pollingRank], buffer_data.data(), sizeof(SegmentInfo));|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
E2E test have passed. Well done! |
Description
Part of #1225.
Avoid indexing SegmentDesc::buffers to obtain peer memory locations; transfer them through Torch's rendezvous store instead
Type of Change
How Has This Been Tested?
Checklist
./scripts/code_format.shbefore submitting.