Skip to content

[EP] Enable Fabric Mem only if MC_USE_NVLINK_IPC is explicitly set to zero#1637

Merged
ympcMark merged 3 commits intomainfrom
sunxun/fix
Mar 10, 2026
Merged

[EP] Enable Fabric Mem only if MC_USE_NVLINK_IPC is explicitly set to zero#1637
ympcMark merged 3 commits intomainfrom
sunxun/fix

Conversation

@UNIDY2002
Copy link
Copy Markdown
Collaborator

Description

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.

@UNIDY2002 UNIDY2002 requested a review from ympcMark as a code owner March 10, 2026 03:16
@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 addresses a bug in the Mooncake EP module where the activation of Fabric Memory was incorrectly handled based on the presence of an environment variable. The change refines the condition for enabling Fabric Memory, ensuring it is active by default and only disabled when explicitly requested, thereby improving the intended behavior of memory management within the system.

Highlights

  • Fabric Memory Activation Logic: Updated the logic for enabling Fabric Memory (MNNVL) to only disable it when the MC_USE_NVLINK_IPC environment variable is explicitly set to '0'. Previously, Fabric Memory was disabled if the variable was set to any value, including an empty string or non-zero values.
  • Environment Variable Handling: Modified the supportFabricMem function to correctly parse the MC_USE_NVLINK_IPC environment variable, ensuring that strcmp is used to check for the specific value '0' rather than just its presence.

🧠 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-ep/src/mooncake_ep_buffer.cpp
    • Fixed the logic for supportFabricMem to correctly interpret the MC_USE_NVLINK_IPC environment variable, enabling Fabric Memory unless MC_USE_NVLINK_IPC is explicitly '0'.
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.

@UNIDY2002
Copy link
Copy Markdown
Collaborator Author

cc @he-yufeng

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 change the condition for enabling fabric memory, making it active only when MC_USE_NVLINK_IPC is explicitly set to '0'. However, the implementation in mooncake-ep/src/mooncake_ep_buffer.cpp contains a significant logic error where the newly calculated fabric_enabled flag is never used. This results in fabric memory being always enabled if hardware supports it, effectively ignoring the user's intent to disable it via the environment variable, which is a security regression as it bypasses intended access control logic for a feature that grants broad memory access across devices. Furthermore, this change creates a discrepancy with a similar check in another module, which could lead to inconsistent behavior.

Comment thread mooncake-ep/src/mooncake_ep_buffer.cpp Outdated
UNIDY2002 and others added 2 commits March 10, 2026 11:20
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@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
Collaborator

@ympcMark ympcMark left a comment

Choose a reason for hiding this comment

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

LGTM

@ympcMark ympcMark merged commit 9968d05 into main Mar 10, 2026
28 of 30 checks passed
@UNIDY2002 UNIDY2002 deleted the sunxun/fix branch March 10, 2026 05:26
@UNIDY2002
Copy link
Copy Markdown
Collaborator Author

@ympcMark Next time, please ensure you click "squash and merge"

@ympcMark
Copy link
Copy Markdown
Collaborator

Oh, I will check it next time!

@he-yufeng
Copy link
Copy Markdown
Contributor

Thanks for the fix and the cc! This makes sense — the original getenv() check I wrote in #1629 was too broad, it would disable fabric mem even when the env var was set to a non-zero value. The explicit strcmp(nvlink_ipc, "0") check is cleaner.

One thing I noticed: the Gemini review flagged that fabric_enabled is true when MC_USE_NVLINK_IPC=0, which then enables fabric mem. The variable name reads a bit counterintuitive since MC_USE_NVLINK_IPC=0 means "don't use NVLink IPC" → "use fabric mem instead". Might be worth a comment clarifying the semantics, but not a blocker — the logic itself is correct.

@UNIDY2002
Copy link
Copy Markdown
Collaborator Author

One thing I noticed: the Gemini review flagged that fabric_enabled is true when MC_USE_NVLINK_IPC=0, which then enables fabric mem. The variable name reads a bit counterintuitive since MC_USE_NVLINK_IPC=0 means "don't use NVLink IPC" → "use fabric mem instead". Might be worth a comment clarifying the semantics, but not a blocker — the logic itself is correct.

Yes, I agree with you. I was just mirroring the logic here:

const char *hip_ipc = getenv("MC_USE_HIP_IPC");
const char *nvlink_ipc = getenv("MC_USE_NVLINK_IPC");
bool fabric_enabled = (hip_ipc && strcmp(hip_ipc, "0") == 0) ||
(nvlink_ipc && strcmp(nvlink_ipc, "0") == 0);
if (!fabric_enabled) {
return false;
}

Perhaps we have to clarify the semantics of these env vars in the future.

@stmatengss
Copy link
Copy Markdown
Collaborator

LGTM

@ympcMark Please use squash merge to consolidate duplicate commits.

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.

5 participants