Skip to content

Conversation

@popsiclexu
Copy link
Contributor

@popsiclexu popsiclexu commented Nov 20, 2025

Description

This PR adds support for dumping topology for specific HCA devices only.

Type of Change

  • Types
    • Bug fix
    • New feature
      • Transfer Engine
      • Mooncake Store
      • Mooncake EP
      • Integration
      • P2P Store
      • Python Wheel
    • Breaking change
    • CI/CD
    • Documentation update
    • Other

How Has This Been Tested?

Dump topology of all devices: transfer_engine_topology_dump

Dump topology of given devices: transfer_engine_topology_dump --device-name mlx5_0, mlx5_1

Checklist

  • I have performed a self-review of my own code.
  • I have updated the documentation.
  • I have added tests to prove my changes are effective.

… for filtering

Signed-off-by: popsiclexu <[email protected]>
Signed-off-by: zhenxue.xu <[email protected]>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @popsiclexu, 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 introduces a new feature to the Transfer Engine that allows for more precise control over topology information retrieval. By implementing device filtering, users can now specify particular HCA devices when dumping topology, which streamlines debugging and analysis by focusing on relevant hardware configurations. This enhancement provides greater flexibility and efficiency in managing and understanding system topology.

Highlights

  • Device Filtering for Topology Dump: The Transfer Engine now supports filtering topology dumps by specific HCA device names, allowing users to retrieve topology information for only the devices they are interested in.
  • API Update: getLocalTopology: The TransferEnginePy::getLocalTopology method has been updated to accept an optional device_name parameter, which is then used to construct a device filter for the underlying TransferEngine.
  • CLI Enhancement: transfer_engine_topology_dump.py: The transfer_engine_topology_dump.py script now utilizes argparse to introduce a --device-name command-line argument, enabling users to easily specify device filters when running the script.
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 adds functionality to filter the dumped topology by device name. The changes correctly propagate the device filter from the Python script through the C++ bindings to the transfer engine. My review includes two points: one high-severity issue regarding whitespace handling in the device name filter string which could lead to incorrect filtering, and one medium-severity style issue about a missing newline at the end of a file. Overall, the changes are well-structured and address the feature request.

std::string TransferEnginePy::getLocalTopology(const char *device_name) {
pybind11::gil_scoped_release release;
auto device_name_safe = device_name ? std::string(device_name) : "";
auto device_filter = buildDeviceFilter(device_name_safe);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The buildDeviceFilter function does not handle whitespace around the device names in the comma-separated list. For an input like "mlx5_0, mlx5_1", this will result in tokens "mlx5_0" and " mlx5_1". The leading space in the second token will cause the device filter to fail for mlx5_1 because the device name matching is exact.

Please update buildDeviceFilter to trim whitespace from each token. Here is a suggested implementation:

std::vector<std::string> buildDeviceFilter(const std::string &device_names) {
    std::stringstream ss(device_names);
    std::string item;
    std::vector<std::string> tokens;
    while (getline(ss, item, ',')) {
        // trim leading whitespace
        size_t first = item.find_first_not_of(" \t\n\r\f\v");
        if (std::string::npos == first) {
            continue;
        }
        // trim trailing whitespace
        size_t last = item.find_last_not_of(" \t\n\r\f\v");
        tokens.push_back(item.substr(first, (last - first + 1)));
    }
    return tokens;
}

print('Local topology: ', engine.get_local_topology(device_name=args.device_name))

if __name__ == "__main__":
sys.exit(main())
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This file is missing a final newline character. It's a common convention to end files with a newline, and some tools might not process the last line correctly without it.

Suggested change
sys.exit(main())
sys.exit(main())

Copy link
Collaborator

@stmatengss stmatengss left a comment

Choose a reason for hiding this comment

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

LGTM

@stmatengss stmatengss merged commit 7519ac9 into kvcache-ai:main Nov 24, 2025
11 checks passed
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.

2 participants