Skip to content

[PG] force register local memory on specific devices#1656

Merged
UNIDY2002 merged 4 commits intomainfrom
sunxun/fix
Mar 14, 2026
Merged

[PG] force register local memory on specific devices#1656
UNIDY2002 merged 4 commits intomainfrom
sunxun/fix

Conversation

@UNIDY2002
Copy link
Copy Markdown
Collaborator

Description

In this way, processes can know exactly which NIC to use when transferring data to peers.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake EP (mooncake-ep)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • PyTorch Backend (mooncake-pg)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Other

How Has This Been Tested?

Checklist

  • I have performed a self-review of my own code.
  • I have formatted my own code using ./scripts/code_format.sh before submitting.
  • I have updated the documentation.
  • I have added tests to prove my changes are effective.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 mooncake-pg PyTorch backend by enforcing device-specific registration of local memory. By explicitly associating registered memory with a particular GPU device, the system can accurately determine which NIC to use for peer-to-peer data transfers, leading to more efficient and reliable communication in distributed environments.

Highlights

  • Device-Specific Memory Registration: Local memory buffers are now registered with a specific GPU device ID rather than a generic wildcard location.
  • Improved NIC Selection: This change enables processes to precisely identify and utilize the correct Network Interface Card (NIC) for data transfers to peers.

🧠 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
  • mooncake-pg/src/connection_poller.cpp
    • Included the cuda_alike.h header.
    • Introduced logic to query the current CUDA device ID.
    • Updated registerLocalMemory calls for warmup regions to use the specific device location.
  • mooncake-pg/src/mooncake_backend.cpp
    • Included the cuda_alike.h header.
    • Added device ID retrieval at the start of the MooncakeBackend constructor.
    • Modified all registerLocalMemory calls for send/receive buffers and CPU sync regions to use the device-specific location.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 aims to force local memory registration on specific devices, likely to control NIC selection for data transfers. The changes correctly modify registerLocalMemory calls to use a device-specific location. However, I've identified a critical issue regarding code robustness and duplication. The logic to get the CUDA device ID is duplicated and will cause a crash in environments without CUDA devices. My review includes comments with suggestions to centralize this logic and add necessary checks to prevent crashes, improving both maintainability and stability.

Comment thread mooncake-pg/src/mooncake_backend.cpp Outdated
Comment thread mooncake-pg/src/connection_poller.cpp Outdated
@UNIDY2002 UNIDY2002 enabled auto-merge (squash) March 14, 2026 02:12
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member

@yuechen-sys yuechen-sys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for your contribution!

@UNIDY2002 UNIDY2002 merged commit bd4a183 into main Mar 14, 2026
13 of 15 checks passed
@UNIDY2002 UNIDY2002 deleted the sunxun/fix branch March 14, 2026 07:19
UNIDY2002 added a commit that referenced this pull request Mar 18, 2026
whn09 pushed a commit to whn09/Mooncake that referenced this pull request Apr 4, 2026
In this way, processes can know exactly which NIC to use when transferring data to peers.
whn09 pushed a commit to whn09/Mooncake that referenced this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants