Skip to content

fix: fix a memleak#1206

Open
blueswhen wants to merge 1 commit intomainfrom
fix_leak
Open

fix: fix a memleak#1206
blueswhen wants to merge 1 commit intomainfrom
fix_leak

Conversation

@blueswhen
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @blueswhen, 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 memory leak issue identified with frequent small data communications using NCCL. The solution involves migrating specific communication patterns from the NCCL backend to the Gloo backend, utilizing CPU pinned-memory tensors for these operations. This change ensures more stable memory usage during inter-process communication, particularly for broadcasting and gathering request information within and across nodes.

Highlights

  • Communication Backend Switch: Replaced NCCL with Gloo for specific small data communication operations to mitigate memory leaks, as indicated by an inline comment in the code.
  • Tensor Migration: Switched from CUDA tensors to CPU pinned-memory tensors for broadcast and all-gather operations to support the Gloo backend, specifically for node_broadcast_tensor and multinode TP tensors.
  • Multinode TP Mode Updates: Applied similar NCCL to Gloo and CUDA to CPU tensor changes for multinode Tensor Parallelism (TP) communication, ensuring consistency across different communication patterns.

🧠 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
  • lightllm/server/router/model_infer/mode_backend/base_backend.py
    • Replaced self.node_broadcast_tensor (CUDA tensor) with self.node_broadcast_tensor_cpu (CPU pinned-memory tensor) and self.node_nccl_group with self.node_gloo_group.
    • Introduced self.multinode_tp_gather_item_tensor_cpu and self.multinode_tp_all_gather_tensor_cpu (CPU pinned-memory tensors) and replaced self.multinode_tp_nccl_group with self.multinode_tp_gloo_group for multinode TP mode.
    • Updated _try_read_new_reqs_normal and _try_read_new_reqs_multinode_tp functions to use the new Gloo groups and CPU tensors for communication and status checks.
  • lightllm/server/router/model_infer/mode_backend/dp_backend/dp_shared_kv_trans.py
    • Updated dist.barrier calls to use self.backend.node_gloo_group instead of self.backend.node_nccl_group.
Activity
  • No specific activity (comments, reviews, or progress updates) 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
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 addresses a memory leak by switching from nccl to gloo for small data communications, which is a sound approach. The implementation is consistent across the modified files, correctly utilizing CPU-pinned tensors with the gloo backend. I have identified one minor issue regarding some leftover code that is no longer used after this change and should be removed to improve code maintainability.

@blueswhen blueswhen force-pushed the fix_leak branch 2 times, most recently from fca25ff to 4298455 Compare February 7, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant