[BugFix] Implement scatter-done event handling for RDMA writes#189
[BugFix] Implement scatter-done event handling for RDMA writes#189matthewygf wants to merge 3 commits intoLMCache:mainfrom
Conversation
Added handling for scatter-done events to prevent RDMA writes from racing with ongoing reads in the same pool. Introduced event recording for synchronization in multi-batch processing. Signed-off-by: Matthew Yeung <yyygggfff@hotmail.com>
Summary of ChangesHello, 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 enhances 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. Changelog
Activity
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.
Pull request overview
This PR implements scatter-done event handling for RDMA writes in the NPU connector's ping-pong pipeline, resolving a TODO about potential race conditions between RDMA writes and scatter reads on the same memory pool.
Changes:
- Added per-pool scatter-done events and tracking flags to synchronize RDMA writes with ongoing scatter operations
- Replaced a TODO comment with actual event recording and synchronization logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Code Review
This pull request introduces synchronization for RDMA writes and scatter operations to prevent race conditions, which is a solid improvement for data integrity. The use of per-pool events and flags is well-implemented. I have one suggestion to improve maintainability by avoiding a hardcoded value.
Ensure compute stream waits for load_stream's KV scatter completion before attention reads. Signed-off-by: Matthew Yeung <yyygggfff@hotmail.com>
This pull request adds synchronization mechanisms to prevent race conditions when using RDMA writes and scatter operations on the same memory pool in
lmcache_ascend/v1/npu_connector.py. The changes ensure that RDMA operations do not overwrite buffers that are still being read by a scatter operation, improving data integrity and correctness.Synchronization improvements for RDMA and scatter operations:
pool_scatter_events) and flags (pool_scatter_recorded) to ensure that an RDMA write does not race with an ongoing scatter read from the same pool. The code now waits for the previous scatter to complete before allowing RDMA writes to proceed.load_streamafter each scatter operation, and updated the logic to track which pool's event was recorded, ensuring proper synchronization for subsequent RDMA writes.